[antlr-interest] adding enum token types output for java target

Terence Parr parrt at cs.usfca.edu
Mon May 26 11:55:39 PDT 2008


On May 26, 2008, at 10:59 AM, Johannes Luber wrote:

>> Howdy folks,
>>
>> The C target gets a .h file as output to define tokens etc...  Brian
>> Goetz, Sun smarty pants, asked me about generating an enum from ANTLR
>> to make it easier for IDEs and other tools to use reflection to get
>> token types and other goodies.  It took me 2 minutes and a few
>> template lines to make this happen (i.e., no code generator changes).
>
> You mean an enum for UP, DOWN, EOF, etc.? Why isn't there one  
> already used in Java instead the int array? Why is the current  
> solution not sufficient?

It's for all of the generated tokens not be predefined ones, although  
I should add those as well.  Tools that use antlr-generated  
recognizers need to know what the list of tokens is in token types so  
that it can do highlighting, error recovery, auto completion, all  
sorts of things.

Ter


More information about the antlr-interest mailing list