heavily refactored parser and abstract syntax by using a state monad inside the parser