[antlr-interest] Newbie: rule equivalent of a token reference?

JConner at ssp-uk.com JConner at ssp-uk.com
Tue Jul 19 06:25:50 PDT 2005


Dear all,

Sorry if this isn't the right place to ask this, and I know that I might be
trying to run before I can walk, but...

I'm trying to play around and create a simple translator.  Getting the
"text" of a token seems straight forwards - you label the token reference,
and call xzy.getText() in an action.  However, what do I do if I wrap the
token reference up in another parser rule?  Eg, in:

variable_declaration : constant type ( COMMA constant type )* ;
constant : INDENTIFIER ;
type : .....

Given that COMMA and IDENTIFIER are lexer rules, how would I get the "text"
from the rule constant into an action in the rule variable_declaration?  Am
I missing something obvious, or am I trying to go about this in the wrong
way?

John



More information about the antlr-interest mailing list