when to use PEP treetop vs regexp

Discussion in 'Ruby' started by David Rose, Jan 28, 2008.

  1. David Rose

    David Rose Guest

    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-forum.com/.
    David Rose, Jan 28, 2008
    #1
    1. Advertising

  2. David Rose

    Phrogz Guest

    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/
    Phrogz, Jan 28, 2008
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Christoph Becker-Freyseng

    PEP for new modules (I read PEP 2)

    Christoph Becker-Freyseng, Jan 15, 2004, in forum: Python
    Replies:
    3
    Views:
    355
    Gerrit Holl
    Jan 16, 2004
  2. Lie
    Replies:
    25
    Views:
    709
    Dafydd Hughes
    Dec 18, 2007
  3. Phrogz
    Replies:
    18
    Views:
    230
    IƱaki Baz Castillo
    Apr 22, 2008
  4. Phrogz

    Treetop Email Parser

    Phrogz, Jan 28, 2008, in forum: Ruby
    Replies:
    13
    Views:
    191
    Phil Tomson
    Feb 1, 2008
  5. Joao Silva
    Replies:
    16
    Views:
    328
    7stud --
    Aug 21, 2009
Loading...

Share This Page