X-Git-Url: https://thelambdalab.xyz/gitweb/index.cgi?a=blobdiff_plain;ds=inline;f=src%2Flib_1_basic.4th;h=b6f75e48605882b80fc8d596977f480da3c87104;hb=56f581c25775f4244cd60d5943a5beb46a9ccafb;hp=176472312f2bca7a80641eda60447b92e6c9ec8a;hpb=9da6dc7c0252fdc18aca602928feab518737cc8f;p=forth.jl.git diff --git a/src/lib_1_basic.4th b/src/lib_1_basic.4th index 1764723..b6f75e4 100644 --- a/src/lib_1_basic.4th +++ b/src/lib_1_basic.4th @@ -36,14 +36,27 @@ : C@ @ ; : C, , ; +\ Retrieve stack depth : DEPTH PSP@ PSP0 - ; +\ Words for whitespace : '\n' 10 ; : BL 32 ; +: CR '\n' emit ; +: SPACE BL emit ; -: LITERAL IMMEDIATE ['] LIT , , ; - +\ CFA retrieval : ' BL WORD FIND DROP ; +: ['] IMMEDIATE + LIT LIT , ' , ; + +\ Compilation + +: [COMPILE] IMMEDIATE ' , ; +: COMPILE IMMEDIATE + LIT LIT , ' , LIT , , ; + +: LITERAL IMMEDIATE ['] LIT , , ; : CHAR BL WORD 1+ @ ; : [CHAR] IMMEDIATE @@ -51,18 +64,14 @@ ['] 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 -; +\ Address containing 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 ;