From 2b1a4e856967a0d69d355a386c2f817abb6812f9 Mon Sep 17 00:00:00 2001 From: Laurence Tratt Date: Thu, 13 Jun 2024 15:42:57 +0100 Subject: [PATCH] Unbreak empty productions and actions. This is a classic copy and paste mistake on my part: I didn't think carefully enough about the `syms.is_empty()` clause. Fixes https://github.com/softdevteam/grmtools/issues/463. --- cfgrammar/src/lib/yacc/parser.rs | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/cfgrammar/src/lib/yacc/parser.rs b/cfgrammar/src/lib/yacc/parser.rs index d0f8e5aea..22a1a1835 100644 --- a/cfgrammar/src/lib/yacc/parser.rs +++ b/cfgrammar/src/lib/yacc/parser.rs @@ -691,9 +691,7 @@ impl YaccParser { i = self.parse_ws(j, true)?; action = Some(a); - if syms.is_empty() - || !(self.lookahead_is("|", i).is_some() || self.lookahead_is(";", i).is_some()) - { + if !(self.lookahead_is("|", i).is_some() || self.lookahead_is(";", i).is_some()) { return Err(self.mk_error(YaccGrammarErrorKind::ProductionNotTerminated, i)); } } else if let Some(mut j) = self.lookahead_is("%empty", i) { @@ -2629,5 +2627,12 @@ B"; 3, 17, ); + + let src = " + %% + A: B B {}; + B: {} ; + "; + parse(YaccKind::Original(YaccOriginalActionKind::NoAction), src).unwrap(); } }