summaryrefslogtreecommitdiff
path: root/pyparsing
diff options
context:
space:
mode:
authorptmcg <ptmcg@austin.rr.com>2023-03-26 02:12:17 -0500
committerptmcg <ptmcg@austin.rr.com>2023-03-26 02:12:17 -0500
commit9d789cbc7331509862060c8b06ebca9fe9d827b2 (patch)
treea4633437ce0a7e0baf784a6c4fa362e6eb748bfb /pyparsing
parent2e98055c8dab3e00fd20f39cd815b7e2773886e7 (diff)
downloadpyparsing-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 'pyparsing')
-rw-r--r--pyparsing/core.py17
1 files changed, 6 insertions, 11 deletions
diff --git a/pyparsing/core.py b/pyparsing/core.py
index 02ae50a..b51779f 100644
--- a/pyparsing/core.py
+++ b/pyparsing/core.py
@@ -5281,7 +5281,8 @@ class SkipTo(ParseElementEnhance):
):
super().__init__(other)
failOn = failOn or fail_on
- self.ignoreExpr = ignore
+ if ignore is not None:
+ self.ignore(ignore)
self.mayReturnEmpty = True
self.mayIndexError = False
self.includeMatch = include
@@ -5299,9 +5300,7 @@ class SkipTo(ParseElementEnhance):
self_failOn_canParseNext = (
self.failOn.canParseNext if self.failOn is not None else None
)
- self_ignoreExpr_tryParse = (
- self.ignoreExpr.try_parse if self.ignoreExpr is not None else None
- )
+ self_preParse = self.preParse if self.callPreparse else None
tmploc = loc
while tmploc <= instrlen:
@@ -5310,13 +5309,9 @@ class SkipTo(ParseElementEnhance):
if self_failOn_canParseNext(instring, tmploc):
break
- if self_ignoreExpr_tryParse is not None:
- # advance past ignore expressions
- while 1:
- try:
- tmploc = self_ignoreExpr_tryParse(instring, tmploc)
- except ParseBaseException:
- break
+ if self_preParse is not None:
+ # skip grammar-ignored expressions
+ tmploc = self_preParse(instring, tmploc)
try:
self_expr_parse(instring, tmploc, doActions=False, callPreParse=False)