help-bison
[Top][All Lists]
Advanced

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

Fwd: how to send data up the stack


From: Chris verBurg
Subject: Fwd: how to send data up the stack
Date: Wed, 11 Aug 2010 14:13:22 -0700

(FYI)

---------- Forwarded message ----------
From: Sasan Forghani <address@hidden>
Date: Wed, Aug 11, 2010 at 8:18 AM
Subject: Re: how to send data up the stack
To: Chris verBurg <address@hidden>


Phil and Chris thank you for the response.  I actually figured out what was
wrong last night.  I had my printf statements as there own action after the
reduce action I wanted to occur when expr + expr reduced.  Having 2 separate
action blocks after the last component of a production causes the parsing
problems.  In regards to sending data up the stack, my prof sent me an
example that showed me how to correctly send data up the stack.  As of right
now, everything is working.  I wrote a lot of code last and am almost
finished with my project.  Again thanks everyone for all the help.



On Tue, Aug 10, 2010 at 5:54 PM, Chris verBurg <address@hidden>wrote:

>
> That I might be able to answer: bison has to split rules at actions, so
> introducing actions can actually cause shift/reduce conflicts.  Further, I
> believe bison still looks beyond the action to the next token in order to
> satisfy a lookahead requirement -- which means that it can mess up your
> global state.
>
> As an example, consider:
>
>   a : w x y ;
>   b : w x z ;
>
> will work fine.  But this:
>
>   a : w { blah; } x y ;
>   b : w { foo; } x z ;
>
> will have issues.  After reading in a w, bison can only look ahead one
> token, and reading that "x" doesn't tell it which rule this is, so it
> doesn't know whether it should run the blah or foo block. This is why you
> want to put actions as far at the end of rules as possible.
>
> -Chris
>
>
>
>
> On Tue, Aug 10, 2010 at 1:23 PM, Sasan Forghani <address@hidden>wrote:
>
>>
>> Chris,
>>
>> The project is for a CS class.  I don't know if I can submit it to the
>> list.  I don't want my code out on the internet.  I don't know how my prof
>> would feel about that.  That being said, I discovered that if I add any code
>> Bison's parse goes wrong.  Even if I add an empty action the parse goes
>> wrong.
>>
>> For example:
>>
>> expr : expr addop expr { }
>>
>> causes Bison to parse a = b + c + d
>>
>> c + d = something
>> b + something = something
>>
>> On the note of sending data up the stack, my prof sent me an email with a
>> example script that I am going to try tonight.  Why do you think adding an
>> action to the rule causes Bison to to parse incorrectly?
>>
>> Thanks again for all the help.
>>
>>
>>
>> On Tue, Aug 10, 2010 at 1:42 PM, Chris verBurg <address@hidden>wrote:
>>
>>>
>>> (Replying individually for a quick question)
>>>
>>> I just got back into town and am catching up on email -- have you posted
>>> or otherwise sent out your actual bison source file?  Would that be possible
>>> to do?  It might not be, due to company IP concerns, etc, but at least those
>>> of us trying to help you wouldn't be shooting in the dark so much.  :)
>>>
>>> -Chris
>>>
>>>
>>>
>>> On Mon, Aug 9, 2010 at 2:27 PM, Sasan Forghani <address@hidden>wrote:
>>>
>>>> After the %left issue, the issue left is how to send data up the stack.
>>>> Once a production such as expr : expr + expr is reduced and the actions
>>>> performed how can I send data to the next reduction?
>>>> _______________________________________________
>>>> address@hidden http://lists.gnu.org/mailman/listinfo/help-bison
>>>>
>>>
>>>
>>
>


reply via email to

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