Fixed failing tests.
Moved the AST handling code into the GrammarParser class.