Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

Parse::RecDescent and need for speed

by EchoAngel (Pilgrim)
on Feb 15, 2005 at 22:35 UTC ( [id://431365]=perlquestion: print w/replies, xml ) Need Help??

EchoAngel has asked for the wisdom of the Perl Monks concerning the following question:

Hi Monks, After some testing of my scripts, I found that the my language file parsing script (all self program in perl) takes a long time. If I was to use Parse::RecDescent, would it go faster? (is Parse::RecDescent all in perl?). There is a need for speed . Or should I got for Parse::Yapp or the perl package for bison I been looking at Perl Optimization techniques such as print using , or using Memoize package (only for static functions). Note : I am parsing big files

Replies are listed 'Best First'.
Re: Parse::RecDescent and need for speed (eq Parse::Yapp)
by grinder (Bishop) on Feb 16, 2005 at 08:26 UTC
    If I was to use Parse::RecDescent, would it go faster?

    Parse::RecDescent is known to be slow. So much so that Damian Conway want(?:ed|s) to write Parse::RecDescent::Fast. Or something like that.

    Another alternative is to use Parse::Yapp (Yet Another Perl Parser). I haven't used it personally, but a number of people who have have appreciated the speed. They have also appreciated less, the fact that it is drop-in compatible with yacc(1). No-one knows yacc anymore. stefp was threatening a while back to write a front-end to P::Y to get it to accept P::RD's input, but I don't know if he got round to doing so.

    - another intruder with the mooring in the heart of the Perl

Re: Parse::RecDescent and need for speed
by VSarkiss (Monsignor) on Feb 15, 2005 at 22:48 UTC
      it's in the functions where I am processing comment statements
        my script tries to preserve the whole file within a structure hash , including comments.
Re: Parse::RecDescent and need for speed
by kvale (Monsignor) on Feb 15, 2005 at 23:41 UTC
    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

        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;

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://431365]
Approved by Tanktalus
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others lurking in the Monastery: (5)
As of 2024-04-19 03:42 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found