|YA YACC/LEX question email@example.com (2003-03-09)|
|From:||firstname.lastname@example.org (Kevin Smith)|
|Date:||9 Mar 2003 17:42:28 -0500|
|Posted-Date:||09 Mar 2003 17:42:28 EST|
I've been through what seems like the whole internet and can't find an
example of what I need to do.
I'm writing a plug-in for a 3D graphics package (Maya). I need to
take a command written in a very simple scripting language, parse it
and pass out the result.
An example input would be
inputString = "2 * tan(input1 * 2)"
This seems like the perfect use for lex/yacc. I've found dozens of
calculators on the web. But (there's always a but :/ ) every example
I've seen compiles a standalone executable. What I need is a function
that I can pass a string, and returns a float, from the compute()
function in my plug-in. I can't for the life of me find an example of
how to do this.
Any pointers to such an example would be hugely appreciated.
Senior Technical Director
[The example in my lex&yacc book evaluates the expression it parses. It's
just integers, but the changes to handle float and more stuff are obvious.
Or you could swipe the expression evaluator from TCL. -John]
Return to the
Search the comp.compilers archives again.