This is an implementation of a Scheme interpreter written in a single file of Ruby.
It is only 140 lines of code, 53 of which are implementing standard library functions -- like cos
to caculate cosine.
Scheme is one of the easiest programming languages to interpret. And Ruby is one of the most expressive and least-terse languages to develop in.
The goal of this repository is to make it as easy as possible to understand how a language intepreter works.
It is not a complete implementation of The R5RS Standard. Notably it is missing pairs and inexact numbers.
As mentioned above, the first iteration of this interpreter was 140 lines of code -- 53 of which implemented standard library functions.
On my machine, it can calculate (fact 1000)
0.00534 seconds. That's fast enough for playing around with, although Ruby can do the same calculation in 0.00038 -- about 15 times faster.
This interpreter is not very complete. Several missing features include:
- Syntax: Missing
#
literals, derived expression typescond
fromif
andlet
fromlambda
, the.
list notation, and numerical constants like3.1415926535F0
,0.6L0
,6/10
,3+4i
. - Symatntics: Missing call/cc and tail recursion.
- Data Types: Missing characters, ports, pairs, and exact/inexact numbers.
- Procedures: Missing several primitive procedures like
complex?
,real?
,rational?
,exact?
, andinexact?
. - Error Recovery: This interpreter has very little error detection, reporting, or error recovery. Good luck [=
- Lis.py - Peter Norvig's Python Lisp Interpreter