Stage 4 done: README, CLAUDE.md and the plan brought up to date README: errors, warnings and -Werror, failed checks and signals; the compiler under 6,000 lines, the report about 1,000. CLAUDE.md: where things stand, X.stderr and test/err's X.args, -Werror on examples, tools and lib; the readings of stage 4 in place of "index out of range". genbench's base case names its unused param _s. make loc: 5,827 lines of code; make bench: 1.1M lines a second.
| @@ -24,10 +24,13 @@ | ||
| 24 | 24 | exactly as written. |
| 25 | 25 | |
| 26 | 26 | `make check` must pass before every commit. Tests: `test/run/X.raz` |
| 27 | -with `X.expect` (stdout), optional `X.status` and `X.args`; modules they | |
| 28 | -import in `test/run/mods`. `test/err/X.raz` must fail to compile with | |
| 29 | -the text in `X.err`. `test/pretty/X.raz` must format to `X.expect`. | |
| 30 | -Examples in `examples/` work the same way. | |
| 27 | +with `X.expect` (stdout), optional `X.status`, `X.stderr` and | |
| 28 | +`X.args`; modules they import in `test/run/mods`. `test/err/X.raz` | |
| 29 | +must fail to compile with the text in `X.err` (all of standard error), | |
| 30 | +given the compiler options in `X.args` if there is one. | |
| 31 | +`test/pretty/X.raz` must format to `X.expect`. Examples in `examples/` | |
| 32 | +work the same way, compiled with `-Werror`, as are the tools and the | |
| 33 | +library's tests: they must have no warnings. | |
| 31 | 34 | |
| 32 | 35 | ## How we work |
| 33 | 36 | |
| @@ -57,8 +60,10 @@ | ||
| 57 | 60 | ravite (vim's). What they needed of the system went into `Sys` (report |
| 58 | 61 | 2026-10.2, approved): the terminal, files, directories and the |
| 59 | 62 | environment. `tools/Scan.raz` is theirs to use, as a tool, not part of |
| 60 | -the library. Stage 4, diagnostics (steps 19-27), is under way: | |
| 61 | -steps 19-25 are done. New work starts only on the owner's word. Keep | |
| 63 | +the library. Stage 4, diagnostics (steps 19-27), is done. Planned and | |
| 64 | +not started: stage 6, the language of report 2026-10.3, | |
| 65 | +and stage 7, `Sys` for rlX11 and rat (report 2026-10.4, for review). | |
| 66 | +New work starts only on the owner's word. Keep | |
| 62 | 67 | `doc/compiler.md`'s table of lines and its routine names true when the |
| 63 | 68 | compiler changes. Left for later at the owner's word: a rewrite of |
| 64 | 69 | var parameters. |
| @@ -113,6 +118,16 @@ | ||
| 113 | 118 | ones are left as they fall. |
| 114 | 119 | - `Heap` and `Out` lock with `Lock`, a spinlock that yields, since they |
| 115 | 120 | serve C's threads and `Thread`'s alike; `Thread.Mutex` is a futex. |
| 116 | -- Every failed check says "index out of range"; some errors point at | |
| 117 | - the symbol after the offending expression. Error messages are to be | |
| 118 | - improved later, all together. | |
| 121 | +- A failed check says what failed and with what values, at the place | |
| 122 | + of the offending expression. A signal is told at the place of the | |
| 123 | + statement it stopped in, or of the procedure for a stack overflow in | |
| 124 | + its prologue. The handlers run on a stack of `Rt`'s, which threads | |
| 125 | + made by `Thread` don't have: a stack overflow in one of them ends it | |
| 126 | + by the signal with no message. | |
| 127 | +- The smallest `I64` divided by -1 traps (SIGFPE), as 6.1 says. | |
| 128 | +- Warnings come only for a module with no errors. A procedure naming | |
| 129 | + itself doesn't use it; a type named by a pointer in its own | |
| 130 | + declaration does. An enumeration's names are never warned of, nor a | |
| 131 | + generic module's parameters; a generic module is warned of in its | |
| 132 | + first instance only. Assigning a variable whole (`x :=`, `a, b :=`) | |
| 133 | + doesn't read it; anything else does. |
| @@ -277,7 +277,7 @@ | ||
| 277 | 277 | (6.1), and is told as a division fault. |
| 278 | 278 | The compiler and `Rt`, |
| 279 | 279 | *main*; the tests, *agent*. |
| 280 | -- [ ] 27. `doc/compiler.md` (its table and routine names), `README.md` | |
| 280 | +- [x] 27. `doc/compiler.md` (its table and routine names), `README.md` | |
| 281 | 281 | and `CLAUDE.md` brought up to date; `make loc` within 6,000 and |
| 282 | 282 | 10%, `make bench` at 400,000 lines a second. *agent*, checked by |
| 283 | 283 | *main*. |
| @@ -24,7 +24,7 @@ | ||
| 24 | 24 | $ examples/Hello |
| 25 | 25 | hello, world |
| 26 | 26 | |
| 27 | -The compiler is under 5,000 lines of Free Pascal: one pass, no | |
| 27 | +The compiler is under 6,000 lines of Free Pascal: one pass, no | |
| 28 | 28 | intermediate form, no optimizer. It writes x86-64 machine code and the |
| 29 | 29 | ELF executable itself, with no assembler or linker, and compiles about |
| 30 | 30 | a million lines a second. |
| @@ -77,9 +77,21 @@ | ||
| 77 | 77 | in the main module's directory, then in each `-I` directory, then in |
| 78 | 78 | `lib`. A module whose code depends on the system comes in one file per |
| 79 | 79 | target, `Name.linux-x86_64.raz` before `Name.raz`; the compiler checks |
| 80 | -that all of them export the same things. `-Werror` makes warnings | |
| 81 | -errors. | |
| 80 | +that all of them export the same things. | |
| 82 | 81 | |
| 82 | +An error is shown with its file, line and column, the line of source | |
| 83 | +underlined, and notes and help where they help: where a name is | |
| 84 | +declared, a name spelled almost alike. The compiler goes on to find | |
| 85 | +the others, up to 20. It warns of what is declared and never used, | |
| 86 | +and of a variable assigned but never read, unless its name starts with | |
| 87 | +`_`; `-Werror` makes warnings errors. | |
| 88 | + | |
| 89 | +At run time, a failed check says where it is and what failed, as in | |
| 90 | +`Main.raz:12:9: index 7 is out of range for a length of 5`, and ends | |
| 91 | +the program with status 2. A program stopped by a signal says where it | |
| 92 | +was and why first: a `nil` pointer, a `nil` procedure, a stack | |
| 93 | +overflow, a bad address or a division fault. | |
| 94 | + | |
| 83 | 95 | `raz run Main.raz a b` compiles the same way, then runs the program |
| 84 | 96 | with the arguments `a b`, writing no file: its output and exit status |
| 85 | 97 | are the command's. |
| @@ -107,11 +119,11 @@ | ||
| 107 | 119 | - `extern` procedures and variables from C; code procedures written as |
| 108 | 120 | bytes of machine code; `SYSCALL`. |
| 109 | 121 | |
| 110 | -The report, `doc/raz.md`, says all of it in about 900 lines. | |
| 122 | +The report, `doc/raz.md`, says all of it in about 1,000 lines. | |
| 111 | 123 | |
| 112 | 124 | ## The library |
| 113 | 125 | |
| 114 | -`Rt` (ending the program, checks), `Sys` (system calls), `Out` | |
| 126 | +`Rt` (ending the program, failed checks, signals), `Sys` (system calls), `Out` | |
| 115 | 127 | (buffered output), `C`, `Lock`, `Thread` (threads without C), `Mem`, |
| 116 | 128 | `Heap`, `Arena`, `Str`, `Buf`, `Fmt`, `List(T)` and `Map(K, V; hash, |
| 117 | 129 | eq)`. `tools/Doc.raz` prints any of them: |
| @@ -15,7 +15,7 @@ | ||
| 15 | 15 | g: [16]I64; |
| 16 | 16 | data: [64]I64; |
| 17 | 17 | """) |
| 18 | -print("""proc p0(a, b: I64; s: []I64): I64; | |
| 18 | +print("""proc p0(a, b: I64; _s: []I64): I64; | |
| 19 | 19 | begin |
| 20 | 20 | return a + b; |
| 21 | 21 | end; |