Encapsulate the parser state and make it stateful