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.