Around June 2021, I saw a post called build your own lisp shared on hacker news on Twitter. This piqued my interest as I've always eager to learn about compilers. So I followed the book and wrote a very simple and stupid Lisp interpreter in C. I didn't stop there, because this little program was full of bugs like memory leaks and illegal pointer accesses.
So I started to refactor it in c++ and finally as my knowledge grew I completely rewrote it ! It is now a complete C++ project containing no C code or anything in build your own lisp !
- A complier that support C++20
- cmake
- make
mkdir build && cd build
cmake ../
make
sudo make install # This install jisp in your system
make test
Jisp supports two modes, just like Python.
When you just type jisp
in the terminal, you will enter interaction mode.
Or you can execute a jisp file by typing jisp file.jun
.
Jisp is a dynamic type language, you can change the type of a variable at runtime.
We support three types now:
- Number(32 bit integer)
- String
- Boolean
(def x 1)
(def x "Hello, world!")
(def x true)
(fn func [x y]
( + x y)
)
(func (1 2))
(if (true)
(* 6 8)
( + 12 30)
)
We only support while
loop now.
(def x 1)
(def y 1)
(while
(<= x 10)
(
( += x 1 )
( *= y 1 )
y
)
)
More examples can be found in example/
directory.
Jisp is just a simple toy for myself, honestly saying it's far from done.
Here is a TODO list, I may implement these if I can.
- Add error handling.
- Add some builtin functions like
print
,head
,tail
and etc. - Add a VM?