[antlr-interest] another nondeterminism question
Terence Parr
parrt at jguru.com
Fri Feb 14 15:29:17 PST 2003
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/
More information about the antlr-interest
mailing list