in reply to Parse::RecDescent and need for speed

Personally, I find that code generated by Parse::RecDescent is generally slower than a hand-coded recursive descent parser. But such comparisons really depend on the skill of the programmer.

Without seeing your language, grammar, or parser, I can't give any specific advice. In perl top-down parsers, nonterminals in your grammar generally correspond to functions and terminals to regular expressions. So eating comments should be a pretty fast operation. An excellent book on parsers and compilers is Compilers: Principles, Techniques, and Tools, by Aho, Sethi and Ullman.

-Mark

  • Comment on Re: Parse::RecDescent and need for speed

Replies are listed 'Best First'.
Re^2: Parse::RecDescent and need for speed
by merlyn (Sage) on Feb 16, 2005 at 01:03 UTC

      At one point, theDamian said he would rewrite it to use pos (which wasn't available in 5.004 when he wrote PRD)

      Bull. pos was available in 5.000, as the perl5.000 manual will tell you.

      At one point, theDamian said he would rewrite it to use pos (which wasn't available in 5.004 when he wrote PRD)
      First non-comment, non-whitespace line of Parse::RecDescent:
      use 5.005;
        In fact, the original was written for 5.004, because it was written on MacPerl, which was only 5.004 at the time.

        The use 5.005 was no doubt added later when some other feature required 5.005.

        -- Randal L. Schwartz, Perl hacker
        Be sure to read my standard disclaimer if this is a reply.