[antlr-interest] literal token names in AntLR3

Putrycz, Erik Erik.Putrycz at nrc-cnrc.gc.ca
Tue Sep 18 12:39:35 PDT 2007


In Antlr 2.x, the literal tokens got friendly field names for their type
number. 

E.g. 'ADD' would become LITERAL_ADD but in ANTLR 3, all the literals
become Txxx in the lexer. 

When working with trees, it was much easier in the past to write
something like

Switch (node.getType()) {

            Case MyTokenTypes.LITERAL_ADD:...

}

Whereas now you need to get back to MyParser.tokenNames to find the
corresponding one.

Is there any way to control the naming of the literals and get something
more friendly than the Txxx?

 

Erik Putrycz, Ph.D - Research Associate

Institute for Information Technology - Software Engineering Group

National Research Council, Canada - Building M-50, 1200 Montreal Road

Ottawa, Ontario, CANADA K1A 0R6

 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/antlr-interest/attachments/20070918/2abbe4b1/attachment.html 


More information about the antlr-interest mailing list