Skip to content

sooriravindra/Todalu

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

66 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Todalu

Todalu (Kannada for Lisp), is my attempt to write an interpreter for a lisp like language.

Build

git clone https://github.com/sooriravindra/Todalu.git
mkdir Todalu/build; cd Todalu/build
cmake ..
cmake --build .

Install and run

./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)

Sample interaction

$ ./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

Built-ins and support

keywordintepretcompile
+yesyes
-yesyes
*yesyes
/yesyes
eq?yesyes
list?yesyes
int?yesyes
bool?yesyes
dec?yesyes
string?yesyes
>yesyes
prognyesyes
printyespartial
printlnyespartial
quoteyesyes
evalyesno
exityesyes
readstryesno
readyesno
caryesyes
cdryesyes
consyesyes
lambdayesyes
defyesyes
ifyesyes

About

A lisp interpreter in C++

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages