Re: Implementing a stack-based interpreter

Alex McDonald <ar.mcdonald@virgin.net>
22 Jul 2005 20:14:43 -0400

          From comp.compilers

Related articles
Implementing a stack-based interpreter cvrebert@gmail.com (2005-07-17)
Re: Implementing a stack-based interpreter ar.mcdonald@virgin.net (Alex McDonald) (2005-07-22)
Re: Implementing a stack-based interpreter mailbox@dmitry-kazakov.de (Dmitry A. Kazakov) (2005-07-22)
Re: Implementing a stack-based interpreter gah@ugcs.caltech.edu (glen herrmannsfeldt) (2005-07-22)
Re: Implementing a stack-based interpreter john.carter@tait.co.nz (John Carter) (2005-07-22)
Re: Implementing a stack-based interpreter Jan.Bogaerts@telenet.be (Jan Bogaerts) (2005-07-22)
Re: Implementing a stack-based interpreter anton@mips.complang.tuwien.ac.at (2005-07-26)
Re: Implementing a stack-based interpreter dot@dotat.at (Tony Finch) (2005-07-26)
[6 later articles]
| List of all articles for this month |

From: Alex McDonald <ar.mcdonald@virgin.net>
Newsgroups: comp.compilers
Date: 22 Jul 2005 20:14:43 -0400
Organization: Virgin Net Usenet Service
References: 05-07-070
Keywords: interpreter
Posted-Date: 22 Jul 2005 20:14:43 EDT

cvrebert@gmail.com wrote:
> I know this is comp.compilers, but since there isn't a
> comp.interpreters, I figure this is the right place to ask.
> I'm trying write an interpreter for a programming language but haven't
> been able to find anything on how to write a stack-based interpreter.
> If anyone could point me to a book/website I'd be much obliged.
> Thanks again.
> - Chris
> [Compile to a string of reverse polish operators, then interpret that string
> pushing results on the stack and popping operands off the stack. -John]


Take a look at Forth; it is a stack based language. Newsgroup is over at
comp.lang.forth; there are also quite a lot of forth implementations,
from public domain to polished professional. There's a webring at
http://t.webring.com/hub?ring=forth, and a FAQ at
http://www.complang.tuwien.ac.at/forth/faq/toc.html.


One stack isn't quite enough, btw, unless you're interpreter is for a
simple RPN calculator; Forth uses two, one for data and one for return
addresses of called subroutines (called words in Forth).
--
Regards
Alex McDonald
[One stack is enough if you have a simple enough procedure call without
variable length argument lists and the like. -John]



Post a followup to this message

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