A toy Lisp/Scheme interpreter in OCaml.
Make sure that you have dune
and opam
ready.
dune --version
# 3.7.1
opam --version
# 2.1.3
Install dependencies:
...
Run the binary:
dune exec camlisp
Test the REPL:
=> 1
1
=> (define x 1)
1
=> (+ x 1)
2
=> (define (fact n)
.. (if (= n 1)
.. 1
.. (* n (fact (- n 1)))))
(lambda (n) (if (= n 1) 1 (* n (fact (- n 1)))))
=> (fact 5)
120
=> (define (fact-iter n)
.. (define (iter result n)
.. (if (= n 1)
.. result
.. (iter (* result n) (- n 1))))
.. (iter 1 n))
(lambda ...)
=> (fact-iter 5)
120
Run unit tests:
dune test
- Implement
+
,-
,*
, and/
- Redefine the underlying type to make the operators work for both
int
andfloat
- Find a strategy to turn the operators into a "normal"
Func
?
- Redefine the underlying type to make the operators work for both
- Implement
lambda
- Add dot notation
- Implement
define
- Add dot notation
- Implement
cons
,car
andcdr
- Implement
quote
- Implement
let
andlet*
(done sincelet
acts likelet*
in this case for the wayenv
works) - Implement
set!
- Implement
eval
andapply
- Research how to release/distribute the built binary
- Improve error handling by separating user's error to internal evaluator error
- Implement a "proper" CLI experience:
- Interactive mode
--interactive
- Interactive mode with files preloading
- Compiling
- Interactive mode
- Add tests
-
Tokenizer.is_balance
-
Tokenizer.tokenize
-
Parser.parse_expr
-
Parser.parse_lambda
-
Parser.parse_define
-
Parser.parse_if
-
Parser.parse_let
-
Parser.parse_one
-
Parser.parse
-
Evaluator.compare_nodes
-
Evaluator.is_self_eval
-
Evaluator.try_eval_int
-
Evaluator.make_operator_handler
-
Evaluator.apply
-
Evaluator.eval
-