How do I get a wildcard to match a complete subtree? For example... (DECL name 
(ARRAY (TYPE float) 9))

Currently I can only get the wild card to match any flat node like: (DECL name 
float 9).

Here are my tree pattern match rules...

expand_array_declaration
        :       ^(VDECL ty=. ^(IADECL id=. bnds=.))                             
-> ^(VDECL ^(ARRAY $ty $bnds) $id)
        ;

expand_array_declarations
        :       ^(VDECL ty=. (^(IADECL id+=. bnds+=.))+)                        
-> ^(VDECLS ^(VDECL ^(ARRAY $ty $bnds) $id)+)
        ;
        
expand_scalar_declaration
        :       ^(VDECL ty=. ^(ISDECL id=.))                                    
        -> ^(VDECL $ty $id)
        ;
        
expand_scalar_declarations
        :       ^(VDECL ty=. (^(ISDECL id+=.))+)                                
        -> ^(VDECLS ^(VDECL $ty $id)+)
        ;


Also, as you can see, I have to versions that seem to account for a limitation 
(bug?) in the rewriting that only allows you to replace a node with a single 
node.  What these rules are doing is expanding type declarations so they are 
unified (e.g. float a, b[4], c, d[5]; -> float a; float[4] b; float c; float[5] 
d;).  So I need to replace one child with many. Simplified version would be: 
(VDECL type id+) -> (VDECL type id) (VDECL type id) (VDECL type id). Currently 
I have to do it in two separate rules and then I am guessing I will need a 
second pass to gather all the VDECLS + VDECL and flatten them out. Am I missing 
something obvious? Can (or should I be able to) replace on node with many?

Any help on these two issues is much appreciated.

Thanks,
Kevin


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.

Reply via email to