An interpreter for a custom lisp dialect.
The core language should be as simple as possible, complex features should be implemented in terms of the primitives where possible and reasonable. Let can be implemented with lambda, loops can be implemented with recusion, etc.
This lisp is intended to be similar to Emacs lisp, but functions and values are unified into a single namespace like in scheme.
There is only one equality function, “=”, no eq, eql, equal, etc.
This language is very unstable and many things are not implemented yet.
NOTE: You will need rust’s nightly toolchain installed to build this project.
git clone https://github.com/Jturnerusa/lisp
cd lisp
cargo build
Currently, the core lib is passed as an environment variable.
export CARPET_LISP_PATH="$PWD/lib/lisp"
Sample lisp for testing:
(require list) (def fib (lambda (n) (if (< n 2) n (+ (fib (- n 1)) (fib (- n 2)))))) (named-let loop ((n 1)) (print (fib n)) (if (< n 10) (loop (+ n 1)) nil))
Run the sample:
cargo run --bin eval sample.lisp
This should result in a fibonaci sequence up to 10 indices:
1 1 2 3 5 8 13 21 34 55
List of native functions:
+
-
*
/
cons
car
cdr
list
apply
cons?
function?
symbol?
string?
int?
char?
nil?
apply
lambda
defmacro
def
set!
eval-when-compile
quote
if
- ===
>
<
assert
decl
map-create
map-insert!
map-retrieve
map-items
module
export
require
- Native Functions (string slicing, utils, etc.)
- control flow graph for type system