Fixed loose error

This commit is contained in:
2026-05-17 05:13:28 +02:00
parent c7529412f4
commit 1bcbca00b8
3 changed files with 16 additions and 6 deletions
+4 -4
View File
@@ -497,13 +497,13 @@ as_px = {
range_end_inc_px = { "..=" } range_end_inc_px = { "..=" }
range_end_exc_px = { ".." } range_end_exc_px = { ".." }
increment_px = { "++" } inc_px = { "++" }
decrement_px = { "++" } dec_px = { "++" }
postfix = { postfix = {
field_px field_px
| increment_px | inc_px
| decrement_px | dec_px
| call_px | call_px
| macro_call_px | macro_call_px
| struct_px | struct_px
+11 -1
View File
@@ -41,7 +41,7 @@ macro_rules! ast_ensure {
Err(AstError { Err(AstError {
span: $pair.as_span(), span: $pair.as_span(),
error_code: crate::error::ErrorCode::AstGenBug, error_code: crate::error::ErrorCode::AstGenBug,
error_message: format!("Possible bug: expected {:?}, got {}", $rule, $pair), error_message: format!("Possible bug: expected {:?}, got {:?}", $rule, $pair.as_rule()),
recovered: None, recovered: None,
}) })
} }
@@ -50,6 +50,16 @@ macro_rules! ast_ensure {
#[macro_export] #[macro_export]
macro_rules! ast_expr { macro_rules! ast_expr {
(use $r:expr, $($v:expr),* $(,)?) => {{
let mut analyzer = $crate::error::AstErrorAnalyzer(None);
$(
analyzer.get($v).get()?;
)*
analyzer.build($r)
}};
($($item:ident)::+ { $($k:ident: $v:expr),* $(,)? }) => {{ ($($item:ident)::+ { $($k:ident: $v:expr),* $(,)? }) => {{
let mut analyzer = $crate::error::AstErrorAnalyzer(None); let mut analyzer = $crate::error::AstErrorAnalyzer(None);
+1 -1
View File
@@ -101,7 +101,7 @@ impl<'a> TryFrom<pest::iterators::Pair<'a, Rule>> for Expression {
postfixes: postfixes, postfixes: postfixes,
}) })
} else { } else {
exp ast_expr!(use exp?, prefixes, postfixes)
} }
} }