[antlr-interest] Using token values in other java classes (newbie)
Paul J. Lucas
pauljlucas at mac.com
Tue Jan 18 14:19:17 PST 2005
On Tue, 18 Jan 2005, Peter Robinson wrote:
> status_type returns [ int x ]: ( LIVE_KW { x = LIVE_KW; } |
> SECONDARY_KW { x = SECONDARY_KW; } |
> DISCONTINUED_KW { x = DISCONTINUED_KW; }|
> NEWENTRY_KW { x = NEWENTRY_KW; } )
> ;
That's much easier to do if you simply do:
status_type returns [ int x ]
{
x = LA(1);
}
: LIVE_KW | SECONDARY_KW | ...
;
> ==>> However, I keep getting error messages when transforming the .g
> file that "s" cannot be identified. What am I doing wrong?
You can just do getText() without the 's' also I believe.
> 2) The grammar file generates a java interface with int constants for
> tokens. Assuming I have some java class files in subdirectories and want
> them to know about these constants, how does one do that (just class foo
> implements bar doesnt work).
Uhm.... it should work.
- Paul
More information about the antlr-interest
mailing list