Browse Source

Fix Earley non-determinism

Rule.order should be set as the index of each expansion with rules
of the same name (e.g: a : b    # rule.order 1 | c    # rule.order 2).
tags/gm/2021-09-23T00Z/github.com--lark-parser-lark/0.7.4
night199uk 5 years ago
committed by Erez Sh
parent
commit
dc94ebc42f
1 changed files with 2 additions and 2 deletions
  1. +2
    -2
      lark/load_grammar.py

+ 2
- 2
lark/load_grammar.py View File

@@ -511,12 +511,12 @@ class Grammar:

simplify_rule = SimplifyRule_Visitor()
compiled_rules = []
for i, rule_content in enumerate(rules):
for rule_content in rules:
name, tree, options = rule_content
simplify_rule.visit(tree)
expansions = rule_tree_to_text.transform(tree)

for expansion, alias in expansions:
for i, (expansion, alias) in enumerate(expansions):
if alias and name.startswith('_'):
raise GrammarError("Rule %s is marked for expansion (it starts with an underscore) and isn't allowed to have aliases (alias=%s)" % (name, alias))



Loading…
Cancel
Save