Updated pattern ast
This commit is contained in:
@@ -36,7 +36,7 @@ pub enum Pattern {
|
||||
Struct(Path, Vec<Identifier>),
|
||||
Tuple(Vec<Identifier>),
|
||||
Literal(Literal),
|
||||
Path(Path),
|
||||
Path(bool, Path),
|
||||
Id(Identifier),
|
||||
}
|
||||
|
||||
|
||||
@@ -135,7 +135,7 @@ literal = {
|
||||
// ======================================================
|
||||
|
||||
multi_pat_template = _{
|
||||
"[" ~ (identifier ~ ("," ~ identifier)*)? ~ "]"
|
||||
(identifier ~ ("," ~ identifier)*)?
|
||||
}
|
||||
|
||||
tuple_pattern = {
|
||||
|
||||
@@ -7,8 +7,8 @@ use crate::{
|
||||
Rule,
|
||||
ast::*,
|
||||
ast_ensure, ast_expr,
|
||||
error::{AstError, IntoErr, collect_recovered},
|
||||
parser::consume_rule,
|
||||
error::{AstError, AstResult, IntoErr, collect_recovered},
|
||||
parser::{consume_rule, listen_rule},
|
||||
};
|
||||
|
||||
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::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),
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user