help-bison
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: resolving shift/reduce in ActionScript3


From: Akim Demaille
Subject: Re: resolving shift/reduce in ActionScript3
Date: Wed, 26 Nov 2008 16:51:38 +0100
User-agent: Gnus/5.110006 (No Gnus v0.6) Emacs/22.0.95 (gnu/linux)

>>> "MK" == Matthias Kramm <address@hidden> writes:

 > state 1
 >     4 EXPRESSION: T_IDENTIFIER . '(' EXPRESSION ')'
 >     5           | T_IDENTIFIER .  [$end, T_IDENTIFIER, ';', '(', ')', "++", 
 > "--", '+', '-', '/']
 >     '('  shift, and go to state 5
 >     '('       [reduce using rule 5 (EXPRESSION)]
 >     $default   reduce using rule 5 (EXPRESSION)

 > Is there some way to tell bison to prefer shifting to reducing in this
 > case? 

Yes, sure.  S/R is a conflict bw a rule (reduce) and a token (shift).
Since you want the shift here, the token must have precedence over the
rule (or both have the same precedence but right associativity).

The rule is labeled by T_IDENTIFIER, so you can just state that

    %nonassoc T_IDENTIFIER
    %nonassoc '('

to get what you want, use use %prec to label the rule with some other
precedence/associativity token.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]