[antlr-interest] Multiple pass tree walking Q

Hill, Robert rhill03 at eds.com
Wed Oct 4 23:33:57 PDT 2006


Lol, walked into that one ;)
Its not the tree walk per se, as you've demonstrated... Its putting it
all together with the action code, swathes of token comparisons, and
then mountains of getInstance() and setAttributes() for the output
templates. Its sooooo much easier (and cleaner to look at) to use the
tree parser generator, I think. Maybe im just being uber lazy ;)

Cheers
Rob



--
Rob Hill
EDS - Hallamshire Business Park
F1E/045
Sheffield	
T:	+44 (0) 114 291 1928
M:	+44 (0) 791 732 1227
E:	rhill03 at eds.com

 

>-----Original Message-----
>From: antlr-interest-bounces at antlr.org 
>[mailto:antlr-interest-bounces at antlr.org] On Behalf Of Andy Tripp
>Sent: 04 October 2006 21:29
>Cc: ANTLR Interest
>Subject: Re: [antlr-interest] Multiple pass tree walking Q
>
>Hill, Robert wrote:
>
>>Yay - a Reply! I was thinking my mails weren't getting through for a 
>>minute there ;)
>>
>>Hmm, I considered this originally, but I think I only need 3 
>passes, so 
>>while it's a big hassle, using grammars has take out a huge wodge of 
>>time in getting it up and running , whereas I feel that walking the 
>>tree's manually would probably have taken a fair bit longer.
>>
>Things can't get any simpler than walking the tree by hand:
>
>void walk(AST ast) {
>  // do stuff
>  AST child = ast.getFirstChild();
>  while (child != null) {
>     walk(child);
>     child = child.getNextSibling();
>  }
>}
>
>I'm using an old version of ANTLR. By now, it's probably:
>void walk(AST ast) {
>// do stuff
>for (AST child: ast.getChildren()) {
>   walk(child);
>}
>}
> 
>
>


More information about the antlr-interest mailing list