diff options
author | ptmcg <ptmcg@austin.rr.com> | 2022-11-10 17:18:26 -0600 |
---|---|---|
committer | ptmcg <ptmcg@austin.rr.com> | 2022-11-10 17:18:26 -0600 |
commit | 1bf5807fe4d03d9fa2bfded0861533745ea30ca4 (patch) | |
tree | 173808fabd2532e34dd667e9d5f80ebcfc222eab /pyparsing | |
parent | e6c7783b2e129e29165da2882803581e6316d3b2 (diff) | |
download | pyparsing-git-1bf5807fe4d03d9fa2bfded0861533745ea30ca4.tar.gz |
Additional measures to prevent premature streamlining (Issue #447)
Diffstat (limited to 'pyparsing')
-rw-r--r-- | pyparsing/core.py | 7 | ||||
-rw-r--r-- | pyparsing/helpers.py | 4 |
2 files changed, 6 insertions, 5 deletions
diff --git a/pyparsing/core.py b/pyparsing/core.py index 1a92ca5..320d882 100644 --- a/pyparsing/core.py +++ b/pyparsing/core.py @@ -1892,7 +1892,7 @@ class ParserElement(ABC): self._defaultName = None return self - def recurse(self) -> Sequence["ParserElement"]: + def recurse(self) -> List["ParserElement"]: return [] def _checkRecursion(self, parseElementList): @@ -3726,7 +3726,7 @@ class ParseExpression(ParserElement): self.exprs = [exprs] self.callPreparse = False - def recurse(self) -> Sequence[ParserElement]: + def recurse(self) -> List[ParserElement]: return self.exprs[:] def append(self, other) -> ParserElement: @@ -4503,7 +4503,7 @@ class ParseElementEnhance(ParserElement): self.callPreparse = expr.callPreparse self.ignoreExprs.extend(expr.ignoreExprs) - def recurse(self) -> Sequence[ParserElement]: + def recurse(self) -> List[ParserElement]: return [self.expr] if self.expr is not None else [] def parseImpl(self, instring, loc, doActions=True): @@ -5313,6 +5313,7 @@ class Forward(ParseElementEnhance): return NotImplemented self.expr = other + self.streamlined = other.streamlined self.mayIndexError = self.expr.mayIndexError self.mayReturnEmpty = self.expr.mayReturnEmpty self.set_whitespace_chars( diff --git a/pyparsing/helpers.py b/pyparsing/helpers.py index c4ac2a9..4b2655f 100644 --- a/pyparsing/helpers.py +++ b/pyparsing/helpers.py @@ -58,9 +58,9 @@ def delimited_list( while to_visit and num_exprs < MAX_EXPRS: parent, cur = to_visit.pop() num_exprs += 1 - if cur in seen: + if id(cur) in seen: continue - seen.add(cur) + seen.add(id(cur)) cur = cur.copy() if parent is None: cpy = cur |