diff options
author | ptmcg <ptmcg@austin.rr.com> | 2021-10-27 12:57:15 -0500 |
---|---|---|
committer | ptmcg <ptmcg@austin.rr.com> | 2021-10-27 12:57:15 -0500 |
commit | 1bbc83267f33471f25b885c5376b65316a6d1968 (patch) | |
tree | f145c9e8932fc66f51b7f7c6989a527601b52a8a /pyparsing/core.py | |
parent | 46f4af6fee9b4dc6b7c10f27ed9a755a45082377 (diff) | |
download | pyparsing-git-1bbc83267f33471f25b885c5376b65316a6d1968.tar.gz |
Fix whitespace skipping bug introduced while reverting LineStart() changes - Issue #319
Diffstat (limited to 'pyparsing/core.py')
-rw-r--r-- | pyparsing/core.py | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/pyparsing/core.py b/pyparsing/core.py index 0e91666..ab178f3 100644 --- a/pyparsing/core.py +++ b/pyparsing/core.py @@ -3853,7 +3853,9 @@ class Or(ParseExpression): def streamline(self): super().streamline() if self.exprs: + self.mayReturnEmpty = any(e.mayReturnEmpty for e in self.exprs) self.saveAsList = any(e.saveAsList for e in self.exprs) + self.skipWhitespace = all(e.skipWhitespace for e in self.exprs) else: self.saveAsList = False return self @@ -3967,7 +3969,7 @@ class Or(ParseExpression): class MatchFirst(ParseExpression): """Requires that at least one :class:`ParseExpression` is found. If - two expressions match, the first one listed is the one that will + more than one expression matches, the first one listed is the one that will match. May be constructed using the ``'|'`` operator. Example:: @@ -3987,7 +3989,6 @@ class MatchFirst(ParseExpression): super().__init__(exprs, savelist) if self.exprs: self.mayReturnEmpty = any(e.mayReturnEmpty for e in self.exprs) - self.callPreparse = all(e.callPreparse for e in self.exprs) self.skipWhitespace = all(e.skipWhitespace for e in self.exprs) else: self.mayReturnEmpty = True @@ -4000,7 +4001,7 @@ class MatchFirst(ParseExpression): if self.exprs: self.saveAsList = any(e.saveAsList for e in self.exprs) self.mayReturnEmpty = any(e.mayReturnEmpty for e in self.exprs) - self.callPreparse = all(e.callPreparse for e in self.exprs) + self.skipWhitespace = all(e.skipWhitespace for e in self.exprs) else: self.saveAsList = False self.mayReturnEmpty = True @@ -4013,7 +4014,7 @@ class MatchFirst(ParseExpression): for e in self.exprs: try: return e._parse( - instring, loc, doActions, callPreParse=not self.callPreparse + instring, loc, doActions, ) except ParseFatalException as pfe: pfe.__traceback__ = None |