X-Git-Url: https://thelambdalab.xyz/gitweb/index.cgi?a=blobdiff_plain;f=src%2Flib_1_basic.4th;h=21c7b9388e4a2b0b36fe2c2dad7efe70bd49a9f3;hb=ebff3ca5a9b2dd5a6608b696e7862aa7264f6682;hp=40851f34e198b37ea532e08d30227065d545716f;hpb=6cb12b03e2a154214fc60d7c437e650e79fb42e5;p=forth.jl.git diff --git a/src/lib_1_basic.4th b/src/lib_1_basic.4th index 40851f3..21c7b93 100644 --- a/src/lib_1_basic.4th +++ b/src/lib_1_basic.4th @@ -36,18 +36,26 @@ : 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 ; -: [COMPILE] IMMEDIATE ' , ; : ['] IMMEDIATE LIT LIT , ' , ; +\ Compilation + +: [COMPILE] IMMEDIATE ' , ; +: COMPILE IMMEDIATE + LIT LIT , ' , LIT , , ; + : LITERAL IMMEDIATE ['] LIT , , ; : CHAR BL WORD 1+ @ ; @@ -56,9 +64,14 @@ ['] LIT , , ; +\ LFA of most recent definition +: LATEST + CURRENT @ 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 + LINK> \ get the codeword , \ compile it ;