[antlr-interest] another nondeterminism question

Alan Oursland alan at oursland.net
Mon Feb 17 11:21:33 PST 2003


Ah! That works. Thanks.

I remember reading that in the docs now, but I didn't think I would apply in
this case.

I've also found that a liberal use of syntactic predicates helps resolve
most of the nondeterminism warnings and lets me avoid lots of ugly and
painful left factoring and inlining.

Incidently, I am working on an r5rs Scheme grammar file for a class. If no
one has done so yet, I'll send it to you at the ned of the semester.

Alan

> -----Original Message-----
> From: Terence Parr [mailto:parrt at jguru.com]
> Sent: Friday, February 14, 2003 5:29 PM
> To: antlr-interest at yahoogroups.com
> Subject: Re: [antlr-interest] another nondeterminism question
>
>
>
> On Friday, February 14, 2003, at 03:21 PM, Alan Oursland wrote:
>
> > I am having problems with lookahead in the parser now. Is this another
> > problem with linear approximation? The grammar and warnings are at the
> > bottom of this message.
>
> I believe this is a linear approximation problem.  It's a tough one
> with all of the parenthesis around.
> >
> > I think that k=2 should have resolved any nondeterminism here.
> > In expression, (cond_clause)+ should loop on ("(" "(" | "(" "EXPR"),
> > transition to else_clause on ("(" "else"), and skip the else_clause on
> > (")").
> >
> > I also tried doing (options{greedy=false;}: cond_clause)+, but that
> > gave me:
> > 	TestParser.g:15: warning:nongreedy block may exit incorrectly due
> > 	TestParser.g:15:     	to limitations of linear
> approximate lookahead
> > (first
> > k-1 sets
> > 	TestParser.g:15:     	in lookahead not singleton).
>
> Well, greedy=true is probably better because you want it to keep
> matching expressions while it can.  Try it out...
>
> Ter
> --
> Co-founder, http://www.jguru.com
> Creator, ANTLR Parser Generator: http://www.antlr.org
> Lecturer in Comp. Sci., University of San Francisco
>
>
>
>
> 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