|
Warning: this is an htmlized version!
The original is here, and the conversion rules are here. |
# (find-lua50ref "Table Constructors")
# (find-angg "LFORTH/")
# (find-angg "LFORTH/README" "inner")
Primeiro: hashes. Por exemplo, se
dncs["\\Set"] = { hash = 1, name = "\\Set" }
dncs["\\catC"] = { hash = 2, name = "\\catC" }
dncs["a"] = { hash = 3, name = "a", Cat = "\\Cat[a]" }
dncs["\\Cat[a]"] = { hash = 4, name = "\\Cat[a]", [":="] = "\\catC" }
dncs["x"] = { hash = 5, name = "x", Cat = "\\Cat[x]" }
dncs["\\Cat[x]"] = { hash = 6, name = "\\Cat[x]", [":="] = "\\catC" }
dncs["a^F"] = { hash = 7, name = "a^F", Cat = "\\Cat[a^F]" }
dncs["\\Cat[a^F]"] = { hash = 8, name = "\\Cat[a^F]", [":="] = "\\Set" }
dncs["x^F"] = { hash = 9, name = "x^F", Cat = "\\Cat[x^F]" }
dncs["\\Cat[x^F]"] = { hash =10, name = "\\Cat[x^F]", [":="] = "\\Set" }
hashname["#3|->#5"] = "a|->x"
dncs["a|->x"] = {
hash = 11, name = "a|->x",
left = "a", right = "x", arrow = "|->",
E = "\\E[a|->x]" }
dncs["\\E[a|->x]"] = {
hash = 12, name = "\\E[a|->x]",
E = "*"
# (find-lua50ref "sec3.7")
# (find-lua50ref "__index")
# (find-lua50ref "__newindex")
# (find-lua50file "test/")
# (find-lua50file "test/readonly.lua")
# (find-lua50file "test/trace-globals.lua")
# (find-lua50file "test/undefined.lua")
# (find-lua50ref "getglobals")
Falta mais coisa numa categoria: Objs, Hom, talvez id e comp.
dncs["C"].Objs = "Objs_C"
dncs["C"].Hom = "Hom_C"
dncs["C"].id = "id_C"
dncs["C"].comp = "comp_C"
dncs["a"].Cat = "Cat[a]"
dncs["Cat[a]"][":="] = "C"
dncs["x"].Cat = "Cat[x]"
dncs["Cat[x]"][":="] = "C"
dncs["O[a]"][":"] = "Objs_C"
dncs["O[x]"][":"] = "Objs_C"
dncs["E[a|->x]"][":"] = "*"
dncs["E[a|->x]"][":="] = compile(
"h_forth", "O[a]", "O[x]", "Hom_C" "infer2_" "exit")
dncs["a|->x"][":"] = "E[a|->x]"
dncs["a|->x"].Cat = "Set"
dncs["E[(a|->x)|->x^F]"][":"] = "*"
dncs["E[(a|->x)|->x^F]"][":="] = compile(
"h_forth", "E[a|->x]", "E[x^F]", "Hom_Set" "infer2_" "exit")
dncs["(a|->x)|->x^F"][":"] = "E[(a|->x)|->x^F]"
a|->b requires a, b,
[lua dncs = {}
hashcount = 0
newhash = function () hashcount = hashcount + 1; return hashcount end
hashs = {}
lua]
:lua $
local name = getword()
if dncs[name] then dspush(dncs[name]); return end
local struct = { name=name, hash=newhash() }
compile(name, "h_var", struct)
dspush(struct)
lua;
getword ds{ -- struct }
#*
# (find-angg "LFORTH/kernel.lua" "interpret")
# (find-angg "LFORTH/kernel.lua" "getuntilluare")
# (find-angg "LFORTH/README")
cd ~/LFORTH/
# lua50 -l kernel.lua -l dbg.lua -e ...
lua50 -l kernel.lua -e 'interpret [[
:lua dup dspush(ds[1]) lua;
:lua * ds[2] = ds[2]*ds[1]; dspop() lua;
:lua swap ds[2], ds[1] = ds[1], ds[2] lua;
:lua drop dspop() lua;
:lua . print(dspop()) lua;
:lua .. ds[2] = ds[2]..ds[1]; dspop() lua;
:lua # getuntilluare(nil, "^[^\n]*") lua; # to ignore the rest of a line
:lua $
local w = getword()
prim(w, function () dspush(w) end)
dspush(w)
lua;
:lua binop
$ a drop
$ x drop
$ a^F drop
$ x^F drop
a x .. .
]]'
#*
# (a;x=>x^F)-.>(a^F<->(x-.>((a|->x)|->x^F)))
a x x^F
=>
pp;pp a^F x a x
|-> x^F
|->
-.>
<->
-.>
#*