From 56f581c25775f4244cd60d5943a5beb46a9ccafb Mon Sep 17 00:00:00 2001 From: Tim Vaughan Date: Sat, 4 Jun 2016 22:15:53 +1200 Subject: [PATCH] FORGET works with vocabularies. Updated readme. --- README.md | 7 +++---- src/lib_1_basic.4th | 2 +- src/lib_7_decompiler.4th | 22 +++++----------------- src/lib_8_vocab.4th | 14 +++++++++----- 4 files changed, 18 insertions(+), 27 deletions(-) diff --git a/README.md b/README.md index e0c9767..3f4332a 100644 --- a/README.md +++ b/README.md @@ -90,17 +90,16 @@ as makes sense given the underlying VM. (Actually, my main goal goes a bit beyond this: I want to be able to, with a couple of exceptions, be compatible with the description of forth contained in the second edition of Leo Brodie's book "Starting Forth".) I'm fairly happy with my progress so far. Of the -131 required F83 words, only 26 remain unimplemented. These words fall into +131 required F83 words, only 22 remain unimplemented. These words fall into three categories: those I intend to implement in the near future, those I may possibly implement at some point, and those that I do not intend to ever implement for reasons of obsolescence or incompatibility with the design of the VM. ### F83 Words to be implemented soon - PAD ABORT" CMOVE> VOCABULARY DEFINITIONS FORTH + PAD ABORT" -User-defined vocabularies aren't in there yet but this should be easy to solve. -`PAD`, `ABORT` and `CMOVE>` are simple oversights. +The words `PAD` is a simple oversite. `ABORT"` will also be implemented soon. ### F83 Words that may be implemented someday diff --git a/src/lib_1_basic.4th b/src/lib_1_basic.4th index 21c7b93..b6f75e4 100644 --- a/src/lib_1_basic.4th +++ b/src/lib_1_basic.4th @@ -64,7 +64,7 @@ ['] LIT , , ; -\ LFA of most recent definition +\ Address containing LFA of most recent definition : LATEST CURRENT @ 1+ ; diff --git a/src/lib_7_decompiler.4th b/src/lib_7_decompiler.4th index 505f7da..a27442b 100644 --- a/src/lib_7_decompiler.4th +++ b/src/lib_7_decompiler.4th @@ -33,6 +33,10 @@ F_IMMED AND ( mask the F_IMMED flag and return it (as a truth value) ) ; +: BODYLEN + \ **TODO** +; + : SEE BL WORD FIND ( find the dictionary entry to decompile ) @@ -43,23 +47,7 @@ EXIT THEN - >LINK - - ( Now we search again, looking for the next word in the dictionary. This gives us - the length of the word that we will be decompiling. (Well, mostly it does). ) - HERE ( address of the end of the last compiled word ) - LATEST @ ( word last curr ) - BEGIN - 2 PICK ( word last curr word ) - OVER ( word last curr word curr ) - <> ( word last curr word<>curr? ) - WHILE ( word last curr ) - NIP ( word curr ) - DUP @ ( word curr prev (which becomes: word last curr) ) - REPEAT - - DROP ( at this point, the stack is: start-of-word end-of-word ) - SWAP ( end-of-word start-of-word ) + DUP DUP BODYLEN + SWAP >LINK DUP LINK> @ CASE DOCOL OF diff --git a/src/lib_8_vocab.4th b/src/lib_8_vocab.4th index 34b8251..e0ba306 100644 --- a/src/lib_8_vocab.4th +++ b/src/lib_8_vocab.4th @@ -1,9 +1,16 @@ \ 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 ) + BL WORD CURRENT @ FINDVOCAB ( find the word, gets the dictionary entry address ) + + 0= if + drop exit + then + + >link + DUP @ LATEST ! ( set LATEST to point to the previous word ) - H ! ( and store H with the dictionary address ) ; : HIDE @@ -11,9 +18,6 @@ DUP @ F_HIDDEN OR SWAP ! ; -: VOCAB>LATEST ( vcfa -- vlatest ) - 1+ @ @ ; - \ Create new vocabulary : VOCABULARY create 0 , -- 2.20.1