https://github.com/schani/forthlisp
A Small Lisp in Forth
https://github.com/schani/forthlisp
Last synced: 3 months ago
JSON representation
A Small Lisp in Forth
- Host: GitHub
- URL: https://github.com/schani/forthlisp
- Owner: schani
- Created: 2017-06-18T04:03:57.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2021-04-21T01:40:53.000Z (about 4 years ago)
- Last Synced: 2025-01-23T15:15:09.398Z (5 months ago)
- Language: Forth
- Size: 3.91 KB
- Stars: 154
- Watchers: 7
- Forks: 13
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Lisp in Forth
This is an interpreter for a really simple dynamically scoped Scheme
dialect. It only runs with
[Gforth](https://www.gnu.org/software/gforth/), because it uses
Gforth's structs to implement its data structures. One of the more
involved parts of this interpreter is the reader, where I had to do
quite a lot of stack juggling to keep everything in line. It doesn't
look very involved now but I remember spending quite some time
thinking about the stack layout for the reader routines.
[Read here](https://news.ycombinator.com/item?id=26884231) why the
way I did it is most certainly wrong.## How to use it
Assuming you have Gforth installed (if you're on MacOS you can get it
via [Brew](https://brew.sh)), start it withgforth lisp.fs
There are mainly three words of interest:
* `lisp-load-from-string` reads and evaluates a string.
* `lisp-load-from-file` reads and evaluates a file, given a filename.
* `lisp-display` prints a lisp value.
Example:
s" (+ 1 2 3)" lisp-load-from-string lisp-display
=> 6 oks" test.scm" lisp-load-from-file lisp-display
=> 4 120 () okIn this example, `4` and `120` are printed in `test.scm`, and `()` is
the result of the evaluation of the file.