Piper, Martin wrote: > Greetings, > ... > > My main confusion is that when generating a tree > > ^(rule_1 A B) > rule_1: TOKEN C D->^(TOKEN C D) > produces a tree (TOKEN C D A B) > > but the same when walking the tree seems to expect to find ((TOKEN C D) A B) >
Hi Martin, You ran into the same issue I did a while back (and whined about it here :-). Given an expression "^(LEAF)", the (tree-generating) parser will generate a single LEAF node, but the tree parser will expect the node sequence LEAF-DOWN-UP - tree parser takes ^() expression bit more literally. A simple but crude workaround is to refactor your tree grammar so that the root term of an ^() expression is not a subrule that matches another ^() expression. For your simple example, the simple fix is to inline rule_1 into ^() expression referencing rule_1 as its root term. This inlining business wasn't so bad for my tree grammar, but I suspect it could be a pain for others. Perhaps others can chime in with better solutions. Jay 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.
