diff options
Diffstat (limited to 'crates/rebel-parse')
-rw-r--r-- | crates/rebel-parse/src/ast/typ.rs | 9 | ||||
-rw-r--r-- | crates/rebel-parse/src/grammar/recipe.rs | 15 |
2 files changed, 3 insertions, 21 deletions
diff --git a/crates/rebel-parse/src/ast/typ.rs b/crates/rebel-parse/src/ast/typ.rs index 18ea827..939b67d 100644 --- a/crates/rebel-parse/src/ast/typ.rs +++ b/crates/rebel-parse/src/ast/typ.rs @@ -11,17 +11,10 @@ pub enum Type<'a> { pub enum Literal<'a> { Unit, Tuple(Vec<Type<'a>>), - Array(Box<Type<'a>>, ArrayLen), + Array(Box<Type<'a>>), Struct(Vec<StructField<'a>>), } -#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord)] -pub enum ArrayLen { - Free, - Fixed(u32), - Dynamic, -} - #[derive(Debug, Clone, PartialEq, Eq)] pub struct StructField<'a> { pub name: &'a str, diff --git a/crates/rebel-parse/src/grammar/recipe.rs b/crates/rebel-parse/src/grammar/recipe.rs index c9fe1e2..b1ac32f 100644 --- a/crates/rebel-parse/src/grammar/recipe.rs +++ b/crates/rebel-parse/src/grammar/recipe.rs @@ -72,24 +72,13 @@ peg::parser! { / p('(') elements:(typ() ** p(',')) p(',')? p(')') { typ::Literal::Tuple(elements) } - / p('[') typ:typ() len:array_len() p(']') { - typ::Literal::Array(Box::new(typ), len) + / p('[') typ:typ() p(']') { + typ::Literal::Array(Box::new(typ)) } / p('{') entries:delimited(<struct_field_typ()>, <p(',')>) p('}') { typ::Literal::Struct(entries) } - rule array_len() -> typ::ArrayLen - = p(';') len:number() { ? - Ok(typ::ArrayLen::Fixed(len.try_into().or(Err("Invalid array length"))?)) - } - / p(';') [Token::Ident(name) if *name == "_"] { - typ::ArrayLen::Free - } - / { - typ::ArrayLen::Dynamic - } - rule pat() -> Pat<'a> = path:path() { Pat::Path(path) } |