Todalu (Kannada for Lisp), is my attempt to write an interpreter for a lisp like language.
git clone https://github.com/sooriravindra/Todalu.git
mkdir Todalu/build; cd Todalu/build
cmake ..
cmake --build .
./todalu # Interactive
./todalu ../testscripts/hello-world.tdl
#Alternatively, copy todalu to $PATH
sudo ln -s /usr/bin/todalu $(readlink -f todalu) # Step 1: setup todalu
todalu # To run an interactive session
../testscripts/hello-world.tdl # To run a script (Check shebang if it doesn't work)
$ ./todalu todalu> (+ 20 22) => 42 todalu> (- (* 50 2) (/ 40 2) 30) => 50 todalu> (def myvar (+ 1 2 3)) => 6 todalu> (def is-odd (lambda x (eq? (% x 2) 1))) => <lambda=94877095594064> todalu> todalu> (if (is-odd myvar) (println "That's odd") (println "All good")) All good => "All good" todalu> (range 1 6) => ( 1 2 3 4 5 ) todalu> (filter is-odd (range 1 11)) => ( 1 3 5 7 9 ) todalu> => (progn (print "Enter a number: ") (+ 4 (read))) Enter a number: 10 => 14
keyword | intepret | compile |
---|---|---|
+ | yes | yes |
- | yes | yes |
* | yes | yes |
/ | yes | yes |
eq? | yes | yes |
list? | yes | yes |
int? | yes | yes |
bool? | yes | yes |
dec? | yes | yes |
string? | yes | yes |
> | yes | yes |
progn | yes | yes |
yes | partial | |
println | yes | partial |
quote | yes | yes |
eval | yes | no |
exit | yes | yes |
readstr | yes | no |
read | yes | no |
car | yes | yes |
cdr | yes | yes |
cons | yes | yes |
lambda | yes | yes |
def | yes | yes |
if | yes | yes |