Updated pattern ast

This commit is contained in:
2026-05-28 11:34:14 +02:00
parent 83e98573aa
commit e09c7926e5
3 changed files with 8 additions and 5 deletions
+1 -1
View File
@@ -36,7 +36,7 @@ pub enum Pattern {
Struct(Path, Vec<Identifier>), Struct(Path, Vec<Identifier>),
Tuple(Vec<Identifier>), Tuple(Vec<Identifier>),
Literal(Literal), Literal(Literal),
Path(Path), Path(bool, Path),
Id(Identifier), Id(Identifier),
} }
+1 -1
View File
@@ -135,7 +135,7 @@ literal = {
// ====================================================== // ======================================================
multi_pat_template = _{ multi_pat_template = _{
"[" ~ (identifier ~ ("," ~ identifier)*)? ~ "]" (identifier ~ ("," ~ identifier)*)?
} }
tuple_pattern = { tuple_pattern = {
+6 -3
View File
@@ -7,8 +7,8 @@ use crate::{
Rule, Rule,
ast::*, ast::*,
ast_ensure, ast_expr, ast_ensure, ast_expr,
error::{AstError, IntoErr, collect_recovered}, error::{AstError, AstResult, IntoErr, collect_recovered},
parser::consume_rule, parser::{consume_rule, listen_rule},
}; };
impl<'a> TryFrom<pest::iterators::Pair<'a, Rule>> for Identifier { impl<'a> TryFrom<pest::iterators::Pair<'a, Rule>> for Identifier {
@@ -76,7 +76,10 @@ impl<'a> TryFrom<pest::iterators::Pair<'a, Rule>> for Pattern {
Rule::identifier => ast_expr!(Pattern::Id(pair.try_into())), Rule::identifier => ast_expr!(Pattern::Id(pair.try_into())),
Rule::static_path => ast_expr!(Pattern::Path(pair.try_into())), Rule::path_pattern => ast_expr!(Pattern::Path(
Ok(listen_rule(&mut inner, Rule::mutable)) as AstResult<'_, bool>,
inner.next().unwrap().try_into()
)),
_ => AstError::bug_unimplemented(pair), _ => AstError::bug_unimplemented(pair),
} }