[antlr-interest] Custom token set up from lexer rules

Johannes Luber jaluber at gmx.de
Thu Feb 21 15:20:25 PST 2008


Bertalan Fodor schrieb:
> Hello,
> 
> I would like to set up my custom token object from the lexer rules. 
> Until now I only found one solution: set some member field in the lexer 
> actions, then use that field in the overridden emit method. Isn't there 
> a more elegant way for this?

Use

options {TokenLabelType=MyToken;}

instead. MyToken is a class probably derived from CommonToken.

Johannes


More information about the antlr-interest mailing list