Improved deterministic code generation output

This change improves upon some of the work in #724.

The most obvious improvements here are:

* For separate lexer and parser grammars, the order in which tokens were written to the **.tokens** file while generating the lexer affected the order in which the token constants appeared in the final generated parser.
* Generated accessor methods in parse tree context classes is now deterministic.