Mercurial > lbo > hg > pcombinators
changeset 41:23a3dfc26014 draft
Fix index overflow in ParseState
author | Lewin Bormann <lbo@spheniscida.de> |
---|---|
date | Thu, 23 May 2019 19:58:43 +0200 |
parents | e9cb1d6b12d3 |
children | 24d3a2ae7031 |
files | pcombinators/state.py |
diffstat | 1 files changed, 4 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/pcombinators/state.py Thu May 23 19:54:54 2019 +0200 +++ b/pcombinators/state.py Thu May 23 19:58:43 2019 +0200 @@ -181,6 +181,8 @@ return 'ParseState({}<>)'.format(self._input) def next(self): + if self.finished(): + return None current = self.peek() self._index += 1 return current @@ -189,6 +191,8 @@ self._index += n def peek(self): + if self.finished(): + return None return self._input[self._index] def index(self):