[antlr-interest] Re: Resolving nondeterminism

mikemoretti antlr4 at mordent.com
Tue Jun 22 10:47:02 PDT 2004


You probably need to hoist the guts of the attribute and operation 
into the foo rule and use lookahead:

foo
    : ("oneway")=> ("oneway")? scopedId ID LPAREN RPAREN
    | scopedId ID
    ;


Hope this helps,
-Mike


--- In antlr-interest at yahoogroups.com, Braden McDaniel <braden at e...> 
wrote:
> Given:
> 
>         class TestParser extends Parser;
>         
>         foo
>             :   attribute
>             |   operation
>             ;
>         
>         attribute
>             :   scopedId ID
>             ;
>         
>         operation
>             :   ("oneway")? scopedId ID LPAREN RPAREN
>             ;
>         
>         scopedId
>             :   ("::")? ID ("::" ID)*
>             ;
> 
> Because of the nature of scopedId's definition, antlr complains of
> nondeterminism between foo's alternatives for any value of k. I'm 
just
> wondering if there are any clever tricks to resolve this without
> mangling the productions too badly for the human reader.
> 
> -- 
> Braden McDaniel                           e-mail: <braden at e...>
> <http://endoframe.com>                    Jabber: <braden at j...>



 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
     http://groups.yahoo.com/group/antlr-interest/

<*> To unsubscribe from this group, send an email to:
     antlr-interest-unsubscribe at yahoogroups.com

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



More information about the antlr-interest mailing list