[Top][All Lists]

[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 11:04:56 +0200

I think that the version to be implemented is where the token actions are
executed before right the shift of a real grammar (non-action) token, as it
seems to be important for implementing compiler debugging features, and
good debugging features will surely help up any compiler. As for the first
version I suggested, the token action being executed immediately, I can
only see that might be useable for the lexer sending error actions to the
parser, but that is probably a whole separate chapter and therefore should
probably be treated wholly independently.

If somebody wants to implement this feature (first mentioned above), here
is a list of what I think one should do:

Bison tweaks:
1. Make sure action tokens are unusable in grammar (but they should still
have token numbers).
2. Create a M4 macro for token actions, similar to that of the other actions.
3. Create a M4 macro for a lookup table telling which tokens are action tokens.
4. Make sure the .output file writes out the action tokens as such and not
as "unused tokens".

Skeleton file tweaking, in the parser function:
1. After reading a token from the lexer, check if it is a action token, and
if it is, put it onto the action token queue, and then read a new token.
Repeat until a grammar token is found.
2. Right before a token shift, check if action token queue is non-empty,
and if it is, execute the token actions of the queue. Empty the queue, and
then proceed with the grammar token shift.

  Hans Aberg
                  * Email: Hans Aberg <mailto:address@hidden>
                  * Home Page: <http://www.math.su.se/~haberg/>
                  * AMS member listing: <http://www.ams.org/cml/>

reply via email to

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