Document the interpreter's architecture as chapter fourteen
Some checks failed
akbasic CI Build / cmake_build (push) Successful in 3m2s
akbasic CI Build / sanitizers (push) Successful in 3m50s
akbasic CI Build / coverage (push) Failing after 3m22s
akbasic CI Build / akgl_build (push) Failing after 20s
akbasic CI Build / mutation_test (push) Successful in 12m19s
Some checks failed
akbasic CI Build / cmake_build (push) Successful in 3m2s
akbasic CI Build / sanitizers (push) Successful in 3m50s
akbasic CI Build / coverage (push) Failing after 3m22s
akbasic CI Build / akgl_build (push) Failing after 20s
akbasic CI Build / mutation_test (push) Successful in 12m19s
Chapters 1 through 13 describe the language. Nothing described the machine that runs it, and the answers were spread across header comments, TODO.md sections written for a different purpose, and the source itself. Somebody embedding the interpreter, debugging something it did, or adding a verb had to reconstruct the shape from all three. docs/14-architecture.md is that shape, and only that: the three targets and the driver, the single akbasic_Runtime and why nothing is file-scope, akbasic_runtime_step() unrolled with the reason each stage sits where it does, the four modes and what set_mode() does beyond assigning, a line's journey from text through tokens and leaves to a verb handler, the dispatch table, the pool map with what each exhaustion actually says, environments doubling as block state, the two kinds of error, devices, and interrupts. It defers rather than restates. The headers are the authority on every function's contract and the chapter says so up front; where a rule is subtle the header comment already states it at more length than a chapter should. MAINTENANCE.md keeps the conventions and now points here for the mechanism, so there is still one copy of each. Two sections are the reason it exists at all. Debugging: reading a TRON trace as evidence about the loop rather than the lines, reading an akerror stack trace and what it is not, four breakpoints and the expressions worth printing at them, narrowing with ctest -R and the mock devices, and a symptom-to-cause table. Changing it: the verb recipe end to end including the private src/verbs.h prototype that is easy to miss, the rule that a missing dependency capability gets filed upstream rather than worked around, and the five constraints goal 3 puts on any change. A `text` fence tag comes with it. Every fenced block in docs/ is executed and an untagged one is a hard error, so six block diagrams had nowhere to live. The tag means never executed, it is counted in the skip line like `cmake`, and MAINTENANCE.md documents it -- the alternative was an indented block the extractor never sees, and a picture nobody decided about is indistinguishable from a test nobody ran. tests/docs_examples.sh now makes --root and --basic absolute before it starts. Both are used from inside a sandbox directory it cd's into, so the invocation MAINTENANCE.md itself documents -- --root . --basic ./build/basic -- failed every example with "exited 127" and every setup= with "setup failed". CTest passes absolute paths and never saw it; running one document by hand hits it immediately. Writing the error section turned up a defect and TODO.md section 8 records it. The ATTEMPT blocks that turn a script's mistake into an error line wrap parsing and interpretation but not scanning, so a line with more than 32 tokens escapes as an interpreter error: stack trace, exit 1, and at a prompt the REPL is gone. That is the same shape as section 8 item 2, on a path that fix did not cover. Not fixed here -- it is a behaviour change and wants its own tests -- but written down with the three call sites and what would cover them. Both configurations stay green: 95/95 and 94/94. docs_examples now runs 37 programs, 9 transcripts, 45 output comparisons, 3 C snippets, 2 excerpts and 2 shell blocks, and skips 9 text blocks. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -8,6 +8,11 @@ enforced by nothing at all and therefore written down here.
|
||||
`CLAUDE.md` is for agents, and it is deliberately thin: it points here. Everything an agent
|
||||
is told about this project is in this file, so there is one copy to keep true.
|
||||
|
||||
One thing is deliberately *not* here. **How the interpreter actually works — the step loop,
|
||||
the four modes, the pools, the scopes that double as block state, the two kinds of error,
|
||||
and how to debug all of it — is [`docs/14-architecture.md`](docs/14-architecture.md).** This
|
||||
file is the conventions for changing the thing; that chapter is the thing.
|
||||
|
||||
---
|
||||
|
||||
## What this project is
|
||||
@@ -570,9 +575,16 @@ a missing decision rather than a free pass.
|
||||
| `sh setup=NAME` | The same, after `tests/docs_setups/NAME.sh` |
|
||||
| `sh norun` | Shown, not run |
|
||||
| `cmake` | **Never executed.** Hand-maintained, by decision |
|
||||
| `text` | **Never executed.** A block diagram, or a stack trace captured from a real run |
|
||||
|
||||
Attributes combine: `basic requires=akgl setup=ship` is a real tag in `docs/08-sprites.md`.
|
||||
|
||||
`text` exists because `docs/14-architecture.md` needed block diagrams and an untagged block
|
||||
is a hard error. It carries no executable claim, which is exactly why it has to be *said*:
|
||||
the alternative was an indented code block that the extractor never sees, and a picture
|
||||
nobody decided about is indistinguishable from a test nobody ran. Keep the diagrams inside
|
||||
about 88 columns so they do not wrap on a forge.
|
||||
|
||||
### Which one to reach for
|
||||
|
||||
- **A program with visible output** — `basic` plus an `output` block. Preferred: it is the
|
||||
@@ -589,6 +601,8 @@ Attributes combine: `basic requires=akgl setup=ship` is a real tag in `docs/08-s
|
||||
`output` block. Refusals carry a trailing blank line; the block has to have it too.
|
||||
- **`norun`** — for a fragment (`60 DATA 255, 129, ...`), an infinite loop, or a command
|
||||
that would reconfigure the tree the suite is running inside. Say why in the prose.
|
||||
- **A diagram or a captured trace** — `text`. Nothing is checked, so anything in one that
|
||||
*could* be checked belongs in a block that is.
|
||||
|
||||
### `sh` blocks: what is not run, and why
|
||||
|
||||
@@ -648,6 +662,11 @@ Run one document at a time while you work:
|
||||
--cflags-file build/docs_cflags.txt docs/04-control-flow.md
|
||||
```
|
||||
|
||||
`--root` and `--basic` are made absolute by the script before it starts, because both are
|
||||
used from inside a sandbox directory it `cd`s into. Relative ones used to fail every
|
||||
example with `exited 127` and every `setup=` with "setup failed" — invisible under CTest,
|
||||
which passes absolute paths, and immediate for anyone running one document by hand.
|
||||
|
||||
The pass line reports **what it executed, by kind**. Read it. A harness that passes because
|
||||
it stopped matching anything looks exactly like a harness that passes because the
|
||||
documentation is correct, and the count is the only thing that tells them apart — it has
|
||||
|
||||
Reference in New Issue
Block a user