https://github.com/threez/rlisp
Ruby implementation of a lisp
https://github.com/threez/rlisp
Last synced: over 1 year ago
JSON representation
Ruby implementation of a lisp
- Host: GitHub
- URL: https://github.com/threez/rlisp
- Owner: threez
- Created: 2010-03-11T23:13:26.000Z (over 16 years ago)
- Default Branch: master
- Last Pushed: 2010-04-29T21:56:38.000Z (about 16 years ago)
- Last Synced: 2025-02-07T08:12:40.922Z (over 1 year ago)
- Language: Ruby
- Homepage:
- Size: 95.7 KB
- Stars: 4
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README
Awesome Lists containing this project
README
This is an simple LISP-interpreter witten in ruby.
Given a Lisp Expression like this:
(+ (* 3 4) 2)
The Lexer will produce:
[:+ [:* 3 4] 2]
Ruby symbols are LISP atoms and arrays are lists.
The interpreter evals the whole list and executes the apply method
on the functions.
The build-in functions are the functions that are attached to the interpreter
class. To bootstrap the interpreter the Core and Math modules (of helper.rb)
are included in the interpreter class. This makes Ruby integration rather
simple. Just include your ruby modules in the interpreter.
Using the interpreter by using the classes:
l = Lisp::Lexer.new
p = Lisp::Parser.new
l.tokenize("test.lisp", p)
i = Lisp::Interpreter.new
i.start p.node
Evaluate a file:
i = Lisp::Interpreter.new
i.import("my_lisp_file.lisp")
Or just start the command line interface with REPL (read eval print loop):
./bin/rlisp