|
Warning: this is an htmlized version!
The original is here, and the conversion rules are here. |
[lua getline = function () return getuntilluare(nil, "^([^\n]*)") end
evalluaexpr = function (str) return assert(loadstring("return "..str)) end
lua]
:lua # getline() lua; # for comments
:lua ( getuntilluare(nil, "^([^\n]-)[ \t]%)") lua; # ( for comments )
:lua getline dspush(getline()) lua; ( -- str )
:lua getword dspush(getword()) lua; ( -- str )
:lua dup dspush(ds[1]) lua; ( a -- a a )
:lua * ds[2] = ds[2]*ds[1]; dspop() lua; ( a b -- a*b )
:lua swap ds[2], ds[1] = ds[1], ds[2] lua; ( a b -- b a )
:lua drop dspop() lua; ( a -- )
:lua . PP(dspop()) lua; ( a -- )
:lua .. ds[2] = ds[2]..ds[1]; dspop() lua; ( a b -- a..b )
:lua evalluaexpr ds[1] = evalluaexpr(ds[1]) lua; ( str -- value )
:lua \\ print(getline()) lua;
:lua \lua assert(loadstring(getline()))() lua;
:lua DBG=1 DBG=1 lua;
# Define `lit'; `lit' is mentioned in the kernel but not defined there...
# (find-lforth "kernel.lua" "states.outer_compiler" "lit")
# (find-lforth "README" "kernel-innertestrsr")
:lua lit dspush(mem[ip]); ip = ip+1 lua; # more efficient than RSRing
:lua slit dspush(mem[ss[1]]); ss[1] = ss[1]+1 lua;
# To define immediate words
# (find-lforth "kernel.lua" "states.outer_compiler")
# (find-lforth "kernel.lua" "invoke")
:lua RUNNOW invoke(word) lua;
:lua immed: dict[getword()] = "RUNNOW" lua;
:lua #!/usr/bin/env getline() lua;
:lua field: -- `field: name' defines `.name' and `.name!'
local fieldname = getword()
prim("."..fieldname, function ()
ds[1] = ds[1][fieldname]
end)
prim("."..fieldname.."!", function ()
ds[1][fieldname] = ds[2]
ds[2] = ds[1]
dspop()
end)
lua;