[antlr-interest] How to intervene automatic keywords generation
Fan Yang
yhhf_dy at yahoo.com
Wed Oct 16 14:16:57 PDT 2002
Hi,
According to the manual of ANTLR about Keywords and literals: any
double-quoted string used in a parser is automatically entered into
the literals table of the associated lexer. For instance,
on_error_stmt
: "on" "error" "goto" label)
;
So "on", "error" and "goto" will be automatically putted into the
literals table. But in my target language "error" is not a keyword.
so "error" can be an "identifier" in a statement as following pseudo
code line shows.
printf("%s", e.error)
In fact, this line will cause a problem. because the parser will look
for the identifier -"error" in the literals table first, then
treat "error" as keyword not an general identifier.
IDENT
options {testLiterals=true;}
: ('a'..'z'|'_') ('a'..'z'|'_'|'0'..'9')*
;
My question is that may I determine which one ,double-quoted strings,
can be entered into literals table instead of automatically
generatation. Or there is an alternative way to deal with this kind
of problem
Thanks,
Fan
Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
More information about the antlr-interest
mailing list