[antlr-interest] Newbie question - Walk AST or Stack Machine?
Geir Ove Skjaervik
geiroves at online.no
Fri Nov 5 18:51:54 PST 2004
Hello,
I hand-coded my own lexer & parser for a simple c-like language I
wrote some 10 years ago. I used a stack machine to execute the
compiled code. I also wrote a debugger for the same language.
I am now in the process of creating a similar language and it's
debugger. I decided to use ANTLR because it supports both Java and
C#.
It's a long time since I done this now, so go easy on me :-) I
understand that I can use an autmatically generated AST and walk
it's tree to execute the code instead of using a stack machine.
However, I have a HARD time finding examples on how this is done
e.g. for function declarations and calls. (abritrary number of
parameters). The only thing I have found so far is CHAD, here:
http://www1.cs.columbia.edu/~sedwards/classes/2003/w4115f/final-
reports/CHAD.pdf
Appendix B page 56. shows the chad.g file
Looking at how function declarations and calls is handled walking
the ChadWalker (p. 100) it looks VERY complex, in fact MUCH more
complex than generating code for a Stack Machine! It also looks
complex to DEBUG in case of errors!
Can anyone advise me here:
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
nd please go easy on the terminology as I am an ANTLR newbie, and
haven't worked with parsers for 10+ years.
And to the ANTLR people: More examples on this would have been nice.
Geir Ove
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