From: Phrogz Date: 2008-01-29T01:19:57+09:00 Subject: Re: when to use PEP treetop vs regexp On Jan 28, 8:27 am, David Rose wrote: > on a practical basis when would want to use treetop parse over using > regular expressions with .scan()? .... > in the wicki 'treetop (PEP)' subject/submission.... it would seem > that using regular expression would be a better tool! I don't have enough experience to be sure, but my guess is: 1) If you can't do it in Regexp (e.g. recursive nested parens), use something like Treetop. 2) If the overall solution using Regexp alone becomes too large or unmaintainable (which may be the same thing), use something like Treetop. (Or you're laying a foundation that you think may become large in the future.) 3) Otherwise, Regexp will be less overhead and, I suspect (but don't know yet) faster. I'm currently porting my OWLScribble[1] library from using (my own strscan/regex state-based) TagTreeScanner[2] parser to use Treetop instead. My goal is to learn Treetop, create a more readable and maintainable syntax description, and also to be able to benchmark and compare the performance of the two implementations. [1] http://rubyforge.org/projects/owlscribble/ [2] http://rubyforge.org/projects/tagtreescanner/