A simple Scheme interpreter, created as a Haskell exercise project. It only implements a subset of R5RS for now. Needs proper testing still as well.
- Prerequisites: Stack.
- Build it:
$ stack build- Run it:
- As an interactive interpreter:
$ make run
- Use it to run a Scheme (.scm) file:
Args are passed into the program in the file as a list bound to a variable called$ stack exec coco-exe -- FILENAME ARG1 ARG2 ARG3args.
- Lists (:information_desk_person:)
- Dotted Lists
- Numbers (Integers, signed)
- Floats (signed) (Note that type isn't strictly enforced in some operations, like addition, etc)
- Strings
- Bools
- Characters
- Functions
All supported types (and errors) are in the ValueLib module. Numbers can be written as decimals, hexadecimals, octals, or binary, given the proper Scheme notation.
- Primitive patterns (patterns that are the types themselves).
- Quoted types (e.g.
'(1 2 3)) - If conditions.
- Set and define variables (e.g.
(set! x 3)or(define x 3)) - Define functions.
- Lambda functions.
- Load file (e.g.
(load "test.scm")). - Evaluate function (e.g.
(func 1 2)).
+-*/modquotientremaindernumber?string?boolean?list?zero?char?symbol?notlengthsymbol->stringstring->symbollist->stringstring->list=/=<><=>=&&||string=?string>?string<?string<=?string>=?char=?char>?char<?char>=?char<=?conscarcdreq?eqv?make-stringstringstring-lengthstring-refsubstringstring-appendstring-copyapplyopen-input-fileopen-output-fileclose-input-portclose-output-portreadwriteread-contentsread-all
The complete list of built-in functions can be found in primitives and ioPrimitives in the Eval module.
- R5RS (Scheme standard doc)
- Write Yourself a Scheme In 48 Hours (Book)
- Haskell Wiki and official docs in general, to adapt depracated methods/patterns and as a general reference.
