[antlr-interest] How can I use my grammar's tokens without them being considered tokens?
Avid Trober
avidtrober at gmail.com
Fri Aug 20 19:05:50 PDT 2010
For example, "SERVICE" is a keyword in my grammar:
tokens
{
SERVICE = 'SERVICE';
OTHER_KEYWORD = 'OTHER_KEYWORD'
.
}
Therefore, I can't use SERVICE as a value to OTHER_KEYWORD, like this:
OTHER_KEYWORD=SERVICE
Based on this grammar rule:
keywordValuePair
: keyword=identifier EQUAL
keywordValue=identifier
-> ^(KEYWORD_VALUE_PAIR $keyword
$keywordValue)
In fact, I can't use *any* token in my grammar on the right side of the
equal sign above.
There are times when I want SERVICE, or any value in tokens {.}, to be
considered an IDENTIFIER, not a token:
identifier
: IDENTIFIER;
.
IDENTIFIER : ( 'A' .. 'Z' | 'a'..'z' | '_') ( 'A' .. 'Z' | 'a'..'z' | '0' ..
'9' | '_' | '.' )* ;
More information about the antlr-interest
mailing list