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: Tue, 17 Dec 2013 20:05:07 -0500

I don't believe that works. According to my rules and the conflict files it
REFUSES to shift. "var, var = var" I think will work but "var = var, var"
will be seen as rval ',' rval which isn't legal. I'm not sure where I can
make rval ',' rval legal and have my code work because doing it in rval:
will mean func(1,2) can be func(rval) instead of func(rval ',' rval). I
could do extra work to check for these things but EVERYTHING would be more
simple if I can just tell it not to reduce when it sees that rule



On Tue, Dec 17, 2013 at 5:26 PM, Hans Aberg <address@hidden> wrote:

> On 17 Dec 2013, at 09:25, Adam Smalin <address@hidden> wrote:
>
> > 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
>
> If you can do dynamic type checking, it suffices to write rules (as in the
> Bison manual calculator example):
>
> expr:
>     expr "op0" expr
>   | expr "op1" expr
>   ...
> ;
>
> And then add precedence rules:
>
> %left ","
>
> %nonassoc "then"
> %nonassoc "else"
>
> %right "≔"
>
> It works fine to resolve dangling "else" with precedences as well. The
> normal way to break precedences is with matched pairs () [] {} etc.
>
> Hans
>
>
>


reply via email to

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