Do not call recognizers if past the end of the input.
@@ -501,12 +501,14 @@ class Parser(object):
Just check with all recognizers available.
"""
tokens = []
+ if context.position < len(context.input_str):
for terminal in self.grammar.terminals.values():
if terminal.recognizer._pg_context:
tok = terminal.recognizer(context, context.input_str,
context.position)
else:
- tok = terminal.recognizer(context.input_str, context.position)
+ tok = terminal.recognizer(context.input_str,
+ context.position)
if tok is not None:
tokens.append(Token(terminal, tok))
return tokens
