Skip to content

Commit

Permalink
Add tests for issue lark-parser#1283
Browse files Browse the repository at this point in the history
  • Loading branch information
chanicpanic committed Aug 1, 2023
1 parent 656334c commit 1b6c1dd
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions tests/test_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -916,7 +916,26 @@ def test_cycles_with_child_filter(self):
tree = l.parse('');
self.assertEqual(tree, Tree('a', [Tree('x', [Tree('b', [])])]))

def test_resolve_ambiguity_with_shared_node(self):
grammar = """
start: (a+)*
!a.1: "A" |
"""

l = Lark(grammar, ambiguity='resolve', lexer=LEXER)
tree = l.parse("A")
self.assertEqual(tree, Tree('start', [Tree('a', []), Tree('a', []), Tree('a', ['A'])]))

def test_resolve_ambiguity_with_shared_node2(self):
grammar = """
start: _s x _s
x: "X"?
_s: " "?
"""

l = Lark(grammar, ambiguity='resolve', lexer=LEXER)
tree = l.parse("")
self.assertEqual(tree, Tree('start', [Tree('x', [])]))



Expand Down

0 comments on commit 1b6c1dd

Please sign in to comment.