feat(v4): v3's whole POST, Task 8 round -- the rules, and v4 where the rulings put it (#189)
v3's whole POST on v4 at 983 of 1010 (the table's own count with its drops), from 850.
What remains is capacity ("Dictionary full", the 100-900-deep stacks): next, as ruled.
Found and fixed under the rulings (docs/v4.0.0/POST-PARITY.md):
- IS and DEFER@ refuse a word DEFER did not make, as v3: error 22, "Not deferred".
v4's IS stored into any word -- POST's `42 IS DUP` broke DUP for every case after it.
DEFER marks its word with flag 128 (dict.f18).
- SMUDGE and HIDDEN are compile-only, as v3's table: at the prompt v4's hid the newest word.
- Q./ by zero gives 0 and no error (ruled: v3's table); error 11 retired. The ROM's,
the test's reference and its hand-assembled copy changed alike.
- FENCE is v3's: it protects what is defined so far. The variable is (FENCE).
- The line's length is (#SRC), no longer SPAN: an EXPECT in a line cut the rest of
the line off, and 0 EXPECT could not leave SPAN 0 (FORTH-83).
- POST gains V4_POST_HEAD: the values left and how the output begins -- the form of a
printout whose values are the run's own (TOP-WORDS, WORD-ENTROPY).
post_all_rules.py: the rest of the whole table where it is not taken as v3 ran it --
v4's units for the cases that wrote through HERE as a byte address (CMOVE>, BLANK,
ERASE, FILL wrote into the system's code), the standard's results (COMPARE, SEARCH,
BASE output, THRU, >BODY with FIND's address), v3's descriptions where v3 printed
otherwise, and the cases dropped with their reasons (SP@/SP! by D-2, DABS/DMIN
underflow, CMOVE>.bounds, THRU.negative_end).
make -C v4 test: all v4 tests passed (both widths, mesh-boot, inference).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017RzZgrf7V7Zk2iczBXDRbm
This commit is contained in:
@@ -74,6 +74,7 @@ static void set_line(const char *s)
|
||||
unsigned len = (unsigned)strlen(s);
|
||||
put_bytes(TIB, s, len + 1u);
|
||||
n.mem[SPAN] = (v4_cell)len;
|
||||
n.mem[SRC_LEN] = (v4_cell)len;
|
||||
n.mem[TO_IN] = 0;
|
||||
}
|
||||
|
||||
@@ -316,7 +317,7 @@ int main(void)
|
||||
k = n.input_len - n.input_pos;
|
||||
CHECK(k == (i < t ? 0u : i + 1u - t), "EXPECT leaves %u unread [%u,%u]", k, t, i);
|
||||
}
|
||||
/* no action for n <= 0: nothing read, nothing stored, SPAN as it was, no error */
|
||||
/* for n <= 0 nothing is read or stored, no error, and SPAN is 0: FORTH-83, the count received (ruled 2026-11-14) */
|
||||
{
|
||||
static const v4_cell none[] = { 0, -1, -100, (v4_cell)V4_MSB };
|
||||
for (i = 0; i < 4; i++) {
|
||||
@@ -324,8 +325,8 @@ int main(void)
|
||||
v4_node_console_input_attach(&n, CONSOLE_RX, CONSOLE_ST);
|
||||
(void)v4_node_console_feed(&n, "abc\n", 4);
|
||||
n.mem[SPAN] = 5;
|
||||
CHECK(run("EXPECT", 2, SBUF, none[i], 0) && clean() && !err() && n.mem[SPAN] == 5
|
||||
&& n.input_len - n.input_pos == 4 && byte_at(SBUF) == 0x2A, "EXPECT takes no action for n <= 0 [%u]", i);
|
||||
CHECK(run("EXPECT", 2, SBUF, none[i], 0) && clean() && !err() && n.mem[SPAN] == 0
|
||||
&& n.input_len - n.input_pos == 4 && byte_at(SBUF) == 0x2A, "EXPECT reads nothing for n <= 0, and SPAN is 0 [%u]", i);
|
||||
}
|
||||
v4_node_console_input_attach(&n, CONSOLE_RX, CONSOLE_ST);
|
||||
}
|
||||
@@ -335,8 +336,8 @@ int main(void)
|
||||
n.mem[TO_IN] = 77;
|
||||
CHECK(v4_node_console_feed(&n, " 12 34 +\nnext line\n", 20) == 20, "fed");
|
||||
CHECK(run("QUERY", 0, 0, 0, 0) && clean() && !err(), "QUERY returns");
|
||||
CHECK(n.mem[SPAN] == 9 && n.mem[TO_IN] == 0 && bytes_are(TIB, " 12 34 +\0", 10), "QUERY fills TIB, sets SPAN and zeroes >IN");
|
||||
CHECK(run("SOURCE", 0, 0, 0, 0) && pop() == 9 && pop() == TIB && clean(), "SOURCE is TIB and SPAN @");
|
||||
CHECK(n.mem[SPAN] == 9 && n.mem[SRC_LEN] == 9 && n.mem[TO_IN] == 0 && bytes_are(TIB, " 12 34 +\0", 10), "QUERY fills TIB, sets SPAN and the line's length, and zeroes >IN");
|
||||
CHECK(run("SOURCE", 0, 0, 0, 0) && pop() == 9 && pop() == TIB && clean(), "SOURCE is TIB and the line's length");
|
||||
CHECK(run("QUERY", 0, 0, 0, 0) && clean() && n.mem[SPAN] == 9 && bytes_are(TIB, "next line\0", 10), "the next QUERY reads the next line");
|
||||
{
|
||||
static char longline[200];
|
||||
@@ -349,8 +350,8 @@ int main(void)
|
||||
CHECK(run("QUERY", 0, 0, 0, 0) && clean() && n.mem[SPAN] == 70 && bytes_are(TIB, longline + 80, 70), "the rest of the line is the next QUERY's");
|
||||
v4_node_console_input_attach(&n, CONSOLE_RX, CONSOLE_ST);
|
||||
}
|
||||
n.mem[SPAN] = -5;
|
||||
CHECK(run("SOURCE", 0, 0, 0, 0) && pop() == 0 && pop() == TIB && clean(), "SOURCE reads a negative SPAN as 0");
|
||||
n.mem[SRC_LEN] = -5;
|
||||
CHECK(run("SOURCE", 0, 0, 0, 0) && pop() == 0 && pop() == TIB && clean(), "SOURCE reads a negative length as 0");
|
||||
|
||||
/* ---- WORD ---- */
|
||||
|
||||
@@ -417,8 +418,8 @@ int main(void)
|
||||
set_line("abc def");
|
||||
n.mem[TO_IN] = -3;
|
||||
CHECK(run("WORD", 1, 32, 0, 0) && word_is(pop(), "abc", ' ') && clean(), "a negative >IN reads as 0");
|
||||
n.mem[SPAN] = -3; n.mem[TO_IN] = 0;
|
||||
CHECK(run("WORD", 1, 32, 0, 0) && word_is(pop(), "", 0) && clean() && n.mem[TO_IN] == 0, "a negative SPAN reads as an empty line");
|
||||
n.mem[SRC_LEN] = -3; n.mem[TO_IN] = 0;
|
||||
CHECK(run("WORD", 1, 32, 0, 0) && word_is(pop(), "", 0) && clean() && n.mem[TO_IN] == 0, "a negative length reads as an empty line");
|
||||
|
||||
/* ---- the comment words ---- */
|
||||
set_line("skip this ) kept ( and ) too");
|
||||
|
||||
Reference in New Issue
Block a user