Basic Math parser (and compiler?) library

This forum can be used to talk about general design strategies, new ideas and questions in general related to wxWidgets. If you feel your questions doesn't fit anywhere, put it here.
Post Reply
krysa
Experienced Solver
Experienced Solver
Posts: 71
Joined: Wed Feb 16, 2005 9:23 pm
Location: Lithuania

Basic Math parser (and compiler?) library

Post by krysa » Thu Mar 03, 2005 10:51 pm

I plan to start this project, but before i do, i would like to find all the right tools i need for it. For this project, i need some kind of math library. That is, the programs main purpose will be to collect (some sources that support XML - easy), process (the hard part), and display (wxWidgets - easy) some numbers.
As you can see, there is this "process" part in the work flow. This "process" must be defined by the user of my application. That is, i need want to give the user ability to enter the formula, that will later be used by the application to process given data.
For this to work, i need some kind of scripting language, that would only accept valid math expressions. I only need some basic functions like addition, subtraction, multiplication, division, power and root calculation and full float support.

So i was wondering - can anyone suggest me any OpenSource libraries? If it comes to writing my own library - can you suggest me anything at this point (syntax, how to parse and how to precess the statements)?

Note: i have no experience in making anything like that.

In general, i would like to make a cross platform application. My "native" development platform, however, is MSW. I use Microsoft Visual C++ Toolkit 2003 + all the stuff needed to compile wx (.NET SDK, Platform SDK, etc.)

Thank you for your time.

PS: sorry for my English - i did the best i could...
Platform: MSW (Windows XP Pro)
Compiler: msvc 13.10.3077 (Free Toolkit)
wxWidgets: v2.6.0

gururamnath
Moderator
Moderator
Posts: 466
Joined: Sat Sep 18, 2004 2:49 am
Location: California, USA

Post by gururamnath » Fri Mar 04, 2005 1:45 am

I found some interesting stuff in CodeProject ; have look at

http://www.codeproject.com/cpp/#Math .

There is a project called Fast Math Parser which can also be compiled with GCC.

-Guru Kathiresan

Jorg
Moderator
Moderator
Posts: 3971
Joined: Fri Aug 27, 2004 9:38 pm
Location: Delft, Netherlands
Contact:

Post by Jorg » Fri Mar 04, 2005 7:54 am

I am (still) working on wxLexer. I created a formula parser with it as sample and once it is finished I hope the wx community will adapt it. With this it will be possible to create such things. But as I said, I am a bit put down right now by a very annoying mem leak I can't seem to fix.

What you can also do is use wxGoldParser (from my site) and fabricate a simple grammar in Gold Parser itself. This will give you a good start. I don't know if it is fast enough for you though.

Other then those, try to look at the boost library, and other 3rd party lexers / parsers like lexx, yacc etc.

- Jorgen
Forensic Software Engineer
Netherlands Forensic Insitute
http://english.forensischinstituut.nl/
-------------------------------------
Jorg's WasteBucket
http://www.xs4all.nl/~jorgb/wb

krysa
Experienced Solver
Experienced Solver
Posts: 71
Joined: Wed Feb 16, 2005 9:23 pm
Location: Lithuania

Post by krysa » Fri Mar 04, 2005 8:30 am

Thanks.
I think i have everything i need now...
You're a life saviour! Did you know that? :)
Platform: MSW (Windows XP Pro)
Compiler: msvc 13.10.3077 (Free Toolkit)
wxWidgets: v2.6.0

krysa
Experienced Solver
Experienced Solver
Posts: 71
Joined: Wed Feb 16, 2005 9:23 pm
Location: Lithuania

Post by krysa » Fri Mar 04, 2005 8:34 am

Jorg wrote:<...>- Jorgen
I'll take a look at your libs too.
I could try to test it a little bit.
Platform: MSW (Windows XP Pro)
Compiler: msvc 13.10.3077 (Free Toolkit)
wxWidgets: v2.6.0

gururamnath
Moderator
Moderator
Posts: 466
Joined: Sat Sep 18, 2004 2:49 am
Location: California, USA

Post by gururamnath » Fri Mar 04, 2005 8:34 pm

Hi,
If you are creating a wrapper for these libs in wx, then feel free to submit your contribution to the wx community.

-regards,
Guru

Post Reply