Given an existing AST with the two paths:

^( a b? ^(m n) c? d )

and

^( a b? ^(x y? ^(m n)) c? d )

(that is, both paths have the same root node 'a')

Given that 'm' is the interesting node, is there a way to write tree 
pattern matching rules that distinguish the 'm' based on the separate paths?


topdown : ^(m .*)  ; // works nicely, but matches on both paths

topdown : ^(a .* ^(m *.) .*) ; // should this work?  I would expect 
it to still match both paths


// should this work?
topdown : ^(a .* ( ^(x .* ^(m .*) )    { call_1($m); } // on match second path
                  | ^(m .*)             { call_2($m); } // on match first path
                  )
                  .*) ;


As a concrete example, the ANTLR grammar defines identical ^(OPTIONS 
.*) blocks, one that is a subtree of GRAMMAR and another that is a 
subtree of RULE, which in turn is a subtree of GRAMMAR.  Would be 
best to directly distinguish them in the pattern match, rather than 
poking around in the AST to examine parents.

Thanks.


--~--~---------~--~----~------------~-------~--~----~
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

Reply via email to