[antlr-interest] nondeterminism in lexer rule
Xue Yong Zhi
zhixueyong at hotmail.com
Fri Mar 2 08:25:14 PST 2007
Please check java.g to see how it handle keywords. In general you should
create lexer rule for each kewyrod., just refer them in your parser
grammar:
YourParser extends Parser;
...
ifExpression
: "if" expression "then" expression "else" expression
;
...
YourLexer extends Lexer;
...
//remove those IF, THEN etc
...
>
> IF : "if" ;
>
> THEN : "then" ;
>
> ELSE : "else" ;
>
> GOTO : "goto" ;
>
> DOT : '.' ;
>
> protected
>
> LITERAL
>
> : (('a'..'z') ('a'..'z'|'0'..'9'| '_' | '@' | '$')*)
>
> ;
--
Xue Yong Zhi
XRuby (Ruby to Java bytecode compiler):
http://xruby.blogspot.com
More information about the antlr-interest
mailing list