word.f18: (NEXT-TOKEN) reads the console or a macro being expanded; labels, branches by name (a label of the word, or a word, now or later), the table of branches waiting, end of word, FOR/NEXT/UNEXT, macros, &NAME, CONST+N, and (ONE), which dispatches a token. A forward branch to a name not yet defined waits on a placeholder symbol, filled in by (DEFINE). dir.f18: constant set here #, ", store, and start, which resolves, clears the tables the ROM used and runs the word it names. main.f18: the ROM itself, entry 12; on an error it stops at (ROM-FAILED) with the code and line in its state, for the loader to report. sym.f18 generalized: any counted string, placeholders, a hash of only a name's own cells. test_host_rom_asm.c gives test_text.c's own texts (accepted and refused), its four real definitions and the ROM's directives to text.c and to the ROM: the same words, the same errors on the same lines, at both widths. The ROM is 2036 words. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
116 lines
4.0 KiB
C
116 lines
4.0 KiB
C
/* rom_asm_cases.h -- the texts of v4/tests/test_text.c, accepted and refused, that the ROM's language has
|
|
* (no header and no flags). Extracted once from test_text.c; each is given to text.c and to the ROM, and
|
|
* test_host_rom_asm.c requires the same outcome. */
|
|
static const char *const rom_asm_cases[] = {
|
|
": T 123 ;",
|
|
": T -5 ;",
|
|
": T $FF ;",
|
|
": T $ff $Ab + ;",
|
|
": T 0 ;",
|
|
": T 1 2 3 4 5 6 7 + + + + + + ;",
|
|
": T 4294967295 ;",
|
|
": T -2147483648 ;",
|
|
": T $FFFFFFFF ;",
|
|
": T 4294967296 ;",
|
|
": T -2147483649 ;",
|
|
": T $100000000 ;",
|
|
": T 18446744073709551615 ;",
|
|
": T -9223372036854775808 ;",
|
|
": T $FFFFFFFFFFFFFFFF ;",
|
|
": T 18446744073709551616 ;",
|
|
": T -9223372036854775809 ;",
|
|
": T $10000000000000000 ;",
|
|
": T 99999999999999999999999999 ;",
|
|
": T VAR ;",
|
|
": ST ( x -- ) VAR a! ! ; : LD ( -- x ) VAR a! @ ;",
|
|
"\\ a line comment\n: T ( a stack comment ) 7 \\ another\n ( and\n one over two lines ) 8 + ; \\ the end",
|
|
": (T) 5 ; : T (T) (T) + ;",
|
|
": T 1 ( never closed",
|
|
": T @p ;",
|
|
": A 3 ; : T A A + ;",
|
|
": T A A + ; : A 4 ;",
|
|
": T jump A : A 9 ;",
|
|
": T call A 1 + ; : A 9 ;",
|
|
": A 1 ; : B A A + ; : C B B + ; : T C C + ;",
|
|
": T 5 \n : U 1 + ;",
|
|
": T ( n -- 1|2 ) if Z drop 1 ; Z: drop 2 ;",
|
|
": T ( n -- 0 ) L: if DONE -1 + jump L DONE: ;",
|
|
": T ( n -- f ) -if P drop -1 ; P: drop 0 ;",
|
|
": A ( n -- 1|2 ) if L drop 1 ; L: drop 2 ; : T ( n -- 3|4 ) if L drop 3 ; L: drop 4 ;",
|
|
": L 50 ; : T ( n -- x ) if L drop 1 ; L: drop 2 ;",
|
|
": L 50 ; : T ( n -- x ) L: if DONE -1 + jump L DONE: drop 3 ;",
|
|
": L drop 50 ; : T ( n -- x ) if L drop 1 ; : U 2 ;",
|
|
": L drop 50 ; : T ( n -- x ) if L drop 1 ;",
|
|
": T ( n -- x ) if OUT drop 1 ; : OUT drop 77 ;",
|
|
": T L: 1 L: 2 ;",
|
|
": T if NOWHERE ;\n: U 1 ;",
|
|
"\n\n: T 1 MISSING + ;",
|
|
": T jump",
|
|
": T jump 5 ;",
|
|
": T jump VAR ;",
|
|
": T jump dup ;",
|
|
": T ( n -- n+5 ) 4 FOR 1 + NEXT ;",
|
|
": T ( n -- n*8 ) 2 FOR 2* UNEXT ;",
|
|
": T ( n -- x ) 1 FOR 2 FOR 2* UNEXT NEXT ;",
|
|
": T ( n -- x ) 2 FOR 2* UNEXT 1 + ;",
|
|
": T ( n -- x ) 2 FOR dup + 2* nop UNEXT ;",
|
|
": T 2 FOR dup + 2* nop nop nop UNEXT ;",
|
|
": T 2 FOR 1 + UNEXT ;",
|
|
": T NEXT ;",
|
|
": T UNEXT ;",
|
|
": T 3 FOR 1 + ;\n: U ;",
|
|
": T 0 FOR 0 FOR 0 FOR 0 FOR 0 FOR 0 FOR 0 FOR 0 FOR 0 FOR ;",
|
|
"macro SWAP over push push drop pop pop endmacro : T ( a b -- b ) SWAP drop ;",
|
|
"macro 1+ 1 + endmacro macro 2+ 1+ 1+ endmacro : T 2+ 2+ ;",
|
|
"macro TEN ( a comment ) 10 \\ and another\n endmacro : T TEN TEN + ;",
|
|
"macro SHL3 2 FOR 2* UNEXT endmacro : T SHL3 ;",
|
|
": A 6 ; macro CALLS A A + endmacro : T CALLS ;",
|
|
"macro NOTHING endmacro : T 5 NOTHING ;",
|
|
"macro M L: endmacro",
|
|
"macro M : X ; endmacro",
|
|
"macro M macro N endmacro endmacro",
|
|
"macro M 1 2 3",
|
|
"macro",
|
|
": T endmacro ;",
|
|
"macro M M endmacro : T M ;",
|
|
": A 1 ;\n: A 2 ;",
|
|
": VAR 1 ;",
|
|
"macro A 1 endmacro : A 2 ;",
|
|
": dup 1 ;",
|
|
": 12 1 ;",
|
|
": FOR 1 ;",
|
|
"macro + 1 endmacro",
|
|
": X: 1 ;",
|
|
":",
|
|
": T THIS-NAME-IS-MUCH-TOO-LONG-TO-BE-A-NAME-IN-THIS-ASSEMBLER-BY-A-WIDE-MARGIN ;",
|
|
": Dup 3 ; : T Dup Dup + ;",
|
|
": 2DUP over over ; : 1+ 1 + ; : T ( a b -- 2a+2b+1 ) 2DUP + + + 1+ ;",
|
|
": T VAR+3 ;",
|
|
": T VAR+0 VAR+10 + ;",
|
|
": VAR+1 77 ; : T VAR+1 ;",
|
|
": T VAR+ ;",
|
|
": T VAR+x ;",
|
|
": T NOPE+1 ;",
|
|
": A 5 ; : T &A ;",
|
|
": A 5 ; : T &A push ;",
|
|
": T &A ; : A 5 ;",
|
|
": T &VAR ;",
|
|
": &X 1 ;",
|
|
": T 1 ;",
|
|
": T 1 ;\n: T 2 ;",
|
|
"constant SEVEN 7 constant MINUS -2 constant BIG $7F : T SEVEN MINUS + BIG + ;",
|
|
"constant K 3 : T K+2 ;",
|
|
"constant K 3 constant K 4",
|
|
"constant dup 3",
|
|
"constant K",
|
|
"constant K x",
|
|
": constant ;",
|
|
"constant K 9 : T ; #, 5 #, -1 #, K #, K+2 #, &T \", ab \", ( \", abcde",
|
|
": T dup #, 7 ;",
|
|
"#, x",
|
|
"#,",
|
|
"\",",
|
|
": #, ;",
|
|
": \", ;",
|
|
};
|