Skip to content

Commit

Permalink
[test] Add test demonstrating expected white space skipping behavior (#…
Browse files Browse the repository at this point in the history
…306)

See issue #305.
  • Loading branch information
dnicolodi authored Aug 29, 2023
1 parent 186550c commit 8320adb
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions test/parsing_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,19 @@ def test_startrule_issue62(self):
model = tatsu.compile(grammar=grammar)
model.parse('4 + 5')

def test_skip_whitespace(self):
grammar = '''
statement = 'FOO' subject $ ;
subject = name:id ;
id = /[a-z]+/ ;
'''
model = tatsu.compile(grammar=grammar)
ast = model.parse('FOO bar', parseinfo=True)
subject = ast[1]
assert subject['name'] == 'bar'
parseinfo = subject['parseinfo']
assert parseinfo.pos == parseinfo.tokenizer.text.index('bar')


def suite():
return unittest.TestLoader().loadTestsFromTestCase(ParsingTests)
Expand Down

0 comments on commit 8320adb

Please sign in to comment.