Mercurial > lbo > hg > pcombinators
changeset 71:ae904cd0859e draft
Fix bad Hold handling in combinators module
author | Lewin Bormann <lbo@spheniscida.de> |
---|---|
date | Sat, 25 May 2019 23:11:45 +0200 |
parents | 3d93b1ac9c29 |
children | 72fb4eb79973 |
files | pcombinators/combinators.py |
diffstat | 1 files changed, 3 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/pcombinators/combinators.py Sat May 25 22:12:55 2019 +0200 +++ b/pcombinators/combinators.py Sat May 25 23:11:45 2019 +0200 @@ -100,9 +100,9 @@ def parse(self, st): results = [] - hold = st.hold() if self._atomic else None if st.finished(): return None, st + hold = st.hold() if self._atomic else None for p in self._parsers: result, st2 = p.parse(st) if result is None: @@ -150,13 +150,13 @@ self._times = repeat def parse(self, st): + if st.finished(): + return None, st results = [] # We only need to remember where we started in case we need to actually # come back here, i.e. if this is a strict repeat. hold = st.hold() if self._strict else None i = 0 - if st.finished(): - return None, st while i < self._times or self._times < 0: r, st2 = self._parser.parse(st) if r == None: