[antlr-interest] Determining Imaginary Nodes

John Volk john.t.volk at gmail.com
Thu Jan 10 16:26:51 PST 2008


Hi,

I'm wondering if there is a way to determine programmatically whether a
CommonTree node is an imaginary node (i.e., a node created in a rewrite
rule; not from the text of the file being parsed).

I've looked at a few possiblities.  For example, it seems that if the
CommonToken for a particular CommonTree node has -1 as it's tokenIndex, then
that node is imaginary.  This doesn't catch all the cases, though.  In some
cases where an imaginary node is a non-leaf node, it looks like the
tokenIndex of the token for that node is somehow derived from the node's
children.  This isn't true of all non-leaf nodes, though.  Many will have -1
as the tokenIndex.

Anyone have any ideas?  Hopefully, I'm being clear enough.

Thanks.

- John
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/antlr-interest/attachments/20080110/8b1733d4/attachment-0001.html 


More information about the antlr-interest mailing list