[antlr-interest] Simple nondeterminism help

Nico nico123 at adinet.com.uy
Sun Oct 19 15:30:31 PDT 2003


Hi, thankz for anwering.
My problem is still there. I have changed some things but I still have
nondeterminism in number RULE.

I am converting a grammar from an BNF And I always have this nondeterminism
errors.

Does anybody know some guidelines to avoid this?

regards:
class S2Parser extends Parser;

options {
k = 2;
exportVocab=S2;
}

// nondeterminism here !!
number: (digits "r")? (MINUS)? bigDigits ("." bigDigits)? ("e" ("-")?
digits)?

;
bigDigits: (bigDigit)+
;

bigDigit: DIGIT | CAPITALLETTER
;

letter: LOWERLETTER | CAPITALLETTER;

digits: (DIGIT)+;

class S2Lexer extends Lexer;

options {
k = 2;
exportVocab=S2;
}

DIGIT : '0'..'9' ;
LOWERLETTER: 'a'..'z';
CAPITALLETTER: 'A'..'Z'
;

----- Original Message ----- 
From: "Arnar Birgisson" <arnarb at oddi.is>
To: <antlr-interest at yahoogroups.com>
Sent: Sunday, October 19, 2003 2:47 PM
Subject: RE: [antlr-interest] Simple nondeterminism help


Perhaps have CAPITALLETTER and LOWERCASELETTER as parser rules and add

protected letter: CAPITALLETTER | LOWERCASELETTER;

as a parser rule. Does that solve your problem?

The task of lexical analyzing should be as decoupled from parsing as
possible, and only in the parsing stage do you have enough information
and context to know if you are expecting an upper-case letter or just
any letter.

Arnar

> -----Original Message-----
> From: Nico [mailto:nico123 at adinet.com.uy]
> Sent: 18. október 2003 21:55
> To: antlr-interest at yahoogroups.com
> Subject: Re: [antlr-interest] Simple nondeterminism help
>
>
> If I add protected keyword to CAPITALLETTER the
> nondeterminism is gone.
> But, I want to call CAPITALLETTER also from a parser rule. If I add
> protectect
> keyword it cannot be seen by the parser right?
>
> ----- Original Message ----- 
> From: "Terence Parr" <parrt at cs.usfca.edu>
> To: <antlr-interest at yahoogroups.com>
> Sent: Saturday, October 18, 2003 12:08 AM
> Subject: Re: [antlr-interest] Simple nondeterminism help
>
>
>
> On Friday, October 17, 2003, at 06:34  PM, Nico wrote:
>
> > Hi, I need some help in this undeterminism.
> >
> >
> > LETTER: CAPITALLETTER | ('a'..'z');
> > CAPITALLETTER: ('A'..'Z');
> >
> > How do I solve this?
>
> Add "protected" keyword in front of second rule.
>
> Terence
>
> >
> >
> > Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.
> --
> Professor Comp. Sci., University of San Francisco
> Creator, ANTLR Parser Generator, http://www.antlr.org
> Co-founder, http://www.jguru.com
> Co-founder, http://www.knowspam.net enjoy email again!
> Co-founder, http://www.peerscope.com link sharing, pure-n-simple
>
>
>
>
>
>
> Your use of Yahoo! Groups is subject to
> http://docs.yahoo.com/info/terms/
>
>
>
>
>
> Your use of Yahoo!
> Groups is subject to http://docs.yahoo.com/info/terms/
>
>




Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/



 

Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/ 




More information about the antlr-interest mailing list