Still to do: update WORDS and FORGET.
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
CONTEXT, CONTEXT_CFA = defNewVar("CONTEXT", zeros(Int64, 10))
mem[CONTEXT] = FORTH_CFA
-NUMCONTEXT, NUMCONTEXT_CFA = defNewVar("#CONTEXT", 1)
FIND_CFA = defPrimWord("FIND", () -> begin
;
: 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
-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