ded7fd3211 | ||
---|---|---|
benchmarks | ||
tests | ||
types | ||
.gitignore | ||
LICENSE | ||
README.md | ||
build.sh | ||
chunk.nim | ||
compiler.nim | ||
config.nim | ||
debug.sh | ||
main.nim | ||
pointerutils.nim | ||
scanner.nim | ||
value.nim | ||
vm.nim |
README.md
nondescript
Nondescript is a nim implementation of lox (see https://craftinginterpreters.com) with large deviations.
Deviations from lox
- NOT SOURCE COMPATIBLE WITH LOX
- Everything is an expression, except variable declarations and break statements
- hence expressions can contain statements, so the stack is tracked inside the compiler, using compiler.stackCount
- uses different local representation than lox inside the compiler
- compiler.addLocal also has a delta argument - check it out if interested
- 1 file = 1 chunk
- function objects are just a pointer to an instruction to jump to (right now instruction index, but this will change)
- constant indexes, local indexes have 2 bytes as arguments
- no object orientation
- closures are not implemented yet
- block expressions can be labelled and break takes a label to break out of
- set block expression results using ^, ^label
- set the return value of functions using ^result
- plans for the far future: defer, tables, lists
Examples
benchmarks/fib.nds
Building
Requirements:
- nim (1.6.2 tested)
- c compiler (gcc, glibc tested)
The 4 steps to a REPL:
git clone https://github.com/prod2/nondescript
cd nondescript
./build.sh
./nds