From 6e38bc776db988a56532e4a662a235d5d9bde52a Mon Sep 17 00:00:00 2001 From: Luis <42945842+ldiaz94@users.noreply.github.com> Date: Sun, 11 Oct 2026 10:54:40 +0100 Subject: [PATCH] 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. --- diff --git a/CLAUDE.md b/CLAUDE.md index 82ccfe6..9246ef2 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -24,10 +24,13 @@ exactly as written. `make check` must pass before every commit. Tests: `test/run/X.raz` -with `X.expect` (stdout), optional `X.status` and `X.args`; modules they -import in `test/run/mods`. `test/err/X.raz` must fail to compile with -the text in `X.err`. `test/pretty/X.raz` must format to `X.expect`. -Examples in `examples/` work the same way. +with `X.expect` (stdout), optional `X.status`, `X.stderr` and +`X.args`; modules they import in `test/run/mods`. `test/err/X.raz` +must fail to compile with the text in `X.err` (all of standard error), +given the compiler options in `X.args` if there is one. +`test/pretty/X.raz` must format to `X.expect`. Examples in `examples/` +work the same way, compiled with `-Werror`, as are the tools and the +library's tests: they must have no warnings. ## How we work @@ -57,8 +60,10 @@ ravite (vim's). What they needed of the system went into `Sys` (report 2026-10.2, approved): the terminal, files, directories and the environment. `tools/Scan.raz` is theirs to use, as a tool, not part of -the library. Stage 4, diagnostics (steps 19-27), is under way: -steps 19-25 are done. New work starts only on the owner's word. Keep +the library. Stage 4, diagnostics (steps 19-27), is done. Planned and +not started: stage 6, the language of report 2026-10.3, +and stage 7, `Sys` for rlX11 and rat (report 2026-10.4, for review). +New work starts only on the owner's word. Keep `doc/compiler.md`'s table of lines and its routine names true when the compiler changes. Left for later at the owner's word: a rewrite of var parameters. @@ -113,6 +118,16 @@ ones are left as they fall. - `Heap` and `Out` lock with `Lock`, a spinlock that yields, since they serve C's threads and `Thread`'s alike; `Thread.Mutex` is a futex. -- Every failed check says "index out of range"; some errors point at - the symbol after the offending expression. Error messages are to be - improved later, all together. +- A failed check says what failed and with what values, at the place + of the offending expression. A signal is told at the place of the + statement it stopped in, or of the procedure for a stack overflow in + its prologue. The handlers run on a stack of `Rt`'s, which threads + made by `Thread` don't have: a stack overflow in one of them ends it + by the signal with no message. +- The smallest `I64` divided by -1 traps (SIGFPE), as 6.1 says. +- Warnings come only for a module with no errors. A procedure naming + itself doesn't use it; a type named by a pointer in its own + declaration does. An enumeration's names are never warned of, nor a + generic module's parameters; a generic module is warned of in its + first instance only. Assigning a variable whole (`x :=`, `a, b :=`) + doesn't read it; anything else does. diff --git a/PLAN.md b/PLAN.md index e0f3039..1f557a9 100644 --- a/PLAN.md +++ b/PLAN.md @@ -277,7 +277,7 @@ (6.1), and is told as a division fault. The compiler and `Rt`, *main*; the tests, *agent*. -- [ ] 27. `doc/compiler.md` (its table and routine names), `README.md` +- [x] 27. `doc/compiler.md` (its table and routine names), `README.md` and `CLAUDE.md` brought up to date; `make loc` within 6,000 and 10%, `make bench` at 400,000 lines a second. *agent*, checked by *main*. diff --git a/README.md b/README.md index 801ac45..21d3f60 100644 --- a/README.md +++ b/README.md @@ -24,7 +24,7 @@ $ examples/Hello hello, world -The compiler is under 5,000 lines of Free Pascal: one pass, no +The compiler is under 6,000 lines of Free Pascal: one pass, no intermediate form, no optimizer. It writes x86-64 machine code and the ELF executable itself, with no assembler or linker, and compiles about a million lines a second. @@ -77,9 +77,21 @@ in the main module's directory, then in each `-I` directory, then in `lib`. A module whose code depends on the system comes in one file per target, `Name.linux-x86_64.raz` before `Name.raz`; the compiler checks -that all of them export the same things. `-Werror` makes warnings -errors. +that all of them export the same things. +An error is shown with its file, line and column, the line of source +underlined, and notes and help where they help: where a name is +declared, a name spelled almost alike. The compiler goes on to find +the others, up to 20. It warns of what is declared and never used, +and of a variable assigned but never read, unless its name starts with +`_`; `-Werror` makes warnings errors. + +At run time, a failed check says where it is and what failed, as in +`Main.raz:12:9: index 7 is out of range for a length of 5`, and ends +the program with status 2. A program stopped by a signal says where it +was and why first: a `nil` pointer, a `nil` procedure, a stack +overflow, a bad address or a division fault. + `raz run Main.raz a b` compiles the same way, then runs the program with the arguments `a b`, writing no file: its output and exit status are the command's. @@ -107,11 +119,11 @@ - `extern` procedures and variables from C; code procedures written as bytes of machine code; `SYSCALL`. -The report, `doc/raz.md`, says all of it in about 900 lines. +The report, `doc/raz.md`, says all of it in about 1,000 lines. ## The library -`Rt` (ending the program, checks), `Sys` (system calls), `Out` +`Rt` (ending the program, failed checks, signals), `Sys` (system calls), `Out` (buffered output), `C`, `Lock`, `Thread` (threads without C), `Mem`, `Heap`, `Arena`, `Str`, `Buf`, `Fmt`, `List(T)` and `Map(K, V; hash, eq)`. `tools/Doc.raz` prints any of them: diff --git a/test/genbench.py b/test/genbench.py index 9a8a3df..2da5cf9 100644 --- a/test/genbench.py +++ b/test/genbench.py @@ -15,7 +15,7 @@ g: [16]I64; data: [64]I64; """) -print("""proc p0(a, b: I64; s: []I64): I64; +print("""proc p0(a, b: I64; _s: []I64): I64; begin return a + b; end;