Skip to content

Commit

Permalink
Unbreak empty productions and actions.
Browse files Browse the repository at this point in the history
This is a classic copy and paste mistake on my part: I didn't think
carefully enough about the `syms.is_empty()` clause.

Problem reported by Bachir Bendrissou in
softdevteam#463.
  • Loading branch information
ltratt committed Jun 13, 2024
1 parent e30e481 commit e077e02
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 e077e02

Please sign in to comment.