[antlr-interest] Multiple pass tree walking Q

Hill, Robert rhill03 at eds.com
Wed Oct 4 02:19:20 PDT 2006


I know it's a but odd  to repy to your own emails LOL , but I see
another reason for manually parsing the trees as you do,
For 8 passes, as you say you're optimising/transforming the tree as you
go, I would imagine an inhereted tree grammar parsing a somewhat more
fixed tree, so depending on how large the tree , speed may be an issue
here. - its not for me so I think I'll give the inheritance thing a go
anyway.

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: Paul Johnson [mailto:gt54-antlr at cyconix.com] 
>Sent: 04 October 2006 09:13
>To: Hill, Robert
>Cc: ANTLR Interest
>Subject: Re: [antlr-interest] Multiple pass tree walking Q
>
>Hill, Robert wrote:
>> I've pretty much gone down the multiple tree parser routes, 
>its a real 
>> pain in the ass though, as if you modify your parser, you 
>then have to 
>> modify all the tree parser grammars too. I must be missing something 
>> here. :( there must be a rule that ignores a whole branch, but i've 
>> tried all sorts and haven't succeeded ,
>>  
>> ignoreme : ^(.*) ... if only :)
>>  
>> which is why i ended up with 3 tree parse phases. I just get this 
>> nagging feeling im missing the point.
>
>You won't like this reply, but this is why I don't use tree grammars. 
>I've got 8 passes, each of which needs to modify the AST. I 
>manually parse the tree, and cut out branches when I've 
>finished with them (or replace nodes, or whatever).
>
>The recursive tree parse in each pass is (almost) trivial, so 
>a grammar would buy me little. I do have occasional 
>complications with having to find my context in the tree, 
>parsing node lists right-to-left instead of left-to-right, and 
>so on, but no major problems, and certainly nothing that would 
>justify maintaining 8 different grammars. One major advantage 
>is that I can trivially add extra passes that do almost 
>nothing, except maybe some cleaning up for the next pass.
>
>Disclaimer: I've never actually tried the tree grammar route, 
>so I (too) may have missed easy ways to do what I'm now doing manually.
>
>There's a lot on this in the archives - have a look. You could 
>start with Andy Tripp's reply in the "How much use is ANTLR 
>for manipulating ASTs?" thread (18/06/2005).
>
>Paul
>


More information about the antlr-interest mailing list