himanshu.garg@gmail.com wrote:> Hello,>> I have seen hoc ( Kernighan & Pike ), PL0 ( Niklaus Wirth )
that> 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)