raz / commit 6e38bc77

commit
6e38bc776db988a56532e4a662a235d5d9bde52a
author
Luis <42945842+ldiaz94@users.noreply.github.com>
date
parent
389c4f3a
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.

patch · log

4 files changed, +43 -16

CLAUDE.md modified +24 -9

@@ -24,10 +24,13 @@
2424 exactly as written.
2525
2626 `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.
3134
3235 ## How we work
3336
@@ -57,8 +60,10 @@
5760 ravite (vim's). What they needed of the system went into `Sys` (report
5861 2026-10.2, approved): the terminal, files, directories and the
5962 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
6267 `doc/compiler.md`'s table of lines and its routine names true when the
6368 compiler changes. Left for later at the owner's word: a rewrite of
6469 var parameters.
@@ -113,6 +118,16 @@
113118 ones are left as they fall.
114119 - `Heap` and `Out` lock with `Lock`, a spinlock that yields, since they
115120 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.

PLAN.md (history) modified +1 -1

@@ -277,7 +277,7 @@
277277 (6.1), and is told as a division fault.
278278 The compiler and `Rt`,
279279 *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`
281281 and `CLAUDE.md` brought up to date; `make loc` within 6,000 and
282282 10%, `make bench` at 400,000 lines a second. *agent*, checked by
283283 *main*.

README.md (history) modified +17 -5

@@ -24,7 +24,7 @@
2424 $ examples/Hello
2525 hello, world
2626
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
2828 intermediate form, no optimizer. It writes x86-64 machine code and the
2929 ELF executable itself, with no assembler or linker, and compiles about
3030 a million lines a second.
@@ -77,9 +77,21 @@
7777 in the main module's directory, then in each `-I` directory, then in
7878 `lib`. A module whose code depends on the system comes in one file per
7979 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.
8281
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+
8395 `raz run Main.raz a b` compiles the same way, then runs the program
8496 with the arguments `a b`, writing no file: its output and exit status
8597 are the command's.
@@ -107,11 +119,11 @@
107119 - `extern` procedures and variables from C; code procedures written as
108120 bytes of machine code; `SYSCALL`.
109121
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.
111123
112124 ## The library
113125
114-`Rt` (ending the program, checks), `Sys` (system calls), `Out`
126+`Rt` (ending the program, failed checks, signals), `Sys` (system calls), `Out`
115127 (buffered output), `C`, `Lock`, `Thread` (threads without C), `Mem`,
116128 `Heap`, `Arena`, `Str`, `Buf`, `Fmt`, `List(T)` and `Map(K, V; hash,
117129 eq)`. `tools/Doc.raz` prints any of them:

test/genbench.py modified +1 -1

@@ -15,7 +15,7 @@
1515 g: [16]I64;
1616 data: [64]I64;
1717 """)
18-print("""proc p0(a, b: I64; s: []I64): I64;
18+print("""proc p0(a, b: I64; _s: []I64): I64;
1919 begin
2020 return a + b;
2121 end;