From: Tim Vaughan Date: Thu, 2 Jun 2016 09:20:27 +0000 (+1200) Subject: Implemented most vocab words. X-Git-Url: https://thelambdalab.xyz/gitweb/index.cgi?a=commitdiff_plain;h=9bfbc52aa2ba873acd40fada868bf26b3e26d8ae;p=forth.jl.git Implemented most vocab words. Still to do: update WORDS and FORGET. --- diff --git a/src/forth.jl b/src/forth.jl index 890cf24..9668025 100644 --- a/src/forth.jl +++ b/src/forth.jl @@ -707,10 +707,12 @@ FROMLINK_CFA = defPrimWord("LINK>", () -> begin return NEXT end) +NUMCONTEXT, NUMCONTEXT_CFA = defNewVar("#CONTEXT", 1) + createHeader("FORTH", 0) FORTH_CFA = mem[H] dictWrite(defPrim(() -> begin - mem[CONTEXT] = reg.W + mem[CONTEXT + mem[NUMCONTEXT] - 1] = reg.W return NEXT end, name="FORTH")) dictWrite(0) # cell for latest @@ -723,7 +725,6 @@ mem[CURRENT] = FORTH_CFA CONTEXT, CONTEXT_CFA = defNewVar("CONTEXT", zeros(Int64, 10)) mem[CONTEXT] = FORTH_CFA -NUMCONTEXT, NUMCONTEXT_CFA = defNewVar("#CONTEXT", 1) FIND_CFA = defPrimWord("FIND", () -> begin diff --git a/src/lib_9_vocab.4th b/src/lib_9_vocab.4th index 7e574b7..e4f836b 100644 --- a/src/lib_9_vocab.4th +++ b/src/lib_9_vocab.4th @@ -27,22 +27,9 @@ does> ; : DEFINITIONS - context @ current ! + context #context @ 1- + @ current ! ; -vocabulary root -also root definitions - -: FORTH forth ; - -: ONLY - 1 #context ! - root - 2 #context ! -; - -\ only forth - \ Display search order and compilation dictionary : ORDER @@ -53,6 +40,29 @@ also root definitions -1 +loop \ Current (definitions) - 9 emit + 5 spaces current @ >name .name ; + +\ Define root vocabulary (always available) +vocabulary ROOT + +: ONLY + 1 #context ! + root + 2 #context ! + root +; + +: PREVIOUS + 1 #context -! +; + +also root definitions + +: FORTH forth ; +: ALSO also ; +: WORDS words ; +: ORDER order ; + +only forth also definitions