Refactor parser to use ParserContext