Parse

I developed this small ANSI C program at the university. It is a simple formula parser, useful for many situations, like an intelligent input in dialog boxes.

The gag in this parser is the possibility to compile formulas into p-code to get a major performance improvement while calculating. This is useful for formula plotters, etc., that uses the same formula only with different values.

In Parse.h some configurations can be done:

Besides the trivial operations (“+”, “-”, “*“, “/”, “^”, with brackets) the parser also know the following functions:

Name Description
“PI” the value PI (3.1415926…)
“E” the value e (2.7182818)
“X”, “Y”, “Z” the values X, Y, Z
“acos”, “arccos” the function cos-1(a)
“asin”, “arcsin” the function sin-1(a)
“atan”, “arctan” the function tan-1(a)
“atan2”, “arctan2” the function tan-1(a,b)
“ceil” the function ceil(a)
“cos” the function cos(a)
“cosh” the function cosh(a)
“exp” the function exp(a)
“floor” the function floor(a)
“fmod” the function fmod(a)
“log” the function log(a)
“log10” the function log10(a)
“pow” the function pow(a,b)
“sin” the function sin(a)
“sinh” the function sinh(a)
“sqrt” the function sqrt(a)
“tan” the function tan(a)
“tanh” the function tanh(a)

Sourcecode for the Parser

Previous post:
Next post: