diff options
author | ptmcg <ptmcg@austin.rr.com> | 2023-03-26 02:12:17 -0500 |
---|---|---|
committer | ptmcg <ptmcg@austin.rr.com> | 2023-03-26 02:12:17 -0500 |
commit | 9d789cbc7331509862060c8b06ebca9fe9d827b2 (patch) | |
tree | a4633437ce0a7e0baf784a6c4fa362e6eb748bfb /tests | |
parent | 2e98055c8dab3e00fd20f39cd815b7e2773886e7 (diff) | |
download | pyparsing-git-9d789cbc7331509862060c8b06ebca9fe9d827b2.tar.gz |
Fix #475 - SkipTo used incorrect storage of ignore expressions, would match the target expression if present within an ignorable
Diffstat (limited to 'tests')
-rw-r--r-- | tests/test_unit.py | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/tests/test_unit.py b/tests/test_unit.py index c2a7160..0f1cb5a 100644 --- a/tests/test_unit.py +++ b/tests/test_unit.py @@ -1692,6 +1692,23 @@ class Test02_WithoutPackrat(ppt.TestParseResultsAsserts, TestCase): {"_skipped": ["red ", "456 "]}, ) + def testSkipToPreParseIgnoreExprs(self): + # added to verify fix to Issue #475 + from pyparsing import Word, alphanums, python_style_comment + + some_grammar = Word(alphanums) + ":=" + ... + ';' + some_grammar.ignore(python_style_comment) + try: + result = some_grammar.parse_string("""\ + var1 := 2 # 3; <== this semi-colon will match! + + 1; + """, parse_all=True) + except ParseException as pe: + print(pe.explain()) + raise + else: + print(result.dump()) + def testEllipsisRepetition(self): word = pp.Word(pp.alphas).setName("word") |