From ba0da33509cc2e02b1685cf742e4da8cb9d02f88 Mon Sep 17 00:00:00 2001 From: Schrottkatze Date: Wed, 24 Apr 2024 20:00:17 +0200 Subject: [PATCH] split up files a bit --- crates/lang/src/parser/grammar/expression.rs | 42 +------------------ .../parser/grammar/expression/collection.rs | 27 ++++++++++++ .../grammar/expression/collection/attr_set.rs | 5 +++ .../grammar/expression/collection/vec.rs | 5 +++ 4 files changed, 38 insertions(+), 41 deletions(-) create mode 100644 crates/lang/src/parser/grammar/expression/collection.rs create mode 100644 crates/lang/src/parser/grammar/expression/collection/attr_set.rs create mode 100644 crates/lang/src/parser/grammar/expression/collection/vec.rs diff --git a/crates/lang/src/parser/grammar/expression.rs b/crates/lang/src/parser/grammar/expression.rs index 3f3a43e..2d3460c 100644 --- a/crates/lang/src/parser/grammar/expression.rs +++ b/crates/lang/src/parser/grammar/expression.rs @@ -2,49 +2,9 @@ use crate::parser::{syntax_kind::SyntaxKind::*, CompletedMarker, Parser}; use self::{collection::collection, instruction::instr, lit::literal}; +mod collection; mod instruction; mod lit; -mod collection { - use enumset::enum_set; - - use crate::parser::{ - syntax_kind::{SyntaxKind::*, TokenSet}, - CompletedMarker, Parser, - }; - - use self::{attr_set::attr_set, matrix::matrix, vec::vec}; - - const COLLECTION_START: TokenSet = enum_set!(MAT_KW | L_BRACK | L_BRACE); - - pub fn collection(p: &mut Parser) -> Option { - if !COLLECTION_START.contains(p.current()) { - return None; - } - - Some(match p.current() { - MAT_KW => matrix(p), - L_BRACK => vec(p), - L_BRACE => attr_set(p), - _ => unreachable!(), - }) - } - - mod matrix; - mod vec { - use crate::parser::{CompletedMarker, Parser}; - - pub fn vec(p: &mut Parser) -> CompletedMarker { - todo!() - } - } - mod attr_set { - use crate::parser::{CompletedMarker, Parser}; - - pub fn attr_set(p: &mut Parser) -> CompletedMarker { - todo!() - } - } -} pub fn expression(p: &mut Parser) -> Option { let expr = p.start("expr"); diff --git a/crates/lang/src/parser/grammar/expression/collection.rs b/crates/lang/src/parser/grammar/expression/collection.rs new file mode 100644 index 0000000..0b525ad --- /dev/null +++ b/crates/lang/src/parser/grammar/expression/collection.rs @@ -0,0 +1,27 @@ +use enumset::enum_set; + +use crate::parser::{ + syntax_kind::{SyntaxKind::*, TokenSet}, + CompletedMarker, Parser, +}; + +use self::{attr_set::attr_set, matrix::matrix, vec::vec}; + +mod attr_set; +mod matrix; +mod vec; + +const COLLECTION_START: TokenSet = enum_set!(MAT_KW | L_BRACK | L_BRACE); + +pub fn collection(p: &mut Parser) -> Option { + if !COLLECTION_START.contains(p.current()) { + return None; + } + + Some(match p.current() { + MAT_KW => matrix(p), + L_BRACK => vec(p), + L_BRACE => attr_set(p), + _ => unreachable!(), + }) +} diff --git a/crates/lang/src/parser/grammar/expression/collection/attr_set.rs b/crates/lang/src/parser/grammar/expression/collection/attr_set.rs new file mode 100644 index 0000000..a71ee7f --- /dev/null +++ b/crates/lang/src/parser/grammar/expression/collection/attr_set.rs @@ -0,0 +1,5 @@ +use crate::parser::{CompletedMarker, Parser}; + +pub fn attr_set(p: &mut Parser) -> CompletedMarker { + todo!() +} diff --git a/crates/lang/src/parser/grammar/expression/collection/vec.rs b/crates/lang/src/parser/grammar/expression/collection/vec.rs new file mode 100644 index 0000000..76f3684 --- /dev/null +++ b/crates/lang/src/parser/grammar/expression/collection/vec.rs @@ -0,0 +1,5 @@ +use crate::parser::{CompletedMarker, Parser}; + +pub fn vec(p: &mut Parser) -> CompletedMarker { + todo!() +}