|seeking embeddable statement compiler code email@example.com (Bruce Varley) (2001-11-25)|
|Re: seeking embeddable statement compiler code firstname.lastname@example.org (Silvius Rus) (2001-11-26)|
|Re: seeking embeddable statement compiler code email@example.com (2001-11-29)|
|Re: seeking embeddable statement compiler code Sid-Ahmed-Ali.TOUATI@inria.fr (Sid Ahmed Ali TOUATI) (2001-11-29)|
|Re: seeking embeddable statement compiler code firstname.lastname@example.org (Silvius Rus) (2001-12-03)|
|Re: seeking embeddable statement compiler code email@example.com (2001-12-07)|
|From:||Silvius Rus <firstname.lastname@example.org>|
|Date:||3 Dec 2001 20:22:46 -0500|
|Organization:||Texas A&M University|
|References:||01-11-115 01-11-126 01-11-132|
|Posted-Date:||03 Dec 2001 20:22:46 EST|
"Edward G. Nilges" wrote:
> Silvius Rus <email@example.com> wrote...
> > At one end, you could write an interpreter for the expression
> > language. The code would be pretty slow as every evaluation would be
> > based on a traversal of the graph that represents your expression.
> Why not translate his expression to Polish notation using top-down
> recursive descent, and write or find an interpreter that evaluates the
> expression using a LIFO stack? I see no need to traverse a graph.
True, it is not necessary to chase pointers around a GRAPH. But a
stack evaluator is an implementation of a postorder traversal of the
TREE that represents the expression. These expressions seem simple
enough to be represented as a tree but one could use a DAG to identify
common subexpressions. Cyclic graphs would only be needed for
recurrences. I was just trying to be a little abstract, but I did use
a stack evaluator myself when I had to.
This is still slower than compiled+ optimized native code. Run-time
compilation is a viable alternative and Java hot-spot compilers are
the living proof. They are usually profile-driven, but in this
particular case you could develop a custom way of identifying the
hot-spot and invoke the compiler only when profitable.
Return to the
Search the comp.compilers archives again.