[antlr-interest] Extensions which I have found useful

Fred phreed at gmail.com
Mon Feb 4 08:29:35 PST 2008


On Feb 1, 2008 6:35 PM, Terence Parr <parrt at cs.usfca.edu> wrote:
>
> On Feb 1, 2008, at 10:02 AM, Fred wrote:
<chop/>
> > Modify the *Walker.input to be a stack rather than a single variable.
> > Then similar to what is done with scope, allow the position in the AST
> > to be changed (input = new CommonTreeNodeStream(subtree))  as the rule
> > is entered.
> > (In my current implementation the subtree is obtained from a symbol
> > table.)
> > Normally, a preparatory pass through the AST to augment the symbol
> > table with the relevant information would be performed but that makes
> > the association less clear.
> > Conceptually, the input stack provides a way to "lazily" augment the
> > symbol table.
>
> interesting. i'll think about this when doing an interpreter.
>
> Ter
>
I can almost get the current implementation of 'scope' to do the whole
thing, but not quite.
Would it be a problem to have the 'input' property be implemented as a
stack rather than (in addition to) a variable?

By the way...
If the 'scope XYZ;' is used and something goes wrong during the
'@init' of a rule the finally section of the try doesn't run.
Meaning, there is a situation wherein the scope stack doesn't get
popped, leaving it in a damaged state.

peace


More information about the antlr-interest mailing list