[Top][All Lists]

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

Re: Featuritis: Token actions

From: Frank Heckenbach
Subject: Re: Featuritis: Token actions
Date: Sat, 26 Jul 2003 00:31:36 +0200
User-agent: semail 20030303

Hans Aberg wrote:

> 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. :-)

I'm afraid I currently don't have the time for it, and I'm still
dealing with several other issues with Bison. Also, as I said, I've
solved my needs (ab)using locations, so I don't really have the
"great need" now. It might have been useful some months ago, but now
it would mean double extra work for me (implementing it in Bison and
changing my code to the new model). So, perhaps someday when I have
the time, but don't count on it ...

> >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.

No, one would have to stick the actions to the following real token.


Frank Heckenbach, address@hidden
GnuPG and PGP keys: http://fjf.gnu.de/plan (7977168E)

reply via email to

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