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.
This commit is contained in:
parent
53239c8f84
commit
3aa681ceca
3
blk/265
3
blk/265
@ -1,6 +1,7 @@
|
|||||||
: X:
|
: X:
|
||||||
(xentry) 1 ( compiled ) C,
|
(xentry) 1 ( compiled ) C,
|
||||||
BEGIN WORD
|
BEGIN
|
||||||
|
WORD DUP LIT" ;" S= IF DROP 0x0b , EXIT THEN
|
||||||
XCURRENT @ SWAP ( xcur w ) _find ( a f )
|
XCURRENT @ SWAP ( xcur w ) _find ( a f )
|
||||||
IF ( a )
|
IF ( a )
|
||||||
DUP IMMED? IF ABORT THEN
|
DUP IMMED? IF ABORT THEN
|
||||||
|
4
blk/397
4
blk/397
@ -9,7 +9,7 @@
|
|||||||
: _ ( : will get its name almost at the very end )
|
: _ ( : will get its name almost at the very end )
|
||||||
(entry) 1 ( compiled ) C,
|
(entry) 1 ( compiled ) C,
|
||||||
BEGIN
|
BEGIN
|
||||||
WORD FIND
|
WORD DUP LIT" ;" S= IF DROP 0x0b , EXIT THEN
|
||||||
IF ( is word ) DUP IMMED? IF EXECUTE ELSE , THEN
|
FIND IF ( is word ) DUP IMMED? IF EXECUTE ELSE , THEN
|
||||||
ELSE ( maybe number ) (parse) LITN THEN
|
ELSE ( maybe number ) (parse) LITN THEN
|
||||||
AGAIN ;
|
AGAIN ;
|
||||||
|
4
blk/398
4
blk/398
@ -10,3 +10,7 @@
|
|||||||
[COMPILE] THEN
|
[COMPILE] THEN
|
||||||
H@ 1- ( push a. 1- for allot offset )
|
H@ 1- ( push a. 1- for allot offset )
|
||||||
; IMMEDIATE
|
; IMMEDIATE
|
||||||
|
: LIT"
|
||||||
|
COMPILE (s) H@ 0 C, ,"
|
||||||
|
DUP H@ -^ 1- ( a len ) SWAP C!
|
||||||
|
; IMMEDIATE
|
||||||
|
6
blk/399
6
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 )
|
( We don't use ." and ABORT in core, they're not xcomp-ed )
|
||||||
: ." [COMPILE] LIT" COMPILE (print) ; IMMEDIATE
|
: ." [COMPILE] LIT" COMPILE (print) ; IMMEDIATE
|
||||||
: ABORT" [COMPILE] ." COMPILE ABORT ; IMMEDIATE
|
: ABORT" [COMPILE] ." COMPILE ABORT ; IMMEDIATE
|
||||||
@ -13,3 +9,5 @@
|
|||||||
: COMPILE ' LITN ['] , , ; IMMEDIATE
|
: COMPILE ' LITN ['] , , ; IMMEDIATE
|
||||||
: [COMPILE] ' , ; IMMEDIATE
|
: [COMPILE] ' , ; IMMEDIATE
|
||||||
: ['] ' LITN ; IMMEDIATE
|
: ['] ' LITN ; IMMEDIATE
|
||||||
|
':' X' _ 4 - C! ( give : its name )
|
||||||
|
'(' X' _ 4 - C!
|
||||||
|
9
blk/400
9
blk/400
@ -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!
|
|
BIN
cvm/forth.bin
BIN
cvm/forth.bin
Binary file not shown.
@ -63,8 +63,7 @@ WORD( a -- a Get wordref's beginning addr.
|
|||||||
|
|
||||||
# Defining words
|
# Defining words
|
||||||
|
|
||||||
: x ... -- Define a new word
|
: x ... ; -- Define a new word
|
||||||
; R:I -- Exit a colon definition
|
|
||||||
CREATE x -- Create cell named x. Doesn't allocate a PF.
|
CREATE x -- Create cell named x. Doesn't allocate a PF.
|
||||||
[COMPILE] x -- *I* Compile word x and write it to HERE.
|
[COMPILE] x -- *I* Compile word x and write it to HERE.
|
||||||
IMMEDIATE words are *not* executed.
|
IMMEDIATE words are *not* executed.
|
||||||
|
Loading…
Reference in New Issue
Block a user