PDA

Click to See Complete Forum and Search --> : Parsing Algorithm


ripperth56
Dec 24th, 2001, 09:30 AM
I'm currently making a very powerful graphing program that can calculate and graph any mathematical expression:

Algebra (except complex numbers), Trigonometry (sin, cos, tan, csc, sec, cot, arccos, arcsin), Analytic Geometry(Conic Sections), Calculus(Piecewise defined functions, Greatest Integer Functions (step functions), Absolute Value Functions)

I'm currently having trouble in making this program because I dont know how to parse correctly (I'm making a program that uses keywords and objects to create the graph).

List of Methods:

Ellipse(X,Y,A,B), Color= RGB(xxx,xxx,xxx);
Circle(X,Y,R), Color=RGB(xxx,xxx,xxx);
Hyperbola(X,Y,A,B), Color=RGB(xxx,xxx,xxx);
Parabola(X,Y, P, Opens), Color=RGB(xxx,xxx,xxx);

List of Functions:

sin
cos
tan
csc
sec
cot
arcsin
arccos
arctan
int - Greatest integer function
abs - absolute value
DER - Derivation (Not Accomplished yet, need help on this)
(all of this is in a text file format, needs to be interpreted)
more.........

jim mcnamara
Dec 28th, 2001, 09:44 AM
Use a descending parser.

It looks for tokens (keywords) then figures out how to translate the keyword argument into something the program can do. There is a descending parser in the attached code.

I've messed with creating an interactive version of C, written in C.
You can play with the attached code - snot.c (short for 'It's not C')

Judd
Jan 3rd, 2002, 10:54 AM
In FORTRAN, but works well:

http://www.its.uni-karlsruhe.de/~schmehl/opensource/fparser-v1.1.tar.gz

based on C++ from:

http://www.students.tut.fi/~warp/FunctionParser