[antlr-interest] Using token values in other java classes (newbie)
Bryan Ewbank
ewbank at gmail.com
Wed Jan 19 14:04:04 PST 2005
Isn't this better written to simply use the normal returned state
information? For example:
myrule:
status_type { myJavaObject.setStatus(#status_type.getType()); }
;
status_type:
LIVE_KW | SECONDARY_KW | DISCONTINUED_KW | NEWENTRY_KW
;
> Thanks to Nigel and Paul for the prompt and useful answers. Now it
> works. To summarize the correct solution:
>
> myrule {int tt;}: tt=status_type { myJavaObject.setStatus(tt); }
> ;
>
> status_type returns [ int x = LIVE_KW /* the default */ ]
> {
> x = LA(1);
> }:
> ( LIVE_KW | SECONDARY_KW | DISCONTINUED_KW | NEWENTRY_KW )
> ;
More information about the antlr-interest
mailing list