There's next to no decision making (failed key backtracks to '}', failed record backtracks to /\Z/), so it shouldn't be intrinsicly slow. Rules like a : b c | b d could easily drag down the parser, but there's no such rule.
The parser might be copying the entire unparsed input text everytime it calls a rule, instead of just keeping a pointer to the current location within the text. This could lead to high memory usage and swapping.
The parser provides a number of variables to each rule. Some provide info to error-reporting functions, even if they are not used. Some are to allow actions to be as flexible as possible. There could be lots of overhead. Reducing the number of rules by inling those without '|'s should speed things up, but would have an severe impact on readability and maintainability.
You could try turning off warnings. I have no idea how much overhead they add.
Instead of returning a data structure, the actions could add to a data structure as soon as a rule is parsed. This could save a lot of memory and copying.
You could Precompile the grammar and look at it. Or even use it as if it was Precompiled:
Parse::RecDescent->Precompile($grammar, 'g') or die("Bad grammar\n"); require g; my $p = g->new(); my $text = ...; my $data = $p->parse($text) or die("Bad data\n");
In reply to Re^6: Pulling data out of { }
by ikegami
in thread Pulling data out of { }
by Felix2000
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |