parser for mathematical evaluation of expressions

parser for mathematical evaluation of expressions

Post by Joey Calisa » Sun, 12 Dec 1999 04:00:00



greetings!

i am looking for a parser code in c++ language to be used in our programming
assignment which graphs mathematical functions. the user will input
mathematical expression(in terms of x only) eg:
    (x^3(exp(x)+sinh(x^3-2x)))/lnx
we need a parser code to evaluate this expression correctly and if anybody
of you has a parsing code, or anything similar o which we can pattern the
code because we really have no idea of how it look like or how it works, and
the programming assignment is due in one week, so we'll have to modify any
parser code u have to suit our program.

any help will be greatly appreciated.
thanx a lot.

joey

 
 
 

parser for mathematical evaluation of expressions

Post by David Harmo » Sun, 12 Dec 1999 04:00:00


On Sat, 11 Dec 1999 15:57:48 +0800 in comp.lang.c++,


>i am looking for a parser code in c++ language to be used in our programming
>assignment which graphs mathematical functions.

See the calculator example in chapters 6 & 8 of Stroustrup +The C++
Programming Language, Third Edition_.

 
 
 

parser for mathematical evaluation of expressions

Post by Mr. Gras » Sun, 12 Dec 1999 04:00:00


We have a project which is similar to yours, but we couldn't
 find any parser code and we wrote a parser code in C++
Builder.This code parses the whole text line by line and
detects the ANSI C function calls and displays the
prototypes of these functions.
Try to use stack structure and strtok() function. Get
strings by strtok and push them onto the stack and use them
afterwards.This is our approach.
try www.freecode.com or www.download.com
I hope this will help you

* Sent from AltaVista http://www.altavista.com Where you can also find related Web Pages, Images, Audios, Videos, News, and Shopping.  Smart is Beautiful

 
 
 

parser for mathematical evaluation of expressions

Post by Aaron Montgomer » Sun, 12 Dec 1999 04:00:00




>i am looking for a parser code in c++ language to be used in our
>programming
>assignment which graphs mathematical functions. the user will input
>mathematical expression(in terms of x only) eg:
>    (x^3(exp(x)+sinh(x^3-2x)))/lnx
>we need a parser code to evaluate this expression correctly and if anybody
>of you has a parsing code, or anything similar o which we can pattern the
>code because we really have no idea of how it look like or how it works,
>and
>the programming assignment is due in one week, so we'll have to modify any
>parser code u have to suit our program.

I was going to suggest using yacc/bison and lex/flex, but if this is for
a single assignment due in a week, that is probably overkill. However,
if it is a reasonable solution, I've got some bison/flex files which
handle that type of processing (and then some).

e-mail if you want the files (remove the *),
Aaron Montgomery

 
 
 

parser for mathematical evaluation of expressions

Post by Joey Calisa » Mon, 13 Dec 1999 04:00:00


thanx a lot!!!


Quote:> We have a project which is similar to yours, but we couldn't
>  find any parser code and we wrote a parser code in C++
> Builder.This code parses the whole text line by line and
> detects the ANSI C function calls and displays the
> prototypes of these functions.
> Try to use stack structure and strtok() function. Get
> strings by strtok and push them onto the stack and use them
> afterwards.This is our approach.
> try www.freecode.com or www.download.com
> I hope this will help you

> * Sent from AltaVista http://www.altavista.com Where you can also find

related Web Pages, Images, Audios, Videos, News, and Shopping.  Smart is
Beautiful
 
 
 

parser for mathematical evaluation of expressions

Post by Joey Calisa » Mon, 13 Dec 1999 04:00:00


thanx a lot!!
i've seen that flex/bison thing and i really don't understand such codes,
anyway thanx for replying..




