nondescript/README.md

38 lines
1.2 KiB
Markdown
Raw Normal View History

2022-01-20 21:55:17 +01:00
# nondescript
2022-01-21 01:51:55 +01:00
2022-01-27 04:18:31 +01:00
Nondescript is a nim implementation of lox (see https://craftinginterpreters.com) with large deviations.
2022-01-21 01:51:55 +01:00
2022-01-27 04:18:31 +01:00
## Deviations from lox
2022-01-21 01:51:55 +01:00
2022-01-27 04:18:31 +01:00
- 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
2022-01-21 01:51:55 +01:00
2022-01-27 04:18:31 +01:00
## Examples
2022-01-21 01:51:55 +01:00
2022-01-27 04:18:31 +01:00
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
2022-01-28 22:00:21 +01:00
./build.sh
2022-01-27 04:18:31 +01:00
./nds
```