On Wed, Jul 1, 2009 at 2:02 AM, J. Stephen Riley Silber<[email protected]> wrote: > Here's a question for you. (Apologies if this is explained somewhere; I > haven't found it yet.) Suppose I have a language where I have procedures > and functions (Oh! Pascal!), such as this: > > procedure a() { ... } > function x() { ... } > procedure b() { ... } > function y() { ... } > procedure c() { ... } > function z() { ... } > > Now suppose, when I'm emitting the final representation, I want to group the > procs and funcs together--I'm thinking I should somehow rewrite the tree to > get it looking like this simplified version: > > ^( CODE ^( PROCS a b c ) ^( FUNCS x y z ) ) > > Is there a clever way, in tree-rewriting syntax, to attach a subtree as a > child of a completely unrelated node?
doesn't something like this work? code: procs* funcs* -> ^(CODE ^(PROCS procs*) ^(FUNCS funcs*)) -- Damien Cassou http://damiencassou.seasidehosting.st "Lambdas are relegated to relative obscurity until Java makes them popular by not having them." James Iry 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 -~----------~----~----~----~------~----~------~--~---
