From: Mohamed Yousef [mailto:[email protected]] Sent: Tuesday, October 27, 2009 7:19 AM To: Jim Idle Subject: Re: [antlr-interest] [C Target] Bug in AST walking , implementing control flow 2009/10/27 Jim Idle <[email protected]> It probably is a bug I am afraid. 3.2.1 will be a 'catch up' release to ensure that everything works in C. You can make calls to LT() directly and so on though. so i could for now - till 3.2.1 - use something like ifstat : ^('if' c=expr s=. e=.) { pANTLR3_BASE_TREE s=(pANTLR3_BASE_TREE)LT(1); pANTLR3_BASE_TREE e=(pANTLR3_BASE_TREE)LT(1); You would not have the s=. and e=., just code to consume what you need. //do whatever with return values or custom nodes in e&s } will this work even if s had children (e will be next 'stat' not just a certain child of s ) ? For index and related properties you should use the method calls rather than the fields directly, but if you know you will never override the structure types then you only have to worry if I change the names of the fields. This is not likely, but I don't guarantee not to do it. what method do you mean ? , i couldn't find any methods in pANTLR3_BASE_TREE that returns the index of the tree root You probably need: pANTLR3_COMMON_TREE s = =(pANTLR3_COMMON_TREE)(((pANTLR3_BASE_TREE)LT(1))->super); Nodes are valid between tree walks and rewrites so long as you do not free the node streams until you are completely done. You can dup a node outside the factory and then it will persist, but you need to free the memory. the syntax i use for carrying out 3 consecutive walks is something like // filtered initial walk , on certain portions of tree treePsr1 = yatgWalkerNew(nodes); treePsr1->program(treePsr1); // walk 2 based on indices from 1 treePsr2 = yatgWalkerNew(nodes); treePsr2->program(treePsr2); // walk 3 by the same walker of 2 , utilizing indices from it walk 2 & 1 treePsr2 = yatgWalkerNew(nodes); treePsr2->program(treePsr2); so , indices across these walks should be valid ? Yes, but I suggest that you don't use the nodes etc, create your own 'class'/structure and populate it from the information in the node. You will probably need to reset the node stream etc too. Jim --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
List: http://www.antlr.org/mailman/listinfo/antlr-interest Unsubscribe: http://www.antlr.org/mailman/options/antlr-interest/your-email-address
