Improve isEndOfParserInput
Performance improvements and correct end-of-input handling in parse/parseL