Re-ordered the function definitions in the parser to better reflect the structure of the grammar.