[antlr-interest] Collecting disparate subtrees into one tree?

J. Stephen Riley Silber jsrs701 at yahoo.com
Tue Jun 30 17:02:13 PDT 2009


Hi gang,

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?

Thanks,
Stephen

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/antlr-interest/attachments/20090630/39973dc2/attachment.html 


More information about the antlr-interest mailing list