Mail Archives: djgpp/1994/09/13/10:47:39
Can anyone help me:
I am writing a program ( using DJ's gcc - which is great by the way! )
which needs to evaluate a user specified mathematical function of several
variables like sin(x*y) fairly rapidly for many x and y values. I appreciate
that the best way to do this might be to link in object code defining
the function but this is not feasible for me: the people specifying the
function may not even know what a compiler is. This seems
to leave me the task of parsing the user's input into some sort of
tree structure and then using this to evaluate the function.
I thought of writing a grammar in Bison for the parsing-into-a-tree but
I'm loath to do this because I've no idea what I'm doing in Bison and I
want to avoid thinking up my own home-grown ( and bad ) methods of
function parsing/evaluation.
In any case I'm sure someone must have already had this "user defined
function problem" and solved it better than I ever could.
Does anybody know how to do this or what I should be doing?
Thanks a lot,
Duncan Sands.
PS: Sophisticated functions, looping, conditionals etc. are not needed,
just the standard mathematical functions and operations. On the other
hand, the more the better!
- Raw text -