The Lambda Lab
/
projects
/
forth.jl.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
DO LOOP LEAVE working
[forth.jl.git]
/
src
/
forth.jl
diff --git
a/src/forth.jl
b/src/forth.jl
index
9c3f62e
..
0b4871f
100644
(file)
--- a/
src/forth.jl
+++ b/
src/forth.jl
@@
-241,26
+241,27
@@
OVER = defPrimWord("OVER", () -> begin
return NEXT
end)
return NEXT
end)
-
ROT = defPrimWord("
ROT", () -> begin
+
NROT = defPrimWord("-
ROT", () -> begin
a = popPS()
b = popPS()
c = popPS()
a = popPS()
b = popPS()
c = popPS()
+ pushPS(b)
pushPS(a)
pushPS(c)
pushPS(a)
pushPS(c)
- pushPS(b)
return NEXT
end)
return NEXT
end)
-
NROT = defPrimWord("-
ROT", () -> begin
+
ROT = defPrimWord("
ROT", () -> begin
a = popPS()
b = popPS()
c = popPS()
a = popPS()
b = popPS()
c = popPS()
- pushPS(b)
pushPS(a)
pushPS(c)
pushPS(a)
pushPS(c)
+ pushPS(b)
return NEXT
end)
return NEXT
end)
+
TWODROP = defPrimWord("2DROP", () -> begin
popPS()
popPS()
TWODROP = defPrimWord("2DROP", () -> begin
popPS()
popPS()
@@
-849,12
+850,16
@@
type ParseError <: Exception
end
Base.showerror(io::IO, ex::ParseError) = print(io, "Parse error at word: '$(ex.wordName)'.")
end
Base.showerror(io::IO, ex::ParseError) = print(io, "Parse error at word: '$(ex.wordName)'.")
+DEBUG, DEBUG_CFA = defNewVar("DEBUG", 0)
+
INTERPRET = defPrimWord("INTERPRET", () -> begin
callPrim(mem[WORD])
wordName = getString(mem[reg.PSP-1], mem[reg.PSP])
INTERPRET = defPrimWord("INTERPRET", () -> begin
callPrim(mem[WORD])
wordName = getString(mem[reg.PSP-1], mem[reg.PSP])
- #println("... ", replace(replace(wordName, "\004", "EOF"), "\n", "\\n"), " ...")
+ if mem[DEBUG] != 0
+ println("... ", replace(replace(wordName, "\004", "EOF"), "\n", "\\n"), " ...")
+ end
callPrim(mem[TWODUP])
callPrim(mem[FIND])
callPrim(mem[TWODUP])
callPrim(mem[FIND])
@@
-999,7
+1004,10
@@
function run(;initialize=true)
jmp = NEXT
while jmp != 0
try
jmp = NEXT
while jmp != 0
try
- #println("Evaluating prim ", jmp," ", primNames[-jmp])
+ if mem[DEBUG] != 0
+ println("Evaluating prim ", jmp," ", primNames[-jmp])
+ end
+
jmp = callPrim(jmp)
catch ex
jmp = callPrim(jmp)
catch ex