divide and conquer

Gaspard Bucher gaspard at teti.ch
Thu Jul 2 10:45:18 EDT 2009


The "divide and conquer" thing is a custom built parser: it cannot be
compared to full blown parser generators.

I will work a little more to see how all this behaves when adding more
features. After that, we will have to test for speed.

G.

On Thu, Jul 2, 2009 at 4:19 AM, Jason Garber<jg at jasongarber.com> wrote:
> Hi Gaspard (and list)!
>
> I'm back from vacation and somewhat recovered.  Trying to dig back in and
> pick up where I left off.
>
> I've checked out your parser.  Not sure what I think yet.  It's not as far
> along as the treetop-based parser, so it's hard to make a comparison.  How
> did it feel to you?  Do you have a sense of how it will feel fully
> implemented (clean and elegant or a cluttered mess)?
>
> Also would like the thoughts/impressions of anyone else paying attention.
>
> I'm going to get redcloth-treetop a little further along so I can compare
> (the formatter doesn't work yet).
>
> Thanks, everyone—especially Gaspard!
> Jason
>
> On Jun 18, 2009, at 8:01 AM, Gaspard Bucher wrote:
>
>> Hi list (and Jason) !
>>
>> I have a prototype parser that uses a Regexp based "Divide and
>> Conquer" pattern to parse textile:
>>
>> http://github.com/gaspard/redcloth-regexp/tree/master
>>
>> This parser currently only parses simple 'list', 'strong', 'em' and
>> 'bold' but it is very easy to extend and adapt.
>>
>> To give you an idea of how this thing works:
>>
>> 1. take a string
>> 2. try to match first regular expression from context (if you are in
>> :main and :main => [:p, :bold], the first regexp is defined by :p =>
>> ..)
>> 3. if the pattern matches, insert a placeholder and scan matched text
>> in the new context (:p).
>> 4. when you cannot match (no more re in context list), unfold by
>> expanding text to an S-expression tree
>>
>> Example:
>>
>> "hello _em and *strong*_"
>>
>> match regular expression associated with :em
>> => "hello @@=9347=@@"
>>
>> scan matched content in :em context
>> => "em and *strong*" matches :strong
>> => "em and @@=9350=@@"
>>
>> no match in "strong"
>>
>> expand in :strong context ==> [:strong, "strong"]
>> expand in :em context     ==> [:em, "em and ", [:strong, "strong"]]
>> expand in :main              ==> [:main, "hello ", [:em, "em and ",
>> [:strong, "strong"]]]
>>
>> Let me know what you think.
>>
>> Gaspard
>> _______________________________________________
>> Redcloth-upwards mailing list
>> Redcloth-upwards at rubyforge.org
>> http://rubyforge.org/mailman/listinfo/redcloth-upwards
>
> _______________________________________________
> Redcloth-upwards mailing list
> Redcloth-upwards at rubyforge.org
> http://rubyforge.org/mailman/listinfo/redcloth-upwards
>


More information about the Redcloth-upwards mailing list