Chipmunk is a Lisp interpreter with partial support for compiling to JavaScript. It's implemented in TypeScript using the Deno runtime. The goal is to someday achieve self-hosting.
Print the factorials of the numbers 1 to 10:
(do
(def factorial (lambda (x)
(if (= x 0)
1
(* x (factorial (- x 1))))))
(print-line (map factorial (range 10))))
; prints "[1 1 2 6 24 120 720 5040 40320 362880]"
To start a Chipmunk REPL:
deno run src/index.ts
To run a Chipmunk program:
deno run --allow-read src/index.ts examples/game-of-life.ch
To compile a Chipmunk program to JavaScript:
# Unfortunately npm is required in order to use the "source-map" module to generate source maps for the compiled JavaScript
npm install
# Compile to JavaScript
deno run --allow-read --allow-env --allow-write src/compile.ts examples/game-of-life.ch
# Run the compiled JavaScript
deno run examples/game-of-life.js
To run tests:
deno test --allow-read --allow-env
- Visual Studio Code extension (provides syntax highlighting)
- Documentation of core functions
- Source map visualization tool (made by someone else)