[antlr-interest] Selection between lexer rule and literal
togol machillan
togolmach2 at lycos.com
Tue Apr 19 03:54:31 PDT 2005
Hello,
I have a rule in the lexer which looks like the following.
VALUE options {testLiterals = true; }
:CAPITAL_LETTER (CAPITAL_LETTER|DIGIT|','|':'|'+'|'-')*
;
In the parser, I have defined a list of literals like the following example rule
p_keyword_list returns [ANTLR_USE_NAMESPACE(std)string k]
:
(
{k = LT(1)->getText(); col = LT(1)->getColumn();} "COMPONENTS"
|{k = LT(1)->getText(); col = LT(1)->getColumn();} "DATABANKS"
|{k = LT(1)->getText(); col = LT(1)->getColumn();} "PROP-SOURCES"
)
;
Now when some parser rule is looking for a VALUE token and it sees, for example, COMPONENTS, it returns an unexpected token error. It there some way of making the parser intelligent enough so that it considers COMPONENTS (defined as a literal) as a token of type VALUE.
Best regards,
T. Mach
--
_______________________________________________
NEW! Lycos Dating Search. The only place to search multiple dating sites at once.
http://datingsearch.lycos.com
More information about the antlr-interest
mailing list