fix(v4): the final review's six minors in the ROM boot

- Text after start is refused, as text.c refuses it: before it jumps, the
  ROM reads on to the end of the source; blanks, comments and the ends of
  blobs may follow, a token is ERR-AFTER (26), "text after start".
- A token too long where a name, a target or a value is wanted is "name
  too long", as text.c says: (MISSING) reports "missing" only when no error
  came first.  `", keeps "missing", which is text.c's word for both.
- text.c's "address out of range" names the address, not the value.
- The system's source files are one list, v4/sys_files.h: boot.c, the
  harness and the nucleus test are made from it.
- The ROM's error codes and words are one list, v4/rom_errors.h: boot.c's
  messages, host_map.h's ROM_ERR_* and mkmap's ERR-* are made from it.
- node.h says what v4_node_store does with a ROM address (nothing, as for
  any address outside RAM, D-14); test_host_rom_range pins it.

ROM: 2095 words, rom_hash 0x06d0dcb7a0cb41a1.  dict_hash unchanged,
0xe5a57f3eb72ff94a.  make -C v4 test test-32 hosted-check pass.  QEMU:
amd64, aarch64, riscv64 to ok>, POST 538/538, POST: PASSED.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
rajames
2026-10-15 17:10:45 -04:00
co-authored by Claude Opus 5.5
parent ff75e69e91
commit a28b5f2230
18 changed files with 646 additions and 89 deletions
+12 -5
View File
@@ -44,7 +44,7 @@
\ ( -- v 1 | 0 0 ) the next token as a VALUE
: (NEXT-VALUE)
(NEXT-TOKEN) if MISS drop jump (VALUE)
MISS: drop ERR-MISSING (FAIL) 0 0 ;
MISS: drop (MISSING) 0 0 ;
: (H-CONSTANT)
(IN-MACRO?) if OK drop ;
@@ -56,7 +56,7 @@
-if NUM drop drop ERR-BIG jump (FAIL)
NUM: drop (NAME-BACK) 2 jump (DEFINE)
NAN: drop drop ERR-VALUE jump (FAIL)
MISS: drop ERR-MISSING jump (FAIL)
MISS: drop jump (MISSING)
: (H-SET)
(IN-MACRO?) if OK drop ;
@@ -66,7 +66,7 @@
(NEXT-VALUE) if BADV drop
(NAME-BACK) 4 jump (DEFINE)
BADV: drop drop ;
MISS: drop ERR-MISSING jump (FAIL)
MISS: drop jump (MISSING)
\ here alone is not something to assemble: only a VALUE
: (H-HERE) ERR-TARGET jump (FAIL)
@@ -88,6 +88,7 @@
(T2) a! @ (TOK) + a! @ (EMIT)
(T2) a! @ 1 + ! jump L
D: drop ;
\ text.c says "without a string, or one too long" for both: missing
MISS: drop ERR-MISSING jump (FAIL)
\ store ADDR VALUE: ADDR must be in RAM, as text.c requires
@@ -113,7 +114,7 @@
0 (RECN) a! ! 0 (POOLN) a! ! 0 (NREF) a! ! 0 (NLAB) a! !
0 (WNP) a! ! 0 (NFOR) a! ! 0 (RDEPTH) a! ! ;
\ start NAME: the system's source has ended
\ start NAME: the system's source has ended; NAME, a word, is where it starts
: (H-START)
(IN-MACRO?) if OK drop ;
OK: drop
@@ -130,9 +131,15 @@
(FIND) if NOTW
dup 2 + a! @ 1 xor if ISW drop drop jump NOTW0
ISW: drop 3 + a! @ (T1) a! !
\ nothing may follow start but blanks, comments and the ends of blobs,
\ up to the end of all
A1: (TOKEN) if A2
drop ERR-AFTER jump (FAIL)
A2: drop (FAILED) a! @ if A3 drop ;
A3: drop (EOF) a! @ if A1 drop
(CLEAR)
0 DSTACK-REG a! ! 0 RSTACK-REG a! !
(T1) a! @ push ;
NOTW: drop
NOTW0: ERR-START jump (FAIL)
MISS: drop ERR-MISSING jump (FAIL)
MISS: drop jump (MISSING)
+7
View File
@@ -41,6 +41,13 @@
\ ( code -- ) stop with an error, noting the line
: (FAIL) (FAILED) a! ! (LINE) a! @ (ERRLINE) a! ! ;
\ ( -- ) "missing": a name, a target or a value was wanted and there is
\ none -- unless an error came first, a token too long or a comment not
\ closed, which stands, as text.c's first error does
: (MISSING)
(FAILED) a! @ if M drop ;
M: drop ERR-MISSING jump (FAIL)
\ ( c -- ) one more character of the token: byte (TOKN)+1 of (TOK), into
\ a cell whose byte there is still zero
: (PUT)
+2 -2
View File
@@ -346,7 +346,7 @@
OK: drop
(NEXT-TOKEN) if NONAME drop
(END-WORD) (LABEL) 1 jump (DEFINE)
NONAME: drop ERR-MISSING jump (FAIL)
NONAME: drop jump (MISSING)
\ ( -- ) assemble the token
: (ONE)
@@ -379,7 +379,7 @@
1 jump (BRANCH-NAME)
PLAIN: drop jump (OP)
FP: drop drop ERR-FETCH-P jump (FAIL)
NOTGT: drop drop ERR-MISSING jump (FAIL)
NOTGT: drop drop jump (MISSING)
AMP: drop (TOKN) a! @ -1 + if ONECH drop
(TOK-SAVE) 1 (MLEN) a! @ -1 + (TOK-SUB)
(FIND) if BADA