Skip to content

Commit

Permalink
Tests: Fixed test_cycle2 to accept the ambiguity it contains
Browse files Browse the repository at this point in the history
  • Loading branch information
erezsh committed Jun 18, 2024
1 parent 928fc26 commit 55b3c50
Showing 1 changed file with 14 additions and 6 deletions.
20 changes: 14 additions & 6 deletions tests/test_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -859,16 +859,24 @@ def test_cycle(self):

def test_cycle2(self):
grammar = """
start: _operation
_operation: value
value: "b"
| "a" value
| _operation
start: _recurse
_recurse: v
v: "b"
| "a" v
| _recurse
"""

l = Lark(grammar, ambiguity="explicit", lexer=LEXER)
tree = l.parse("ab")
self.assertEqual(tree, Tree('start', [Tree('value', [Tree('value', [])])]))
expected = (
Tree('start', [
Tree('_ambig', [
Tree('v', [Tree('v', [])]),
Tree('v', [Tree('v', [Tree('v', [])])])
])
])
)
self.assertEqual(tree, expected)

def test_cycles(self):
grammar = """
Expand Down

0 comments on commit 55b3c50

Please sign in to comment.