Re: Executing code without generating stack machine c ode

Himanshu Garg <>
28 Apr 2005 14:52:19 -0400

          From comp.compilers

Related articles
Re: Executing code without generating stack machine c ode (Himanshu Garg) (2005-04-28)
Re: Executing code without generating stack machine c ode (Tom Verbeure) (2005-04-30)
| List of all articles for this month |

From: Himanshu Garg <>
Newsgroups: comp.compilers
Date: 28 Apr 2005 14:52:19 -0400
Organization: Compilers Central
References: <267988DEACEC5A4D86D5FCD780313FBB079181D6@exch-03.noida.hcl>
Keywords: architecture
Posted-Date: 28 Apr 2005 14:52:19 EDT

Thanks for your replies John and Gaurav,

On 4/27/05, Gaurav Gautam, Noida <> wrote:
> Yes, u are right , we can always execute code from parse tree skipping the
> IG and directly generating assembly code.

Actually I don't even want to generate assembly code to be executed by
the processor. I want to get the output of the program
i) either by walking its AST
ii) or by generating stack machine code and executing it.

> I ur case, the programs like calculator this can be done fairly easily, as
> many things are handled by the HLL in which u are writing this program. For
> exapmle in C ur task reduces to identifying only tokens and rules..and
> actual addition can be left on c (or the underlying compiler on which u are
> attepting to write a calculator).
> However when the program gets tougher..this may pose problems..
> Also skipping IG make the compiler less portable and less optimised.

I am using c/lex/yacc. What is the recommended way of doing it. I just
found some fairly descriptive way of doing it using the stack machine
in the chapter on Run Time Environments of The Dragon Book. I am
afraid I don't know how to walk the AST and execute loops, procedures,
if/then/else and goto's.

Thank You,

Post a followup to this message

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