[antlr-interest] Lexer Keywords and Identifiers (was re: Newbie NonDeterminism Error)
Bryan Ewbank
ewbank at synopsys.com
Mon Oct 4 06:47:44 PDT 2004
> LOAD: "load";
> LOADI: "loadi";
>
> I've tried fiddling with the code, and reading FAQs and message
> boards, but I can't get rid of the error. How would I write it so
> there's no nondeterminism?
Easiest to use literals - define a general rule for IDENTIFIER, then
use keyword lookup to intercept and change token values. Search
for "testLiterals" and "token" in the documentation.
A skeleton looks something like this:
class MyLex extends Lexer;
options { testLiterals = false; }
tokens {
LOAD = "load";
LOADI = "loadi";
}
IDENTIFIER
options { testLiterals = true; }
: ( ALPHA ) ( ALNUM )* ;
Yahoo! Groups Links
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/antlr-interest/
<*> To unsubscribe from this group, send an email to:
antlr-interest-unsubscribe at yahoogroups.com
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/
More information about the antlr-interest
mailing list