X-Git-Url: https://thelambdalab.xyz/gitweb/index.cgi?p=forth.jl.git;a=blobdiff_plain;f=src%2Flib_8_vocab.4th;h=8ad875f334bb14e2699600fb392c26f57da98454;hp=34b82517c42ce91c0c9c0051164f819424b8cbb4;hb=d3205350a0b5935ac26e154750f5916ebbeebae3;hpb=4437e4ba8255ef676faf94682a8ecc2579d0f12d diff --git a/src/lib_8_vocab.4th b/src/lib_8_vocab.4th index 34b8251..8ad875f 100644 --- a/src/lib_8_vocab.4th +++ b/src/lib_8_vocab.4th @@ -1,18 +1,51 @@ \ Vocabulary management +\ Forget word and everything defined after it in compilation dict : FORGET - BL WORD FIND >LINK ( find the word, gets the dictionary entry address ) - DUP @ LATEST ! ( set LATEST to point to the previous word ) - H ! ( and store H with the dictionary address ) + BL WORD CURRENT @ FINDVOCAB ( find the word, gets the dictionary entry address ) + + 0= if + drop exit + then + + >link + + dup @ current @ 1+ ! ( set LATEST to point to the previous word ) ; -: HIDE +\ Mark word as hidden +: HIDE ( -- ) BL WORD FIND DROP >NAME DUP @ F_HIDDEN OR SWAP ! ; -: VOCAB>LATEST ( vcfa -- vlatest ) - 1+ @ @ ; +: ?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 >= 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 @@ -36,6 +69,9 @@ vocabulary ROOT ; : PREVIOUS + #context @ + 1 <= abort" Cannot empty search order stack!" + 1 #context -! ;