Deterministic output improvements

Make the following items deterministic:

* Assignment of names and types to string literals in parser rules (order of first appearance in the grammar)
* Order of methods in listener and visitor interfaces and classes (grammar order)
* Result of topological sort using the `Graph<T>` class

Fixes #709