From 3aa681cecaf7be95dd93fcd816b3fbf322761761 Mon Sep 17 00:00:00 2001 From: Virgil Dupras Date: Sat, 19 Sep 2020 20:19:23 -0400 Subject: [PATCH] Remove ";" word The ":" now takes care of scanning for ";". Conceptually, having ";" as an immediate word is slightly simpler than the approach in this commit, but when bootstrapping is involved, this simpler approach gets murkier. Moreover, it got even murkier-er when trying to de-stabilize EXIT, so here we are. --- blk/265 | 3 ++- blk/380 | 2 +- blk/397 | 4 ++-- blk/398 | 4 ++++ blk/399 | 6 ++---- blk/400 | 9 --------- cvm/forth.bin | Bin 5204 -> 5208 bytes doc/dict.txt | 3 +-- 8 files changed, 12 insertions(+), 19 deletions(-) delete mode 100644 blk/400 diff --git a/blk/265 b/blk/265 index 8b24ef4..905ce9b 100644 --- a/blk/265 +++ b/blk/265 @@ -1,6 +1,7 @@ : X: (xentry) 1 ( compiled ) C, - BEGIN WORD + BEGIN + WORD DUP LIT" ;" S= IF DROP 0x0b , EXIT THEN XCURRENT @ SWAP ( xcur w ) _find ( a f ) IF ( a ) DUP IMMED? IF ABORT THEN diff --git a/blk/380 b/blk/380 index 171c335..1cc934d 100644 --- a/blk/380 +++ b/blk/380 @@ -1 +1 @@ -1 20 LOADR+ ( xcomp core high ) +1 19 LOADR+ ( xcomp core high ) diff --git a/blk/397 b/blk/397 index d9a3609..81bc1a9 100644 --- a/blk/397 +++ b/blk/397 @@ -9,7 +9,7 @@ : _ ( : will get its name almost at the very end ) (entry) 1 ( compiled ) C, BEGIN - WORD FIND - IF ( is word ) DUP IMMED? IF EXECUTE ELSE , THEN + WORD DUP LIT" ;" S= IF DROP 0x0b , EXIT THEN + FIND IF ( is word ) DUP IMMED? IF EXECUTE ELSE , THEN ELSE ( maybe number ) (parse) LITN THEN AGAIN ; diff --git a/blk/398 b/blk/398 index 5770c55..8afba32 100644 --- a/blk/398 +++ b/blk/398 @@ -10,3 +10,7 @@ [COMPILE] THEN H@ 1- ( push a. 1- for allot offset ) ; IMMEDIATE +: LIT" + COMPILE (s) H@ 0 C, ," + DUP H@ -^ 1- ( a len ) SWAP C! +; IMMEDIATE diff --git a/blk/399 b/blk/399 index cf8e01b..6bc303f 100644 --- a/blk/399 +++ b/blk/399 @@ -1,7 +1,3 @@ -: LIT" - COMPILE (s) H@ 0 C, ," - DUP H@ -^ 1- ( a len ) SWAP C! -; IMMEDIATE ( We don't use ." and ABORT in core, they're not xcomp-ed ) : ." [COMPILE] LIT" COMPILE (print) ; IMMEDIATE : ABORT" [COMPILE] ." COMPILE ABORT ; IMMEDIATE @@ -13,3 +9,5 @@ : COMPILE ' LITN ['] , , ; IMMEDIATE : [COMPILE] ' , ; IMMEDIATE : ['] ' LITN ; IMMEDIATE +':' X' _ 4 - C! ( give : its name ) +'(' X' _ 4 - C! diff --git a/blk/400 b/blk/400 deleted file mode 100644 index 1ad17ef..0000000 --- a/blk/400 +++ /dev/null @@ -1,9 +0,0 @@ -( ';' can't have its name right away because, when created, it - is not an IMMEDIATE yet and will not be treated properly by - xcomp. ) -: _ - 0x0b ( EXIT ) , R> DROP ( exit : ) -; IMMEDIATE -';' X' _ 4 - C! ( give ; its name ) -':' X' _ 4 - C! ( give : its name ) -'(' X' _ 4 - C! diff --git a/cvm/forth.bin b/cvm/forth.bin index d7d809d061a2c2a9a60ed85cab8487c677b7fbf8..5f034940a54960d1e6b9b209fd71cf3441ecd784 100644 GIT binary patch delta 117 zcmcbjaYKWX0SImjuHZ4*$az=DyoJGwfzi5}QJ;Z(8iNx9H^T%r83r3BeFmWxhF9$R z3~VI~stn8%*i;!-e^7{$ UAVV8t`{WMc$xQJall4T@0NSY;CIA2c delta 89 zcmcbiaYciZ0SImjuHZ4)$az<2@^2v-wny9yo^D!`WrZyn6()xZ8;S-9J27bSOkm?? raCGty3Q-bdXk#pzJXd(Kur&umBcl@oH^T(B1cqrqI-YN`k%$@qBA69r diff --git a/doc/dict.txt b/doc/dict.txt index c57b725..88892dc 100644 --- a/doc/dict.txt +++ b/doc/dict.txt @@ -63,8 +63,7 @@ WORD( a -- a Get wordref's beginning addr. # Defining words -: x ... -- Define a new word -; R:I -- Exit a colon definition +: x ... ; -- Define a new word CREATE x -- Create cell named x. Doesn't allocate a PF. [COMPILE] x -- *I* Compile word x and write it to HERE. IMMEDIATE words are *not* executed.