> >i am looking for a parser code in c++ language to be used in our
> >programming
> >assignment which graphs mathematical functions. the user will input
> >mathematical expression(in terms of x only) eg:
> >    (x^3(exp(x)+sinh(x^3-2x)))/lnx
> >we need a parser code to evaluate this expression correctly and if
anybody
> >of you has a parsing code, or anything similar o which we can pattern the
> >code because we really have no idea of how it look like or how it works,
> >and
> >the programming assignment is due in one week, so we'll have to modify
any
> >parser code u have to suit our program.

> I was going to suggest using yacc/bison and lex/flex, but if this is for
> a single assignment due in a week, that is probably overkill. However,
> if it is a reasonable solution, I've got some bison/flex files which
> handle that type of processing (and then some).

> e-mail if you want the files (remove the *),
> Aaron Montgomery


 
 
 

parser for mathematical evaluation of expressions

Post by Joey Calisa » Mon, 13 Dec 1999 04:00:00


thanx a lot!!! I'm going to buy that book too...


> On Sat, 11 Dec 1999 15:57:48 +0800 in comp.lang.c++,

> >i am looking for a parser code in c++ language to be used in our
programming
> >assignment which graphs mathematical functions.

> See the calculator example in chapters 6 & 8 of Stroustrup +The C++
> Programming Language, Third Edition_.

 
 
 

parser for mathematical evaluation of expressions

Post by Paul Baxte » Mon, 13 Dec 1999 04:00:00


Since you're so pleased about getting an answer, I thought I might mention
some code...

http://www.xs4all.nl/~apinkus/yacas.html

Its a bit more complete than a simple parser (e.g. it also interfaces to a
3D plotter for the visualisation)
but does have some code you could look at.

Personally, for learning's sake flex/bison are useful things to learn as is
the excellent advice/examples in Stroustrups book.

Good luck

Paul Baxter

 
 
 

parser for mathematical evaluation of expressions

Post by corb.. » Fri, 17 Dec 1999 04:00:00




Quote:> greetings!

> i am looking for a parser code in c++ language to be used in our
programming
> assignment which graphs mathematical functions. the user will input
> mathematical expression(in terms of x only) eg:
>     (x^3(exp(x)+sinh(x^3-2x)))/lnx

If your assignment consists of actually writing the parser code, then
this might not be too useful.  But in the future, should you need a
ready-made math parser, then try UCalc Fast Math Parser.  You can visit
http://www.ucalc.com and download a copy.  It works with VC++, C++
Builder, as well as other leading Windows compilers (VB, Delphi,
etc...).

Daniel Corbier, UCALC
http://www.ucalc.com

Sent via Deja.com http://www.deja.com/
Before you buy.

 
 
 

1. Mathematical Expression Parser has moved

Due to the appearance of a rather aggressive firewall, the old server for
the parser (http://wong.scripps.edu/~iano/Parser) has been replaced with a
new one:

        http://www.alienorb.com/Parser

Hopefully it will be able to stay there for a good long time. The latest
revision is version 1.2.6.

For those of you wondering what I am talking about, the Mathematical
Expression Parser is a ANSI C++ library with full source that can parse a
mathematical expression (e.g. "sin(x) + pi") and evaluate it for any x (or
y or foobar) that you care to supply. It features arbitrary user defined
variable names and a host of supported operators and function types. It
can take partial derivatives of expressions and also has some symbolic
math capability. Evaluation times approach those of directly compiled
code.

____


   Department of Chemistry and Chemical Engineering
   California Institute of Technology  
____                      

2. CFP : AI'94 : TUTORIAL : KAM

3. Mathematical Function Parser

4. Setup restarts? How many?

5. Evaluating a Mathematical expression?

6. ****Permanent & Contract Employment Opportunities**** Job #007

7. evaluate a string as a mathematical expression

8. Copying details ONLY of a directory?

9. Optimizing Mathematical Expressions For Size

10. A Class for recording mathematical expressions?

11. Help on parsing Mathematical expression

12. Runtime Expression Evaluation

13. Expression Evaluation/Parsing Libraries