Browse Source

BUGFIX: Repeating subrules are now allowed (Issue #61)

tags/gm/2021-09-23T00Z/github.com--lark-parser-lark/0.5.3
Erez Shinan 7 years ago
parent
commit
b002ec47fb
1 changed files with 4 additions and 2 deletions
  1. +4
    -2
      lark/load_grammar.py

+ 4
- 2
lark/load_grammar.py View File

@@ -176,7 +176,6 @@ class SimplifyRule_Visitor(Visitor):
break break
tree.expand_kids_by_index(*to_expand) tree.expand_kids_by_index(*to_expand)



def expansion(self, tree): def expansion(self, tree):
# rules_list unpacking # rules_list unpacking
# a : b (c|d) e # a : b (c|d) e
@@ -210,7 +209,10 @@ class SimplifyRule_Visitor(Visitor):
tree.data = 'expansions' tree.data = 'expansions'
tree.children = aliases tree.children = aliases


expansions = _flatten
def expansions(self, tree):
self._flatten(tree)
tree.children = list(set(tree.children))



class RuleTreeToText(Transformer): class RuleTreeToText(Transformer):
def expansions(self, x): def expansions(self, x):


Loading…
Cancel
Save