*antlr-3.2 and libantlr3c-3.2*
> What version of the runtime? What version of the ANTLR tool? > > Jim > > > >* -----Original Message----- > *>* From: antlr-interest-bounces at antlr.org > <http://www.antlr.org/mailman/listinfo/antlr-interest> [mailto:antlr-interest- > *>* bounces at antlr.org > <http://www.antlr.org/mailman/listinfo/antlr-interest>] On Behalf Of ??????? > ????? > *>* Sent: Wednesday, April 27, 2011 11:27 PM > *>* To: antlr-interest at antlr.org > <http://www.antlr.org/mailman/listinfo/antlr-interest> > *>* Subject: [antlr-interest] [C-target] Child-parent relationship > *>* > *>* I took "simplecTreeParser" example, antlr-3.2 and libantlr3c-3.2 ( + ms > *>* vs 2005). After generating AST (after "SimpleCAST = psr- > *>* >program(psr);") and after checking count of errors I inserted this > *>* code: > *>* > *>* correctParent = SimpleCAST.tree; > *>* child = (pANTLR3_BASE_TREE)(correctParent->getChild(correctParent, 0)); > *>* suggestedParent = (pANTLR3_BASE_TREE)(child->getParent(child)); > *>* if (correctParent == suggestedParent) > *>* printf("\n\nCorrect\n\n"); > *>* else > *>* printf("\n\nIncorrect\n\n"); > *>* > *>* So after execution "Incorrect" was printed. Because > *>* ((pANTLR3_COMMON_TREE)child->super)->parent had NULL. It seems to me it > *>* happens due to error in implementaion of "setParent" function in > *>* antlr3commontree.c. I also used Python target and python's "setParent" > *>* has diffrent logic. > *>* > *>* Dmitry Ilyin > *>* > *>* > *>* Take a look at antlr.markmail.org for other examples but where are you > *>* > > *>* trying to get the parent, in the parser before you have built the AST > *>* (it > *>* > > *>* sounds like this) or in the tree walker? You should not need to change > *>* any > *>* > > *>* of the runtime functions; you are probably just making them do things > *>* that > *>* > > *>* are going to get done anyway at the end of the rule. Look at the > *>* generated > *>* > > *>* code for ways to traverse the tree. I suppose there could be a bug, but > *>* ut > *>* > > *>* seems a bit unlikely at this point. > *>* > > *>* > *>* > Jim > *>* > > *>* > *>* > > -----Original Message----- > *>* > > *>* > From: antlr-interest-bounces at antlr.org [mailto:antlr-interest- > *>* > > *>* > bounces at antlr.org] On Behalf Of ??????? ????? > *>* > > *>* > Sent: Wednesday, April 27, 2011 11:15 AM > *>* > > *>* > To: antlr-interest at antlr.org > *>* > > *>* > Subject: [antlr-interest] [C-target] Child-parent relationship > *>* > > *>* > > *>* > > *>* > Sorry, I have no exp in using mailing lists, so I hope i'm doing > *>* right. > *>* > > *>* > I'm trying to get parent of AST node, but "getParent" function > *>* returns > *>* > > *>* > 0x00000001c address. Because pointer to parent of the node's super is > *>* > > *>* > equal to NULL. But when I've changed functions "addChild" and > *>* > > *>* > "setParent" all child-parent relationships become correct. > *>* > > *>* > Dmitry Ilyin > *>* > > *>* > > *>* > > *>* > List: http://www.antlr.org/mailman/listinfo/antlr-interest > *>* > > *>* > Unsubscribe: http://www.antlr.org/mailman/options/antlr- > *>* interest/your- > *>* > > *>* > email-address > *>* > > *>* > *>* List: http://www.antlr.org/mailman/listinfo/antlr-interest > *>* Unsubscribe: http://www.antlr.org/mailman/options/antlr-interest/your- > *>* email-address > * > > 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.
