From 1bcbca00b801cd73ac22603f08057a63b9a3b98a Mon Sep 17 00:00:00 2001 From: Klesti Selimaj Date: Sun, 17 May 2026 05:13:28 +0200 Subject: [PATCH] Fixed loose error --- parser/src/grammar.pest | 8 ++++---- parser/src/lib.rs | 12 +++++++++++- parser/src/parser/common/expr.rs | 2 +- 3 files changed, 16 insertions(+), 6 deletions(-) diff --git a/parser/src/grammar.pest b/parser/src/grammar.pest index 3c45c37..f98962e 100644 --- a/parser/src/grammar.pest +++ b/parser/src/grammar.pest @@ -497,13 +497,13 @@ as_px = { range_end_inc_px = { "..=" } range_end_exc_px = { ".." } -increment_px = { "++" } -decrement_px = { "++" } +inc_px = { "++" } +dec_px = { "++" } postfix = { field_px - | increment_px - | decrement_px + | inc_px + | dec_px | call_px | macro_call_px | struct_px diff --git a/parser/src/lib.rs b/parser/src/lib.rs index df5cbf5..245fd9f 100644 --- a/parser/src/lib.rs +++ b/parser/src/lib.rs @@ -41,7 +41,7 @@ macro_rules! ast_ensure { Err(AstError { span: $pair.as_span(), 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, }) } @@ -50,6 +50,16 @@ macro_rules! ast_ensure { #[macro_export] 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),* $(,)? }) => {{ let mut analyzer = $crate::error::AstErrorAnalyzer(None); diff --git a/parser/src/parser/common/expr.rs b/parser/src/parser/common/expr.rs index 10fb2b2..7de634e 100644 --- a/parser/src/parser/common/expr.rs +++ b/parser/src/parser/common/expr.rs @@ -101,7 +101,7 @@ impl<'a> TryFrom> for Expression { postfixes: postfixes, }) } else { - exp + ast_expr!(use exp?, prefixes, postfixes) } }