[antlr-interest] Enhancement request for identifyingimaginarytokens

Steve Bennett stevagewp at gmail.com
Wed Dec 19 20:18:26 PST 2007


On 12/15/07, Terence Parr <parrt at cs.usfca.edu> wrote:
> Hi. Why not do what I do:
>
> s : 'if' e 'then' s -> ^('if' e s)
>    | e ';' -> e
>    ;
>
> etc...  no need for imaginary tokens.  Remember imag is for nodes that
> have no corresponding input token.

I'm a bit unclear on this. Not having yet gotten to the tree-walking
or output generation phases, I don't know the ramifications of the
choices, but it seems somehow a bit untidy having an AST composed of
both imaginary and real tokens. I would be inclined towards using IT's
everywhere, in order to have consistent naming etc, but this isn't a
good idea?

Steve


More information about the antlr-interest mailing list