bug-bison
[Top][All Lists]
Advanced

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

Re: Featuritis: Token actions


From: Hans Aberg
Subject: Re: Featuritis: Token actions
Date: Fri, 25 Jul 2003 00:46:02 +0200

At 18:14 +0200 2003/07/24, Frank Heckenbach wrote:
>> If one should do such a combination, then that is perhaps that such
>> immediate action tokens, when arriving, are put in a queue, until a real
>> (non-action) token arrives. Then the actions of the queued tokens are
>> executed when the parser discovers that the real token must be shifted onto
>> the stack. That should give the right action, right?
>
>I think so.
>
>In fact, this might be a little better than my solution where the
>action (via locations) is done when the token is reduced, because
>shifting always happens in order, while reducing may not (e.g.,
>`1 + 2 * 3' will reduce the `2 * 3' tokens before `1 + '). In my
>code, I had to work around this problem (which wasn't too hard,
>though). So this feature might be useful for me, though not
>essential.

Well, if you agree with me, then it is only to start implement it into Bison.

It should not be too difficult, I think. Roughly, one needs a "switch"
statement body for token actions, similar to that of the rule actions, a
lookup table telling what which tokens have actions attached, and in case
an action token is not used in the grammar, the .output file should say
that it is an action token.

Since I do not have the right computer equipment to do it, and you have a
great need for it, that leaves you doing it, I guess. :-)

>BTW, I think we'd get essentially the same power if there was a way
>to stick actions to a token (independent of the token value), i.e.
>basically just a way to invoke some user-defined routine when a
>token is shifted. This would shift (pun intended) some work from
>bison (no queue required) to the user's code -- I don't know what's
>generally considered preferable ...

You can do this too, but then you can't insert new tokens as you please
anywhere in the grammar.

  Hans Aberg






reply via email to

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