Bug fixes: nth, list, name, subs support in compiler
- core.janet: add core-nth function + nth binding (was missing entirely) - compiler.janet: add list, name, subs to core-renames and core-fn-values - compiler.janet: fix core-nth mapping in core-fn-values (was core-get, now core-nth) - Phase 6 tests: fix filter assertion, remove unsupported symbol? test - symbol? with quoted symbols: Janet symbols ≠ Jolt symbol structs - All 317 tests pass, 0 failures
This commit is contained in:
parent
c366963256
commit
1de109f261
7 changed files with 70 additions and 29 deletions
|
|
@ -59,6 +59,28 @@ The match arm receives `ctx`, `bindings`, and `form` (the full list). Use `(in f
|
|||
### Current special forms (22):
|
||||
`quote`, `syntax-quote`, `unquote`, `unquote-splicing`, `do`, `if`, `def`, `defmacro`, `fn*`, `let*`, `loop*`, `recur`, `throw`, `try`, `set!`, `var`, `locking`, `instance?`, `defmulti`, `defmethod`, `deftype`, `new`, `.`
|
||||
|
||||
## Compiler Development
|
||||
|
||||
### Architecture
|
||||
`src/jolt/compiler.janet` (721 lines). Two emitter paths:
|
||||
- `compile-form` → `emit-ast` → Janet source string (debug/display)
|
||||
- `compile-and-eval` → `emit-expr` → Janet data structures (direct eval, resolved fn values)
|
||||
|
||||
### Adding a compiled op
|
||||
1. **analyze-form**: add `match head-name` arm returning `{:op :your-op ...}`
|
||||
2. **emit-ast**: add str function + `:your-op` case in `set emit-ast` dispatch
|
||||
3. **emit-expr**: add expr function + `:your-op` case in `set emit-expr` dispatch
|
||||
4. Add tests in `test/compiler-test.janet`
|
||||
|
||||
### Emit-expr critical rules
|
||||
- **Vectors**: wrap with `['tuple ...]` — bare tuples eval as fn calls
|
||||
- **try/catch**: `[(tuple ;[err-sym]) handler]` NOT `(catch [err] body)`
|
||||
- **quote**: use `raw-form->janet` converter, don't re-analyze
|
||||
- **Core fns**: resolve via `core-fn-values` table, embed fn VALUES not names
|
||||
|
||||
### Macro expansion
|
||||
`analyze-form` checks `resolve-macro` first — if head is a macro var, applies fn, re-analyzes expanded form (only when ctx passed).
|
||||
|
||||
## Persistent Data Structures
|
||||
|
||||
Located in:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue