[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

when to use PEP treetop vs regexp

dave

1/28/2008 3:27:00 PM

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!
--
Posted via http://www.ruby-....

1 Answer

Phrogz

1/28/2008 4:16:00 PM

0

On Jan 28, 8:27 am, David Rose <bitdo...@yahoo.com> 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/ow...
[2] http://rubyforge.org/projects/tagtr...