logical and arithmetic parsing and evaluation

"Alex Kuznetsov" <alexkuzn@pacbell.net>
22 Dec 2002 10:37:58 -0500

          From comp.compilers

Related articles
logical and arithmetic parsing and evaluation alexkuzn@pacbell.net (Alex Kuznetsov) (2002-12-22)
| List of all articles for this month |

From: "Alex Kuznetsov" <alexkuzn@pacbell.net>
Newsgroups: comp.compilers
Date: 22 Dec 2002 10:37:58 -0500
Organization: Prodigy Internet http://www.prodigy.com
Keywords: question
Posted-Date: 22 Dec 2002 10:37:57 EST

I need C/C++ code to parse and evaluate expressions consisting from
logical and arithmetic operations, for example:


if( op1 && op2 )
    return 1;
else if( !op3 && (op4 > 0.0 || op5 * op6 < 1.0))
    return 2;


return 0;


How should I tackle it? I don't want to use external programs like bc
because of performance reasons.


Many thanks
[Sounds like you need a little calculator application. I'd start by
seeing if I could borrow the expression evaluator from TCL. Or if you
read in an expression once and then evaluate it many times, write it out
to a file in a wrapper function you can call, call the C compiler and
linker to make a shared object, dlopen() the shared object, and call
your new routine as needed. -John]





Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.