help-bison
[Top][All Lists]
Advanced

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

Re: Tell a rule to shift instead of reduce?


From: Adam Smalin
Subject: Re: Tell a rule to shift instead of reduce?
Date: Sun, 22 Dec 2013 12:40:19 -0500

I forgot to CC this to the group a few days ago.

>The token precedences apply to the tokens immediately before and after the
parsing ‘.’ (as in the .output file) in the shift/reduce conflicting rules.
The grammar must be written so that the tokens appear in such a position.


| rval '=' rval %prec '.' ',' rval

conflict file:


rval '=' rval . ',' rval
Conflict between rule 343 and token ',' resolved as reduce (',' < '=').

Shouldn't it have worked? I tried putting %prec at the end of the line and
after the ',' as well and it failed. I tried multiple places at once and
got an error saying only one %prec per line.


On Sun, Dec 22, 2013 at 12:38 PM, Adam Smalin <address@hidden>wrote:

> That's one way to solve my literal problem but I would really like to make
> ',' a higher precedence than '=' on that one rule (so it would shift
> instead of reducing 100% of the time).
>
> Both sides should be rvals. What if someone wanted to do something like
>
> get_state().member[index].value, new_state, error_id = func(current_state,
> config)
>
> Is there no way to overload the way the rule resolves the shift/reduce? I
> tried prec and dprec several times one email is
> http://lists.gnu.org/archive/html/help-bison/2013-12/msg00022.html
> I tried using prec directly before and after the comma but that didn't
> override the reduce into a shift.
>
>
> On Sun, Dec 22, 2013 at 11:43 AM, Akim Demaille <address@hidden>wrote:
>
>>
>> Le 17 déc. 2013 à 09:25, Adam Smalin <address@hidden> a écrit :
>>
>> > I still need help with this. I rewrote it maybe this will be more clear?
>> >
>> > I want to allow this
>> >
>> > var = var
>> > var, var = var
>> > var = var, var
>>
>> Maybe I am missing something, by how about clearly stating
>> that you can have several lvalues and rvalues?  The following
>> grammar has no conflict, and requires no precedence/associativity.
>>
>> %%
>> body:
>>   lvals '=' rvals
>> ;
>>
>> lvals:
>>   lval
>> | lvals ',' lval
>> ;
>>
>> rvals:
>>   rval
>> | rvals ',' rval
>> ;
>>
>> rval: "var"
>> lval: "var"
>>
>>
>


reply via email to

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