Skip to content

Commit

Permalink
feat: allow inlined rules to be empty
Browse files Browse the repository at this point in the history
  • Loading branch information
rooney committed Mar 31, 2024
1 parent 0b44032 commit 964214f
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion cli/src/generate/prepare_grammar/flatten_grammar.rs
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,13 @@ pub(super) fn flatten_grammar(grammar: ExtractedSyntaxGrammar) -> Result<SyntaxG
}
for (i, variable) in variables.iter().enumerate() {
for production in &variable.productions {
if production.steps.is_empty() && symbol_is_used(&variables, Symbol::non_terminal(i)) {
if production.steps.is_empty()
&& symbol_is_used(&variables, Symbol::non_terminal(i))
&& !grammar
.variables_to_inline
.iter()
.any(|symbol| symbol.index == i)
{
return Err(anyhow!(
"The rule `{}` matches the empty string.
Expand Down

0 comments on commit 964214f

Please sign in to comment.