Hi all,

Would there be some way of manipulating the skip re to do this?

Something along the lines of:

top: <skip: /NOT START DELIMETER/> chunk(s) eof
chunk: delimeter_start <skip: /NORMAL SKIP/> command(s) delimiter_end
eof: /\Z/

The problem there is defining a skip that won't skip a
delimeter_start. This probably won't allow delimeter_start to _not_
mean the start of a set of commands as well.

Not tested, but just a suggestion.

MB

2009/9/4 Mike Diehl <mdi...@diehlnet.com>:
> On Thursday 03 September 2009 01:50:58 Damian Conway wrote:
>> Hi Mike,
>>
>> > What I've tried amounts to this:
>> >
>> > chunk: /.*?/ delimiter_start command(s) delimiter_end /.*?/
>>
>> Unfortunately that won't work, because every regex in a PRD grammar is
>> independent of the rest of the grammar, so even a minimal-matching .*?
>> eats everything.
>
> Ya, that's what I was suspecting.  In hind sight, I should have figured that;
> that's how I'd write it...
>
>> Is there some reason you can't use something like:
>>
>>     my $parser = Parse::RecDescent->new($grammar);
>>
>>     $text =~ s{<DELIMITER> (.*?) </DELIMITER>}
>>             { $parser->parse($1); q{} }gexs;
>
> That's what I was doing, but it seems I misinterpreted my profiling results.
> I found from profiling that the function I use to create (once) and run the
> parser accounted for 80% of runtime.
>
> I assumed that since I only create the parser once (if !defined), creating the
> parser wasn't where the cost was.  So I decided that it must be due to
> actually running the parser, which might run several times during program
> execution.  My conclusion was that I needed to rewrite the grammar so that
> the parser would only run once.
>
> It sounds like I may need to go back to the old algorithm and start tuning the
> grammar.
>
> --
>
> Take care and have fun,
> Mike Diehl.
>

Reply via email to