On 7/3/06, Paul Seamons <[EMAIL PROTECTED]> wrote:


It isn't specifically a parser designed for general language parsing, but
CGI::Ex::Template does have a mathematical expression parser.


Thanks, but this falls into the realm of existing wheels which is a
different part of this project.


perl -e 'use CGI::Ex::Template; $s=CGI::Ex::Template::dump_parse("3 * 4 **
2 +
5"); $s =~ s/\s+/ /g; print "$s\n"'

$VAR1 = [ \[ '+', [ \[ '*', '3', [ \[ '**', '4', '2' ], 0 ] ], 0 ], '5' ],
0 ];


Ok, but where is the evaluation?  I know it wouldn't be too hard to write
something that could evaluate this data structure to produce the correct
results but that is what this project is all about.  Some parsers make this
easier than others.  Some allow the expression to be evaluated as it is
parsed while some require additional homegrown code to parse the resulting
parse tree (data structure).

I have not had a chance to look at Flavio's links yet.  Since no one who
actually knows rules seemed to be inspired to write an example for me - I
will *eventually* figure it out on my own and post back to the list as an
FYI.

Paul Seamons


Cheers,
Joshua Gatcomb
a.k.a. Limbic~Region

Reply via email to