X-Git-Url: https://thelambdalab.xyz/gitweb/index.cgi?a=blobdiff_plain;f=src%2Flib_1_basic.4th;h=bc21965e7d521ef2cc186050ed56437c55739f19;hb=97b6b09881f94f55d0419d8557d2b00f816a18cb;hp=90fad637b677b7f2f50e8e00e2021150b393cf48;hpb=b1c4ba3f0b7204ee4ccb7c6f493607ab5337d5d3;p=forth.jl.git diff --git a/src/lib_1_basic.4th b/src/lib_1_basic.4th index 90fad63..bc21965 100644 --- a/src/lib_1_basic.4th +++ b/src/lib_1_basic.4th @@ -36,17 +36,22 @@ : C@ @ ; : C, , ; +\ Retrieve stack depth : DEPTH PSP@ PSP0 - ; +\ Words for whitespace : '\n' 10 ; : BL 32 ; : CR '\n' emit ; : SPACE BL emit ; +\ CFA retrieval : ' BL WORD FIND DROP ; : ['] IMMEDIATE LIT LIT , ' , ; +\ Compilation + : [COMPILE] IMMEDIATE ' , ; : COMPILE IMMEDIATE LIT LIT , ' , LIT , , ; @@ -59,9 +64,15 @@ ['] LIT , , ; +\ Convert vocabulary CFA to link addr it contains +: VOCAB>LATEST + 1+ @ +; + +\ Compile in recursive call to current word : 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 ;