in reply to Re: On modules
in thread On modules

That could be true as well, merlyn. Recursive descent (the methodology) is the right way to do this sort of thing, but what TheDamian's module does isn't exactly classic RD. It is hard to do this in P::RD where it might be better done in a YACC-style parser because of the left recursion issue.

I was as frustrated with using the module itself as I was with the slowness of the program. Part of the reason I rewrote it was so that I could build my own trace functions and examine my own variables and stacks. I felt that understanding TheDamian's code would have taken me as long as the approach I took, and might not have given me the same results. That's the main reason I focused on the use of modules, and it's a broader concern than just with P::RD. As you say, any module and / or approach has its plusses and minuses and these must be evaluated for each problem one approaches.

Replies are listed 'Best First'.
Re^3: On modules
by merlyn (Sage) on Aug 20, 2005 at 05:10 UTC
    Recursive descent (the methodology) is the right way to do this sort of thing
    No, this is apparently the problem. RD is great for some things, but not for this. There's a reason that gcc is not RD, but LALR. Again, I'm a bear of very little brane about this, but when TheDamian explained it to me, it made sense at the time. It doesn't matter how fast you speed it up: something with 22 levels of precedence should be parsed with LALR (if it can), not RD.

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

      What I appear to have implemented is a homebrew 'Packrat Parser', which is RD with a modifiable context stack. I think that the recursive nature of my problem, in which any given non-operator element might itself be another whole expression, function, or if-then-else statement, leads me to some form of cascading procedural solution.

      I'll go back and reread my Pigeon (lex & yacc) book and see if I can find some Aho to see if I can grok this more deeply. The whole subject is worth understanding thoroughly.

      Thanks for your comments, merlyn!