Parse::RecDescent efficiency

jdavidb on 2005-01-13T19:58:55

When I bundle up the rules for the file format parser I've designed into one big superrule representing the entire file and run the parser, it takes 5 minutes. When I skip that top-level rule and instead write a small program to call the rules that rule included, using appropriate control logic to call the right parsing at the right time, it takes 23 seconds.


P::RD uses nibbling

merlyn on 2005-01-13T20:09:33

P::RD slowly eats away at the string. This is notoriously inefficient for large strings. A "future version" was planned that used pos() instead of nibbling, but that never happened.

Re:P::RD uses nibbling

jdavidb on 2005-01-13T20:49:14

Thanks for the info. I'm parsing a gigantically large string, so that explains it.

Do you know if the Perl6::Rules module would give me any better performance?

Re:P::RD uses nibbling

jdavidb on 2005-01-13T21:28:09

Built my own hand-crafted recursive-descent parser and I can now parse the file in under 2 seconds. Converting my grammar to code was fun; maybe I should get a job as a recursive descent parser compiler. ;)