[antlr-interest] Tree walking Q

Gerald B. Rosenberg gbr at newtechlaw.com
Sat Jun 4 21:05:14 PDT 2005


At 06:48 PM 6/4/2005, Gerald B. Rosenberg wrote:

>At 07:27 PM 6/4/2005, Bryan Ewbank wrote:
>
>>Another option, perhaps, that may not work as well in general, is:
>>
>>    walker :
>>       #( op:.
>>          { preorder(#op); }
>>          (walker)*
>>          { postorder(#op); }
>>       );
>
>Thanks for this suggestion.  It is really close -- maybe if I can combine 
>it with syntactic predicates ...

walker:
    #(a1:FirstToken p1:walker)   { processFirstToken(AST a1, AST p1); }
    #(a2:SecondToken p2:walker)  { processSecondToken(AST a2, AST p2); }
    #(a3:ThirdToken p3:walker)   { processThirdToken(AST a3, AST p3); }
    #(a4:FourthToken p4:walker)  { processFourthToken(AST a4, AST p4); }
    #(uk:.  (p5:walker)*)        { System.out.println("Skipping all 
others..."); }
;

The trick is the "." and the "()*" together.

Seems like it is working perfectly.

Thanks again,
Gerald
----
Gerald B. Rosenberg, Esq.
NewTechLaw
285 Hamilton Avenue, Suite 520
Palo Alto, CA  94301-2576

650.325.2100  (office)  /  650.703.1724  (cell)
650.325.2107  (fax)

www.newtechlaw.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/antlr-interest/attachments/20050604/69abf6a9/attachment-0001.html


More information about the antlr-interest mailing list