You are telling to type them as pANTLR3_COMMON_TREE and so that's what it does. It's your fault, not ANTLR's ;-) The ability to specify the type is just a left over from the Java, basically you should not do it as everything is just passed around via the base pointer.
Jim > -----Original Message----- > From: Kevin J. Cummings [mailto:[email protected]] > Sent: Friday, February 18, 2011 2:19 PM > To: Jim Idle > Subject: Re: [antlr-interest] Problem with AST type in tree grammar in > C target > > On 02/18/2011 04:59 PM, Jim Idle wrote: > > The type of a node is pANTLR3_BASE_TREE and that is the default, you > > do not need to specify it as it is ALWAYS that unless you want to do > > lots and lots of work, which you don't. > > I had used pANTR3_COMMON_TREE for my parser AST, so I just "assumed" I > needed to do the same for the Tree parser since it was reading in those > nodes. > > > Now the default tree factory actually creates pANTLR3_COMMON_TREE but > > this contains pANTLR3_BASE_TREE and it is the pointer to the base > tree > > that is used because EVERY tree node implementation must contain one > of these. > > > > So, when you use the pointer, if you want to access the COMMON_TREE, > > then you cast the 'super' pointer in the base tree to > > pANTLR3_COMMON_TREE and hey presto. > > > > { > > pANTLR3_COMMON_TREE ct = (pANTLR3_COMMON_TREE)($assLhs->super); > > } > > But, the example I quoted below is the code that ANTLR generated, not > something from my actions. Shouldn't ANTLR get it right in its > generated code? > > I will play further with trying to remove the AST type from the tree > grammar and see what happens.... > > > Jim > > -- > Kevin J. Cummings > [email protected] > [email protected] > [email protected] > Registered Linux User #1232 (http://counter.li.org) List: http://www.antlr.org/mailman/listinfo/antlr-interest Unsubscribe: http://www.antlr.org/mailman/options/antlr-interest/your-email-address -- You received this message because you are subscribed to the Google Groups "il-antlr-interest" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/il-antlr-interest?hl=en.
