X-Git-Url: https://thelambdalab.xyz/gitweb/index.cgi?a=blobdiff_plain;f=src%2Flib_7_vocab.4th;fp=src%2Flib_8_vocab.4th;h=5f13b47e2355280fa3a1d0d1f679e54f30c12c6e;hb=90a9b8ad41a542c3ca7d150d4d1168cb8ec97b81;hp=e0ba306dfcfa4c2a50cbd7e7d8c82ad8350166d1;hpb=56f581c25775f4244cd60d5943a5beb46a9ccafb;p=forth.jl.git diff --git a/src/lib_8_vocab.4th b/src/lib_7_vocab.4th similarity index 59% rename from src/lib_8_vocab.4th rename to src/lib_7_vocab.4th index e0ba306..5f13b47 100644 --- a/src/lib_8_vocab.4th +++ b/src/lib_7_vocab.4th @@ -13,11 +13,41 @@ DUP @ LATEST ! ( set LATEST to point to the previous word ) ; -: HIDE +\ Mark word as hidden +: HIDE ( -- ) BL WORD FIND DROP >NAME DUP @ F_HIDDEN OR SWAP ! ; +: ?HIDDEN + 1+ ( skip over the link pointer ) + @ ( get the flags/length byte ) + F_HIDDEN AND ( mask the F_HIDDEN flag and return it (as a truth value) ) +; + +\ Display name of word +: .NAME ( cfa -- ) + DUP @ ( get the flags/length byte ) + F_LENMASK AND ( mask out the flags - just want the length ) + + BEGIN + DUP 0> ( length > 0? ) + WHILE + SWAP 1+ ( addr len -- len addr+1 ) + DUP @ ( len addr -- len addr char | get the next character) + DUP 32 >= OVER 127 <= AND IF + EMIT ( len addr char -- len addr | and print it) + ELSE + BASE @ SWAP HEX + ." \x" 0 .R + BASE ! + THEN + SWAP 1- ( len addr -- addr len-1 | subtract one from length ) + REPEAT + 2DROP ( len addr -- ) +; + + \ Create new vocabulary : VOCABULARY create 0 , @@ -40,7 +70,11 @@ vocabulary ROOT ; : PREVIOUS - 1 #context -! + #context @ 1 > if + 1 #context -! + else + CR ." Cannot empty search order stack!" + then ; : ALSO