[Pharo-project] Evaluate math expression
Hello, What tools will you use to evaluate math expression writen in algebraic form as 2*x*cos(5*x+10). Thanks Hilaire
How will you do it? I have no experience about writting grammar. Thanks Hilaire Le 13/01/2013 22:48, H. Hirzel a écrit :
PetitParser
--Hannes
On 1/13/13, Hilaire Fernandes <hilaire.fernandes@edu.ge.ch> wrote:
Hello,
What tools will you use to evaluate math expression writen in algebraic form as 2*x*cos(5*x+10).
Thanks
Hilaire
Hilarie, It is less difficult than it seems. Lukas has a tutorial how to develop a grammar in a workspace. You can do it step by step and so have immediate feedback how it goes. Actually a very rewarding exercise. Read his tutorial first [2] and [3]. It is about what you are looking for, a math expression evaluator, just a very simple one. You would have to add the function calls. The thesis [4] has a chapter on PetitParser which is introductory level. The same applies for [5]. My estimate is that for your problem it might take you 2...7 hours to create a math expression evaluator depending on what your requirements are. --Hannes References: [1] http://scg.unibe.ch/research/helvetia/petitparser [2] http://www.lukas-renggli.ch/blog/petitparser-1 [3] http://www.lukas-renggli.ch/blog/petitparser-2 [4] Lukas Renggli. Dynamic Language Embedding With Homogeneous Tool Support. PhD thesis, University of Bern, October 2010. http://scg.unibe.ch/archive/phd/renggli-phd.pdf [5] http://www.themoosebook.org/book/internals/petit-parser On 1/14/13, Hilaire Fernandes <hilaire.fernandes@edu.ge.ch> wrote:
How will you do it? I have no experience about writting grammar.
Thanks
Hilaire
Le 13/01/2013 22:48, H. Hirzel a écrit :
PetitParser
--Hannes
On 1/13/13, Hilaire Fernandes <hilaire.fernandes@edu.ge.ch> wrote:
Hello,
What tools will you use to evaluate math expression writen in algebraic form as 2*x*cos(5*x+10).
Thanks
Hilaire
yes... but of course, not complete (no need of UI or other parsers besides the one you wrote). Also, as it's name marks, it is "petit" :) Esteban On Jan 14, 2013, at 11:12 AM, Hilaire Fernandes <hilaire.fernandes@edu.ge.ch> wrote:
Thanks Hannes for the pointers. I will then take the time to learn.
Dumb question: when the grammar is written, does PetitParser still need to be shipped with the final application?
Hilaire
Le 14/01/2013 11:08, H. Hirzel a écrit :
Hilarie,
It is less difficult than it seems.
On Mon, Jan 14, 2013 at 11:08 AM, H. Hirzel <hannes.hirzel@gmail.com> wrote:
References:
I would add http://pharobooks.gforge.inria.fr/PharoByExampleTwo-Eng/latest/ -- Damien Cassou http://damiencassou.seasidehosting.st "Success is the ability to go from one failure to another without losing enthusiasm." Winston Churchill
Damien, Thank you for adding this omission. I wonder if there are tutorials on the intermediary level. So far all what has been mentioned is introductory. However for the actual question -- math evaluator -- they are fine. --Hannes On 1/14/13, Damien Cassou <damien.cassou@gmail.com> wrote:
On Mon, Jan 14, 2013 at 11:08 AM, H. Hirzel <hannes.hirzel@gmail.com> wrote:
References:
I would add http://pharobooks.gforge.inria.fr/PharoByExampleTwo-Eng/latest/
-- Damien Cassou http://damiencassou.seasidehosting.st
"Success is the ability to go from one failure to another without losing enthusiasm." Winston Churchill
participants (4)
-
Damien Cassou -
Esteban Lorenzano -
H. Hirzel -
Hilaire Fernandes