16 Nov 1999 23:43:37 -0500

Related articles |
---|

Runtime mini-compiler for a formula toombs@hurontel.on.ca (Greg) (1999-11-16) |

From: | "Greg" <toombs@hurontel.on.ca> |

Newsgroups: | comp.compilers |

Date: | 16 Nov 1999 23:43:37 -0500 |

Organization: | Compilers Central |

Keywords: | question, parse |

I am scraping together bits of code to make a mathematical formula

runtime mini compiler. What this will do, is take a string (with a

formula in it) as an argument, and initialize a class with information

as to evaluating the formula during run-time. The behaviour of the

first few steps of this compiler are very much like a normal language

compiler -- the only problem is that that part is not yet implemented.

I simply do not know where to start. I realize that I am a mere

programming amateur (more of a mathematician) but can efficiently code

in C when I know what I'm doing...

Here's an example. For a graphing program, the program would include

the above capability for interpreting the user's formula. If the user

entered the formula "x+(y-3)*9" to be graphed, I need to put that

string through the mini-compiler in order to get a set of

instructions, much like assembly language, that would look like:

1. Calculate y subtract 3

2. 9 times step one

3. x plus step two

All I need is a bit of code that can do the above. Maybe what I am

describing is a parser but the definition is cloudy in my mind.

Anyway, thankyou very much for reading.

Greg

toombs@hurontel.on.ca

Post a followup to this message

Return to the
comp.compilers page.

Search the
comp.compilers archives again.