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
|
|
@ -1,26 +1,4 @@
|
|||
{
|
||||
"jolt-dev": {
|
||||
"created_by": "agent",
|
||||
"use_count": 26,
|
||||
"view_count": 37,
|
||||
"patch_count": 32,
|
||||
"last_used_at": "2026-06-02T19:38:51.833410+00:00",
|
||||
"last_viewed_at": "2026-06-02T19:38:51.825602+00:00",
|
||||
"last_patched_at": "2026-06-02T19:39:44.919664+00:00",
|
||||
"created_at": "2026-06-01T21:26:06.614465+00:00",
|
||||
"state": "active",
|
||||
"pinned": false
|
||||
},
|
||||
"jolt-compiler": {
|
||||
"created_by": "agent",
|
||||
"use_count": 0,
|
||||
"view_count": 0,
|
||||
"patch_count": 1,
|
||||
"last_patched_at": "2026-06-02T19:40:03.526270+00:00",
|
||||
"created_at": "2026-06-02T17:54:38.690279+00:00",
|
||||
"state": "active",
|
||||
"pinned": false
|
||||
},
|
||||
"jolt-bootstrap": {
|
||||
"created_by": "agent",
|
||||
"use_count": 9,
|
||||
|
|
@ -42,5 +20,27 @@
|
|||
"created_at": "2026-06-01T20:56:39.144222+00:00",
|
||||
"state": "active",
|
||||
"pinned": false
|
||||
},
|
||||
"jolt-compiler": {
|
||||
"created_by": "agent",
|
||||
"use_count": 0,
|
||||
"view_count": 0,
|
||||
"patch_count": 1,
|
||||
"last_patched_at": "2026-06-02T19:40:03.526270+00:00",
|
||||
"created_at": "2026-06-02T17:54:38.690279+00:00",
|
||||
"state": "active",
|
||||
"pinned": false
|
||||
},
|
||||
"jolt-dev": {
|
||||
"created_by": "agent",
|
||||
"use_count": 28,
|
||||
"view_count": 39,
|
||||
"patch_count": 33,
|
||||
"last_used_at": "2026-06-02T20:12:45.918073+00:00",
|
||||
"last_viewed_at": "2026-06-02T20:12:45.904425+00:00",
|
||||
"last_patched_at": "2026-06-02T20:13:13.431432+00:00",
|
||||
"created_at": "2026-06-01T21:26:06.614465+00:00",
|
||||
"state": "active",
|
||||
"pinned": false
|
||||
}
|
||||
}
|
||||
|
|
@ -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