[antlr-interest] Newbie question - imaginary nodes

Chris Lambrou chris at lambrou.net
Sun Apr 6 16:33:24 PDT 2008


Hello there,

I'm currently working through Ter's book and trying to understand how to
create imaginary nodes to represent pseudo-operations. I'm having trouble
with the relevant section from the book 'Adding imaginary nodes' (p.166), as
follows:

decl : type ID ';' -> ^(VARDEF type ID) ;

This represents the 'variable declaration' pseudo-operation, with two child
nodes representing the type and name of the variable. It's clear that 'type'
refers to another rule, and ID represents an identifier token, but where
does VARDEF come from? With reference to the imaginary VARDEF token, the
book states the following:

The imaginary token must be defined elsewhere in a grammar or in the
tokenssection.

Where can I define the VARDEF token elsewhere in the grammar? I can't define
like all of the 'concrete' tokens, as a VARDEF token can never exist as an
actual sequence of input characters. This leaves the alternative of defining
it in the tokens section, but I can't find any other reference to the
tokenssection in the book.

Regards,

Chris
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/antlr-interest/attachments/20080407/e2221c6f/attachment.html 


More information about the antlr-interest mailing list