This is a interpreter language whose host language is golang.
IMPORTANT This project is based on Writing An Interpreter In Go
let thresholdForAdult = 20;
let user = {
"name": "Tom",
"age": thresholdForAdult + 10
}
let userrole = if (user["age"] >= thresholdForAdult) {
return "ADULT"
} else {
return "CHILD"
}
let showNameIfAdult = fn(user) {
if (userrole == "ADULT") {
puts(user["name"])
}
}
you can find more example in ./examples
directory
$ git clone git@github.com:vsanna/choco.git
$ cd choco
# modify according to your environment
$ echo "export PATH=\"$(pwd):\$PATH\"" >> ~/.zshrc
# to use repl
$ ichoco
# to run yourcode
$ choco your-code.choco
$ rm -f ichoco && cd src/app/repl && go build main.go && mv main ../../../ichoco && cd ../../../
$ rm -f choco && cd src/app/runner && go build main.go && mv main ../../../choco && cd ../../../
TODO: write makefile
- add options for cmdline
- e.g. debug mode
- exntending hash
- make blockstatement return value
- make error messages more informative
this lang is named after one of my dogs, and "ちょこ"っと使える(can be used a little in Japanese) sounds like "Choco".