home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.sources.wanted
- Path: sparky!uunet!cis.ohio-state.edu!pacific.mps.ohio-state.edu!pacific.mps.ohio-state.edu!davis
- From: davis@pacific.mps.ohio-state.edu ("John E. Davis")
- Subject: generic interpreter
- Message-ID: <DAVIS.92Aug16160709@pacific.mps.ohio-state.edu>
- Sender: news@pacific.mps.ohio-state.edu
- Nntp-Posting-Host: pacific.mps.ohio-state.edu
- Reply-To: davis@pacific.mps.ohio-state.edu (John E. Davis)
- Organization: "Dept. of Physics, The Ohio State University"
- Date: Sun, 16 Aug 1992 21:07:09 GMT
- Lines: 43
-
- Hi,
-
- I am looking for an extensible interpreter (preferably in C). I want an
- interpreter which has all the code in it for while loops, if then statements,
- etc. All I need to do is to add the `intrinsic' (in C) functions which the
- interpreter will eventually call. This seems like such a useful generic thing
- that someone must have done it already. If such a thing exists, I would
- appreciate about hearing about it.
-
- I wrote something like this for a stack based calculator a year ago. But
- since I wrote it from scratch I suspect it is not very elegant and it is
- probably slow. The calculator lets the user to define variable and functions.
- This calculator also allows looping and conditional branching. For exaample,
- here is the code for the factorial function in the calculator language:
-
- ( dup 1 - ;; entry stack consists of [n-1, n,...]
-
- {
- dup 2 exchn ;; bury a copy for later pulling product to top
- *
- exch ;; perform product and exchange for buried copy
- 1 - ;; decrement and loop until this goes 0 or negative
-
- } while ;; while always removes top element upon exiting
- ) !
-
-
- The syntax for the function definition is
-
- ( statement_1 statement_2 ... statement_n ) function_name
-
- (By the way, if there is want the source code for this calculator, let me know
- and I will post it. The C soource is only 650 lines long.)
-
- Thanks,
- --
- _____________
- #___/John E. Davis\_________________________________________________________
- #
- # internet: davis@amy.tch.harvard.edu
- # bitnet: davis@ohstpy
- # office: 617-735-6746
- #
-