|Executing code without generating stack machine code email@example.com (2005-04-26)|
|Re: Executing code without generating stack machine code firstname.lastname@example.org (Carlos) (2005-04-30)|
|Re: Executing code without generating stack machine code email@example.com (2005-04-30)|
|Date:||30 Apr 2005 11:01:16 -0400|
|Posted-Date:||30 Apr 2005 11:01:16 EDT|
> I have seen hoc ( Kernighan & Pike ), PL0 ( Niklaus Wirth )
> are calculator programs.
> I was wondering if I could execute code from its tree
> representation without generating any intermediate code. At the least
> my language supports if/then/else, loops, procedures, goto's and
> expressions. This would allow me to avoid the extra stack machine
> processor code, required to run the intermediate code.
Simple interpreting of trees is not hard, but you might find it more
fun to try something like a threaded code interpreter, which can be
added to an AST quite easily by replacing the object type with a
pointer to the procedure which implements that object type. (I'm sure
C++ programmers will have a pretty way to do it, but it all boils down
to procedure pointers)
I wrote an example some years ago, which might help:
Return to the
Search the comp.compilers archives again.