feat(v4.0.0): the prompt -- QUIT, ABORT, ABORT" and ."
Layer 5 of the compiler capsule. The host node is now started at QUIT and left running: it prompts, reads a line from its console with QUERY, interprets it, says " ok" or " ERROR", and goes round again. - capsule/quit.v4: QUIT and ABORT (FORTH-79), ABORT" and (ABORT") as v3 has them, ." and (.") (FORTH-79). Text is compiled as a counted string after the call; the run-time word returns to the cell after it. - INTERPRET prints v3's messages before abandoning a line: UNKNOWN WORD: 'xxx' and xxx: compile-only. - core.v4: CR SPACE COUNT TYPE, as DECOMPOSITION.md gives them. - input.v4: WORD split so that (PARSE) can take text without skipping leading delimiters (." " is an empty string); EXPECT keeps its place in memory, so six values may wait on the stack while a line is typed. - tests/test_host_quit.c: the node is fed characters and its output read; 16 sessions are transcripts of the v3 binary. QUIT stops the line from inside any word and says nothing; v3's goes on with the line and cannot be compiled. v3's compiled ABORT" crashes. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
806f876ee0
commit
b5d644d498
@@ -85,6 +85,24 @@ header KEY
|
||||
L: CONSOLE-STATUS b! @b if WAIT drop CONSOLE-RX b! @b ;
|
||||
WAIT: drop jump L
|
||||
|
||||
header CR
|
||||
: CR ( -- ) 10 jump EMIT
|
||||
header SPACE
|
||||
: SPACE ( -- ) 32 jump EMIT
|
||||
header COUNT
|
||||
: COUNT ( baddr -- baddr+1 c ) dup C@ push 1 + pop ;
|
||||
header TYPE
|
||||
: TYPE ( baddr u -- )
|
||||
-if OK drop drop NODE-ERROR b! -1 !b ;
|
||||
OK: if DONE over C@ EMIT push 1 + pop -1 + jump OK
|
||||
DONE: drop drop ;
|
||||
|
||||
\ ( x -- ) up to four characters packed in one cell, the first in the low
|
||||
\ byte: how the capsule prints its own short messages, a literal at a time.
|
||||
: (EMIT4)
|
||||
L: if DONE dup EMIT 8/ jump L
|
||||
DONE: drop ;
|
||||
|
||||
\ ---- section 5.8: the number base ----------------------------------------
|
||||
: (BASE) ( -- b ) \ BASE, or 10 when it is outside 2 .. 36
|
||||
BASE b! @b dup -2 + -if L1 drop drop 10 ;
|
||||
|
||||
Reference in New Issue
Block a user