[comp.lang.pascal] Parser Wanted

rrwood@lotus.waterloo.edu (Roy Wood) (11/24/89)

Subject: Parser Source Wanted
Newsgroups: comp.edu
Distribution: na
Keywords: parser

I am looking for Pascal source code for a mathematical expression parser. 
Ideally, the routine(s) would accept an expression as a string and then
evaluate it for specified independent variables.  For example, the main routine
might call the parser like this:

begin
	x := 1;
	y := 5;

	writeln("Enter the expression to evaluate:");
	readln(user_expression);

	result := parse_expression(user_expression , x , y);

	writeln("Your expression evaluates to ",result);
end.



And the form of the parse_expression function would be something like this:


function parse_expression(the_expression:packed array[1..80] of char;
                          x:real ; y:real): real;


I have a friend who is the head of Mathematics in a school in Scarborough.  He
is currently on sabbatical and is writing a horde of educational software that
will ultimately allow the student to enter any function and have it graphed
on-screen.  I know, you're all saying, "Why bother writing that?  There's tons
of stuff available to do that."  Well, the description I give is grossly
simplified; the software is intended to do a whole lot more than just plot
a curve.

Anyway, my friend is not really a computer whiz, and the thought of writing
his own expression parser makes him cringe.  He has asked me to post a general
request for source code for anything remotely suitable to his needs, which is
why you're reading this.

I would appreciate anything even remotely useful.  My friend wants to ultimately
have his program handle just about any function, but he'd be thankful for
anything you could provide.  He has offered to give credit for anything he uses.

I'm hoping that I get some response to this posting, otherwise I'll have to
write the bloody thing after exams and over Christmas.

Thanks.

-Roy Wood (rrwood@lotus.waterloo.edu)