[antlr-interest] Lexer nondeterminism

Laurent Debacker debackerl at gmail.com
Mon Jan 23 03:36:48 PST 2006


Hi,

There is something I do not understand:

I have the following operators:
AND		: ("and" | "&&") ;
OR		: ("or" | "||") ;
EQ		: '=' | "==" ;
LT		: '<' ;
LTE		: ("<=" | "=<") ;
GT		: '>' ;
GTE		: (">=" | "=>") ;
NEQ		: ("!=" | "<>") ;
NOT		: '!' ;
IMPLIES		: "->" ;
ASSIGN		: ":=" ;

ANTLR says there are lexical nondeterminisms with (EQ,LTE), (EQ, GTE),
(LTE, GTE) and (LTE, NEQ). k is 2.

But why doesn't he complains about LT and NEQ?

Also in the C# grammar I found and which is compiling fine I found:

SL: "<<";
LTHAN: "<";

Why is ANTLR happy with that? Well maybe because ANTLR is greedy, but
then my =< should also be matched even with the = rule.

Also, is there any good page that explains what testLiterals is? I
looked around, but it was really vague.

Thanks for your help!
Laurent.


More information about the antlr-interest mailing list