in reply to Re: RFC: Module for evaluation math. expressions
in thread RFC: Module for evaluation math. expressions
My parser consists of a self made lexer and a recursive descending parser. The code is quite lengthy, but not really complicated.
Parsing and evaluation are different steps indeed, you can do something like
use Data::Dumper; my $m = Math::Light::Expression->new; $m->parse($expression); print Dumper $m->{ast}; for (0 .. 9) { print $val->({ a => $_ }), "\n"; # evaluate multiple times }
I experimented with a LaTeX emitting backend, but that goes against the grain of keeping modules small and doing exactly what they are meant for.
I considered a PIR emitter as well, but PIR handles precedence on its on, so there is now real need to for my parser ;-)
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: RFC: Module for evaluation math. expressions
by tsee (Curate) on Sep 07, 2007 at 21:06 UTC |