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

Micheal J open.zone at virgin.net
Wed May 28 07:17:11 PDT 2008


Hi,

> The trouble with enums is that they're not extensible; you 
> can't inherit from one and simply add a few extra values 
> (which would be useful for adding imaginary tokens at the 
> parser/treeparser level).  And since they can't be a base 
> class the library code will still have to work with raw ints, 
> which means a lot more casts will be required to type-juggle. 
>  It gets messy very quickly.

Precisely. The C# target had enums in early v2.7.x releases.

We removed them to ease the task of maintaining C# and Java recognizers
simultaneously for v2 but, also because it reduce the need to typecast.

We originally planned to generate both the int constants and an emun type in
the v3 target...

Micheal

-----------------------
The best way to contact me is via the list/forum. My time is very limited. 



More information about the antlr-interest mailing list