Skip to content

Commit

Permalink
Merge pull request #464 from ltratt/fix_empty_productions_and_action_…
Browse files Browse the repository at this point in the history
…parsing

Unbreak empty productions and actions.
  • Loading branch information
ptersilie authored Jun 13, 2024
2 parents e30e481 + 2b1a4e8 commit 8896c85
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions cfgrammar/src/lib/yacc/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -2629,5 +2627,12 @@ B";
3,
17,
);

let src = "
%%
A: B B {};
B: {} ;
";
parse(YaccKind::Original(YaccOriginalActionKind::NoAction), src).unwrap();
}
}

0 comments on commit 8896c85

Please sign in to comment.