The Lambda Lab
/
projects
/
forth.jl.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Updated library code to use IB and QUERY-INPUT.
[forth.jl.git]
/
src
/
lib_1_basic.4th
diff --git
a/src/lib_1_basic.4th
b/src/lib_1_basic.4th
index
1764723
..
a5bb701
100644
(file)
--- a/
src/lib_1_basic.4th
+++ b/
src/lib_1_basic.4th
@@
-36,14
+36,27
@@
: C@ @ ;
: C, , ;
: C@ @ ;
: C, , ;
+\ Retrieve stack depth
: DEPTH PSP@ PSP0 - ;
: DEPTH PSP@ PSP0 - ;
+\ Words for whitespace
: '\n' 10 ;
: BL 32 ;
: '\n' 10 ;
: BL 32 ;
+: CR '\n' emit ;
+: SPACE BL emit ;
-: LITERAL IMMEDIATE ['] LIT , , ;
-
+\ CFA retrieval
: ' BL WORD FIND DROP ;
: ' BL WORD FIND DROP ;
+: ['] IMMEDIATE
+ LIT LIT , ' , ;
+
+\ Compilation
+
+: [COMPILE] IMMEDIATE ' , ;
+: COMPILE IMMEDIATE
+ LIT LIT , ' , LIT , , ;
+
+: LITERAL IMMEDIATE ['] LIT , , ;
: CHAR BL WORD 1+ @ ;
: [CHAR] IMMEDIATE
: CHAR BL WORD 1+ @ ;
: [CHAR] IMMEDIATE
@@
-51,18
+64,14
@@
['] LIT , ,
;
['] LIT , ,
;
-: CR '\n' emit ;
-: SPACE BL emit ;
-
-: [COMPILE] IMMEDIATE
- BL WORD \ get the next word
- FIND DROP \ find it in the dictionary
- , \ and compile that
+\ Convert vocabulary CFA to link addr it contains
+: VOCAB>LATEST
+ 1+ @
;
;
+\ Compile in recursive call to current word
: RECURSE IMMEDIATE
: RECURSE IMMEDIATE
- LATEST @ \ LATEST points to the word being compiled at the moment
-
>CFA
\ get the codeword
+ CURRENT @ VOCAB>LATEST
+
LINK>
\ get the codeword
, \ compile it
;
, \ compile it
;
-