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
+4 -26
View File
@@ -12,6 +12,7 @@
#ifndef V4_TESTS_HOST_MAP_H
#define V4_TESTS_HOST_MAP_H
#include "v4/rom_errors.h"
#include "v4/blocks.h"
#include "v4/text.h"
#include <stdio.h>
@@ -197,32 +198,9 @@
#define ROM_KIND_CONST 2
#define ROM_KIND_MACRO 3
#define ROM_KIND_SET 4
/* the ROM's error codes */
#define ROM_ERR_TOO_LONG 1 /* a token longer than 63 characters: "name too long" */
#define ROM_ERR_COMMENT 2 /* a ( with no ) before the end: "comment not closed" */
#define ROM_ERR_BAD_NAME 3 /* an opcode, a reserved word, a label, a number or &...: "cannot be used as a name" */
#define ROM_ERR_DEFINED 4 /* "already defined" */
#define ROM_ERR_NAMES 5 /* the symbol table is full: "too many names" */
#define ROM_ERR_FIT 6 /* memory is full, or a branch cannot reach: "does not fit" */
#define ROM_ERR_OPCODE 7 /* not an opcode the packer takes there */
#define ROM_ERR_IN_MACRO 8 /* "not allowed in a macro" */
#define ROM_ERR_MACRO 9 /* "macro without endmacro", "endmacro without macro" */
#define ROM_ERR_LABEL_DUP 10 /* "label already defined in this word" */
#define ROM_ERR_LABELS 11 /* "too many labels in one word" */
#define ROM_ERR_FOR 12 /* FOR nested too deep, NEXT or UNEXT without FOR, FOR without NEXT */
#define ROM_ERR_UNEXT 13 /* "FOR ... UNEXT must fit one instruction word and hold no literal" */
#define ROM_ERR_TARGET 14 /* "not something to branch to" */
#define ROM_ERR_UNDEFINED 15 /* "never defined" */
#define ROM_ERR_BIG 16 /* "number does not fit a cell" */
#define ROM_ERR_AMP 17 /* "& needs a word that is already defined" */
#define ROM_ERR_FETCH_P 18 /* "write the number, not @p" */
#define ROM_ERR_MISSING 19 /* a name, a target, a value or a string missing at the end */
#define ROM_ERR_DEEP 20 /* "macros nested too deep" */
#define ROM_ERR_REFS 21 /* "too many unresolved branches" */
#define ROM_ERR_VALUE 22 /* "not a value", "not a number" */
#define ROM_ERR_NO_START 23 /* the input ended with no start */
#define ROM_ERR_START 24 /* start: not a word */
#define ROM_ERR_RANGE 25 /* "address out of range": store outside RAM */
/* the ROM's error codes: ROM_ERR_TOO_LONG, ROM_ERR_COMMENT ... (v4/rom_errors.h) */
#define ROM_ERR_ENUM_(name, code, text) ROM_ERR_##name = code,
enum { V4_ROM_ERRORS(ROM_ERR_ENUM_) ROM_ERR_END_ };
#define ROM_ADDR_TOP ((v4_cell)(V4_NODE_WORDS + V4_ROM_WORDS - 1u)) /* the top of the address space */
#define WORD_DEFINED (BUF0_W - 11) /* the xt of the word that is told of each new entry, or 0 */
#define WORD_FORGOTTEN (BUF0_W - 12) /* the xt of the word that is told when entries go, or 0 */