[LA.pm] Math Parens parsing code needed
Peter Benjamin
pete at peterbenjamin.com
Mon Aug 19 19:31:24 CDT 2002
Anyone know of open source for parsing mathematic
expressions? The one at CPAN is fair. My needs
extends to generating error messages calling out
where the parsing problem occurs. For example:
(34.5 * sin(.5) ) - tan(4.5
is missing the trailing parens. That is an easy one.
Let's try 6 levels of paren nesting and calling out
the first parsing error that occurs from left to right,
the way a person reads. (Yes, I am trying to avoid
this, but the client... insists.)
Most code I have come across is abstracted to the level
that trapping the problem paren case is too hard to
modify the code.
I looked at the perl source code for 'expr' - ugh.
Source for bc ...
Simtel, garbo, are two I have looked at. Old, but this
paren parsing is an old problem. Not much perl there.
Any other URLs - I can do the searching of a library,
just need more references. I'd prefer perl, or java,
or C, or awk, or sed, or any unix solution.
llnl.gov did not have much, but it was all C. I did not
actually look at the source code, as most was application
specific.
Pete
More information about the Losangeles-pm
mailing list