Re: An expression compiler with run-time interpretation?

"Mikael Lyngvig" <mikael.lyngvig@toolwood.dk>
23 Sep 2000 14:51:58 -0400

          From comp.compilers

Related articles
An expression compiler with run-time interpretation? TArcidiacono@bridge.com (Tom) (2000-09-21)
Re: An expression compiler with run-time interpretation? peter_flass@my-deja.com (2000-09-23)
Re: An expression compiler with run-time interpretation? mikael.lyngvig@toolwood.dk (Mikael Lyngvig) (2000-09-23)
Re: An expression compiler with run-time interpretation? nr@labrador.eecs.harvard.edu (2000-09-24)
Re: An expression compiler with run-time interpretation? rus@tamu.edu (Silvius Rus) (2000-09-28)
| List of all articles for this month |
From: "Mikael Lyngvig" <mikael.lyngvig@toolwood.dk>
Newsgroups: comp.compilers
Date: 23 Sep 2000 14:51:58 -0400
Organization: Compilers Central
References: 00-09-146
Keywords: interpreter

Depending upon your requirements (how large your final executable may
be), you may also consider to simply embed the Python interpreter, see
http://www.python.org for more info, directly in your application.


You'd then get a very powerful "expression evaluator", actually a
complete interpreted object-oriented programming language, which you
could let handle those issuees. It is trivial to embed the Python
interpreter; I believe the demo program, in the Python source
distribution, is less than 30 lines of C code (including a full C
main() function).


Python supports 32-bit integers, a special long integer type (with
virtually unlimited precision), floating point numbers, strings,
lists, dictionaries, classes, and all the other goodies you'd probably
ever need.


To get going quickly on Windows, download the Python v1.6 source and
binary distributions from the Python web site, install it, open the
Python manuals (there should be a link in the Python folder in the
Start menu), go to the section "Extending and Embedding", and read the
chapter "Embedding Python in Another Application". (The directions
are actually for the v1.5.2 release, because I don't have v1.6
installed on this computer, but I'd be surprised if the directions
don't work). After that, build the "demo\embed" sample and try it
out.


If you need help with the process, please feel free to write me.


It the final executable is a bit too large for your taste, you can
always consider to compress it using the UPX, which can be retrieved
from http://wildsau.idv.uni-linz.ac.at/mfx/upx.html.


P.S. Like Tcl, Python was/is intentionally developed to be embedded in
other applications.


-- Mikael


----- Original Message -----
From: "Tom" <TArcidiacono@bridge.com>


> I'm building an application that must be able to read arithmetic
> expressions (such as x = 12 * ((y + z)/ (sqrt(y))) ) from an external
> text file at runtime, "compile" them, and later evaluate the
> expression to find a result when the variable values have been
> satisfied. The evaluation may have to happen multiple times during the
> life of the program, as the variable values may change.


Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.