[antlr-interest] how to distinguish a keyword (e.g. "stale") from other string literal

Ning Ji ning883 at gmail.com
Tue Sep 26 07:05:46 PDT 2006


hi my old code has this line

IDNET: ('a'..'z')*

now i want to add a keyword "stale",
STALE: "stale"

so my expected code is

switch (LA(1))  {
    case STALE:
    {
        keyword = ....;
        break;
    }
    case IDENT:
    {
        do sth. else
        break;
    }
    ....
}

-------------------------------------------------------------
now STALE conflicts with IDENT, antlr issues a warning as STALE is a special
case of IDENT,
how should i rewrite this ?

Thanks very much !
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/antlr-interest/attachments/20060926/f8065a93/attachment.html 


More information about the antlr-interest mailing list