The only way to guarantee that ANTLR uses particular constants for particular tokens is to write your own .tokens
file (you'll see them produced ANTLR when you compile grammars). You can then use the tokenVocab
option to specify the name of your custom tokens file.
That said, the ordering of tokens has never proven to be a significant performance issue in my experience. The C# port of ANTLR 3 approaches the performance issue by eliminating redundant range checks that appear on some code paths.