[antlr-interest] XPath - identifiers are keywords
John Merrells
merrells at sleepycat.com
Tue Jul 2 15:29:08 PDT 2002
This is probably simple, but I've failed to find an explicit answer
in the documentation or the FAQ. I have a language (XPath) and
it has some keywords that can also be identifiers. How do I set
up my lexer rules for this? The identifier is called NCNAME and
is defined thus:
k=2;
NCNAME
: (LETTER|'_') (NCNAMECHAR)*
;
protected
NCNAMECHAR: LETTER|'0'..'9'|'.'|'-'|'_';
protected
LETTER: ('a'..'z'|'A'..'Z');
The keyword is 'comment', and when it's a keyword it is always
followed by '(' ')'. So I tried just adding...
COMMENT: "comment()";
But that's ambiguous, so I tried adding a lexer rule to disambiguate
between them, but I either got that wrong, or it didn't work. Should
I increase k to be length("comment()")? That seems like overkill.
I'm sure there's something obvious that I'm missing here...
John
Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
More information about the antlr-interest
mailing list