mirror of https://github.com/lark-parser/lark.git
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).
This commit is contained in:
parent
d845aa3bf1
commit
dc94ebc42f
|
@ -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…
Reference in New Issue