develooper Front page | perl.perl6.language | Postings from July 2006

Using Rules Today

Thread Next
Joshua Gatcomb
July 3, 2006 08:29
Using Rules Today
Message ID:
I have a for-fun project that I am working on exploring various different
parsers and their methods.  So far I have looked at things like
Parse::RecDescent, Parse::YAPP, Parse::Earley, and HOP::Parser.  I had
Perl6::Rules on my list, but it is my understanding that
Pugs::Compiler::Rule is more up to date.

In any case, I was wondering if someone could provide me with an example of
a mathematical expression parser (and evaluator).
To properly compare to the others, it would need to handle the following

+, -     (left associative)
*, /, % (left associative)
^         (right associative)

handle parens 12 - (3 + 4)

handle two functions sqrt() and abs() both of which must include the parens.

If someone has time to do this for me, I would be appreciative.  It might
also serve as example documentation or cookbook ideas.

I am specifically interested in examples that can be run in Perl 5 today
without needing Pugs or Parrot.

Joshua Gatcomb
a.k.a. Limbic~Region

Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About