Skip to content

Commit

Permalink
Add failing test for issue #27.
Browse files Browse the repository at this point in the history
  • Loading branch information
manueljacob committed Jun 11, 2017
1 parent 192c6e8 commit 825ffde
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions test/grammar/left_recursion_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -215,3 +215,18 @@ def test_left_recursion_with_right_associativity(self, trace=False):
model = compile(grammar, "test")
ast = model.parse("1+2+3", trace=trace, colorize=True)
self.assertEqual(['1', '+', ['2', '+', '3']], ast)

def test_dropped_input_bug(self, trace=False):
grammar = '''
@@left_recursion :: True
identifier = /\w+/ ;
expr = expr ',' expr | identifier ;
'''
model = compile(grammar)

ast = model.parse('foo', 'expr', trace=trace, colorize=True)
self.assertEqual(ast, 'foo')
ast = model.parse('foo, bar', 'expr', trace=trace, colorize=True)
self.assertEqual(ast, ['foo', ',', 'bar'])
ast = model.parse('foo bar', 'expr', trace=trace, colorize=True)
self.assertEqual(ast, 'foo')

0 comments on commit 825ffde

Please sign in to comment.