nondescript/README.md

46 lines
1.4 KiB
Markdown

# nondescript
Nondescript started as a nim implementation of clox (see https://craftinginterpreters.com) but has acquired large deviations.
## Deviations from lox
- closures, gc not implemented yet
- classes will not be implemented
- 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
- constant indexes, local indexes have 2 bytes as arguments - no 256 limit on locals/constants
- block expressions can be labelled (@label) and the break statement takes a label to break out of
- set block expression results using :label
- set the return value of functions using :result
- lists (example: @[1, 4, 5])
- tables (example: @{ "hello" = "world"})
- length operator #
- ampersand operator to chain binary operators to finished expressions
## Examples
See the following folders in the source tree, look for the extension .nds:
- benchmarks/
- examples/
- tests/
## 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
nimble build
bin/nds
```