Browse Source

BUGFIX: Repeated use of optional rules tripped up the simplifier, manifesting when aliases were used (Issue #197)

tags/gm/2021-09-23T00Z/github.com--lark-parser-lark/0.6.3
Erez Shinan 6 years ago
parent
commit
32b78b8ee5
2 changed files with 4 additions and 0 deletions
  1. +1
    -0
      lark/load_grammar.py
  2. +3
    -0
      tests/test_parser.py

+ 1
- 0
lark/load_grammar.py View File

@@ -235,6 +235,7 @@ class SimplifyRule_Visitor(Visitor):
tree.children = [self.visit(ST('expansion', [option if i==j else other
for j, other in enumerate(tree.children)]))
for option in set(child.children)]
self._flatten(tree)
break

def alias(self, tree):


+ 3
- 0
tests/test_parser.py View File

@@ -148,6 +148,9 @@ class TestParsers(unittest.TestCase):
self.assertEqual( r.children, ["<c>"] )


def test_alias(self):
Lark("""start: ["a"] "b" ["c"] "e" ["f"] ["g"] ["h"] "x" -> d """)



def _make_full_earley_test(LEXER):


Loading…
Cancel
Save