Re: How to build your own stack frames? (interpreter questions)

rick@metronet.com (Rick Barton)
Tue, 22 Aug 1995 05:52:52 GMT

          From comp.compilers

Related articles
How to build your own stack frames? (interpreter questions) seguin@engin.umich.edu (1995-08-20)
Re: How to build your own stack frames? (interpreter questions) tonyk@cybercom.net (1995-08-21)
Re: How to build your own stack frames? (interpreter questions) Lassi.Tuura@hut.fi (1995-08-21)
Re: How to build your own stack frames? (interpreter questions) rick@metronet.com (1995-08-22)
Re: How to build your own stack frames? (interpreter questions) tonyk@cybercom.net (1995-08-22)
| List of all articles for this month |
Newsgroups: comp.compilers
From: rick@metronet.com (Rick Barton)
Keywords: interpreter
Organization: Texas Metronet, Inc (login info (214/705-2901 - 817/571-0400))
References: 95-08-132
Date: Tue, 22 Aug 1995 05:52:52 GMT

Ralph Seguin (seguin@engin.umich.edu) wrote:
: We are looking at creating some interpreter code, and we would
: very much like to have the interpreter call into various methods and
: functions that we have available.


I have been working on a BASIC interpreter which now run on FreeBSD,
Linux, Sparc and (dare I say it), DOS. It needs lots of work on some
of these architecutres, but FreeBSD is my platform.


Anyhow, I used 'THE UNIX PROGRAMMING ENVIRONMENT' (sorry, but the
title is in all caps) by Brian W. Kernighan and Rob Pike. It has
an excellent example of doing an interpreter (hoc). I diverged
at different places. They use a recursive method of having a STOP
constant and then the recursion backs up, where as I generated code
to be executed straight through. This book uses the stack for almost
everything which makes it quite simple to implement. It does use
only simple types (I use the BASIC types such as integer, real, string).
For parameter lists for functions such as PRINT, they are NULL terminated
(much like *argv[]). For each built-in function, you just take
whatever arguements are in the calling sequence and push them onto
the stack. The function will perform a pop to retrieve them. There's
more to it than that, but you get the idea.


I hope this helps. The book realy helped me a lot.


rick
--
rbarton@metronet.com
--


Post a followup to this message

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