Derek M Jones wrote:
>
> cwcaceres wrote:
>
>> Hi, I'm having shift/reduce conflict with the unary expression in my
>> grammar
>> file. I've tried using the %prec modifier but it doesn't seem to work.
>
> It does work, but just not in the way you wanted it to (because you have
> put it in the wrong place, but then I would probably not used it).
>
> I take it the shift reduce conflict occurs on the input:
>
> NUMBER PLUS NUMBER potentially-other-tokens
>
> which can be reduced to a single summation expression
> or shifted because there may be a following UPLUS
>
> Your problem is that you are trying to do too much in too few rules.
>
> Create some productions for the unary operators and separate ones for
> the binary operators. See how the C standard has done it, for an
> example.
>
>
Sorry, I don't understand. How would I create separate productions for unary
and binary operators?
I looked at the C++ grammar. It seems somewhat upside down, but rearranging
I think it's a bit similar to what I did which is why I'm still confused.
additive-expression:
multiplicative-expression
additive-expression + multiplicative-expression
additive-expression - multiplicative-expression
multiplicative-expression:
pm-expression
multiplicative-expression * pm-expression
multiplicative-expression / pm-expression
multiplicative-expression % pm-expression
pm-expression:
cast-expression
pm-expression .* cast-expression
pm-expression ->* cast-expression
cast-expression:
unary-expression
( type-id ) cast-expression
unary-expression:
unary-operator cast-expression
unary-operator: one of
* & + - ! ~
--
View this message in context:
http://www.nabble.com/shift-reduce-conflict-with-unary-tf4303942.html#a12252665
Sent from the Gnu - Bison - Help mailing list archive at Nabble.com.
_______________________________________________
[email protected] http://lists.gnu.org/mailman/listinfo/help-bison