[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: shift/reduce conflict with unary
From: |
cwcaceres |
Subject: |
Re: shift/reduce conflict with unary |
Date: |
Tue, 21 Aug 2007 04:16:26 -0700 (PDT) |
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.
- shift/reduce conflict with unary, cwcaceres, 2007/08/21
- Re: shift/reduce conflict with unary, Derek M Jones, 2007/08/21
- Re: shift/reduce conflict with unary,
cwcaceres <=
- Re: shift/reduce conflict with unary, Derek M Jones, 2007/08/21
- Re: shift/reduce conflict with unary, cwcaceres, 2007/08/22
- Top Dowm Variable Communication, Arijit Das, 2007/08/22
- Message not available
- Re: Top Dowm Variable Communication, Ramón García, 2007/08/22
- Re: Top Dowm Variable Communication, Evan Lavelle, 2007/08/22
- Re: Top Dowm Variable Communication, Evan Lavelle, 2007/08/22
- Message not available
- Re: Top Dowm Variable Communication, lfinsto1, 2007/08/22
- Re: Top Dowm Variable Communication, Ramón García, 2007/08/24
- Re: shift/reduce conflict with unary, Evan Lavelle, 2007/08/22
- Re: shift/reduce conflict with unary, cwcaceres, 2007/08/22