Matching templates against a tree - any ideas?

Phil Hunt philh at vision25.demon.co.uk
Thu Sep 23 18:02:21 EDT 1999


In article <000401bf04bc$282158a0$342d153f at tim>
           tim_one at email.msn.com "Tim Peters" writes:
> [Ian Clarke, wants to do tree pattern-matching]
> 
> [John Skaller, suggests a parsing approach]
> 
> Note that John Aycock's "Compiling Little Languages" Python framework (see
> DejaNews) is built on an Earley parser, constructing a parse tree from input
> that matches an arbitrary context-free grammar. 

People say Earley parsing is slow, but my experience is that it is
fast enough. My Parrot program uses a modified version of John
Aycock's framework (the modifications slow it down, by remembering
the line and column numbers of the start of each token), and it
can read in a 150 line input file, parse it, process it, generate code 
from it, and save the results to disk, in 1.5 seconds. (This is
on a cheapish PC with a 300 MHz AMD K6-2 processor).

I guess it depends on the grammar you are parsing.

-- 
Phil Hunt - - - - - - - - -  philh at vision25.demon.co.uk
   - Linux was 8 years old on 17th September! See: -
http://www.vision25.demon.co.uk/prog/linuxbirthday.html





More information about the Python-list mailing list