[antlr-interest] Again simple nondeterminism problems

Ersin Er ersin_er at yahoo.com
Tue Aug 23 09:13:51 PDT 2005



--- "John B. Brodie" <jbb at acm.org> wrote:

> Greetings!

Hi!

> On Tue, 23 Aug 2005 01:08:48, Ersin Er asked:
> >I'll be glad if you can help me about the following nondeterminism
> >problems:
> >
> >OID: NUMERICOID | DESCR;
> >NUMERICOID: NUMBER (DOT NUMBER)+;
> >NUMBER: DIGIT | ( LDIGIT ( DIGIT )+ );
> >protected DOT: '.';
> >protected DIGIT: '0' | LDIGIT;
> >protected LDIGIT: '1'..'9';
> >protected DESCR: ALPHA ( ALPHA | DIGIT | '-' )*;
> >protected ALPHA: 'A'..'Z' | 'a'..'z';
> >
> >and I have literal rules like in the lexer:
> >ID_AND: "and";
> >ID_OR: "or";
> >
> >ANTLR complains about two nondeterminisms. The first one is for
> >NUMERICOID (and OID also) and NUMBER and the second one is for DESCR
> >(and OIS also) and ID_AND, ID_OR...
> >
> 
> For NUMBER, need to left factor the LDIGIT in both alternatives, try:
> 
> NUMBER : '0' | ( LDIGIT ( DIGIT )* ) ;
> 
> For DESCR, please read the Antlr documention about the tokens {...}
> section in a lexer, the testLiterals=true option, and generally how
> to
> deal with Keywords that look like Identifiers (don't remember the
> specific chapter(s) in the docs, sorry).

Yes I've read them here:
http://www.antlr.org/doc/options.html#testLiterals

But does not work for me. Any suggestions please?

> Hope this helps...
>    -jbb
> 


--
Ersin ER
Arastirma Gorevlisi
Hacettepe Universitesi
Bilgisayar Muhendisligi Bolumu

__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 


More information about the antlr-interest mailing list