[antlr-interest] Re: Please - can someone help me out?

lgcraymer lgc at mail1.jpl.nasa.gov
Sat Nov 6 17:36:26 PST 2004



--- In antlr-interest at yahoogroups.com, "Geir Ove Skjaervik"
<geiroves at o...> wrote:
...
> > What's the easiest way to execute my code? Use a Stack Machine or 
> > Walk an auto-genrated AST? Remember, I also need to write a 
> debugger 
> > for the language

Actually, the "best" approach is to implement a threaded code compiler
with a stack-based virtual machine.  That is, the compiler (AST
walker) generates sequences of instruction references (byte codes are
common--each byte encodes an instruction id) and the runtime loops
over a massive case statement--each case encodes the behavior for an
instruction--fetching the instructions in sequence and executing them.
  Data is usually pushed onto a stack when referenced and popped when
used; you also may want to keep a frame pointer for referencing local
variables.  For debugging, you can keep pointers to instruction
locations to track line starts.

I am not aware of a good book on threaded compiler implementation for
C-like languages.  Timothy Budd's "A Little Smalltalk" is worth
reading;  Python internals are a bit gruesome, but the evaluator is in
ceval.c.  The Java VM spec is also worth reading.

--Loring





 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/antlr-interest/

<*> To unsubscribe from this group, send an email to:
    antlr-interest-unsubscribe at yahoogroups.com

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 





More information about the antlr-interest mailing list