Mark S. Johnson wrote:
>
> I would like to write some code to parse mathematical expressions and
> place the results into meaningful objects. Better yet, I'd rather use
> someone else's code to do this! :-)
An excellent sentiment!
As you likely know, there are classically two phases to doing this sort
of thing:
1. Input a text string and form some sort of internal, probably tree
based, internal representation.
2. Manipulate that internal representation to your heart's content.
This is where you implement your own fancy object oriented solver.
There are many tools available for doing the former, and compiler
writers/designers tend to have strong opinions about them. There are
various kinds of grammars that you can prove theorems about and build
parser generators to handle. The classic in this field is YACC (Yet
another Compiler Compiler), which shows its age in various ways. A gnu
version of YACC is Bison. These are not object oriented -- they produce
C code that inputs a string and outputs a data structure or an error.
I've seen references to object oriented versions of these but I have no
experience with them.
The bottom line here: DEFINITELY use somebody else's solution for this
sort of parsing. There is a vast amount of experience out there with
parsing expressions like this. I can't point you to the One True And
Best Way to do it, but doing it yourself is almost certainly not it.
-- Steve R. Karmesin
This archive was generated by hypermail 2b29 : Wed Feb 20 2002 - 03:20:05 EST