|
Warning: this is an htmlized version!
The original is here, and the conversion rules are here. |
-- (find-miniforth "crim/crim.lua")
-- (find-miniforth "crim/")
--% «_ERRORMESSAGE»
--% (find-es "lua" "_ERRORMESSAGE")
_ERRORMESSAGE = function( msg )
printf("Error: <%s>\n", msg)
printf("Rest: <%s>\n", strsub(program.string, program.pos))
exit(1)
end
--% «bytecode_colon»
dict["%"] = function() fwordclass:declare(getword()) end
dict[":"] = function() fwordclass:declare(getword()); dict["H_COL"]() end
dict["g%"] = function() fwordclass:gdeclare(getword()) end
dict["g:"] = function() fwordclass:gdeclare(getword()); dict["H_COL"]() end
dict[":RSR"] = function() fwordclass:declare(getword()); dict["H_RSR"]() end
--% «e,p,comment»
dict["e"] = function() eval(getword()) end
dict["p"] = function() px(eval(getword())) end
dict["#"] = getline
--% «asm_and_C_files»
saveasmandC = function( asmfname, Cfname )
defineLASTs()
unskeletize("crim/skel.bytecode.asm", asmfname)
unskeletize("crim/skel.engine.c", Cfname)
end
dict["asm/C-files:"] = function( ) saveasmandC(getword(), getword()) end
--% «luaword»
--% «nasm»
re(res, ")", "[ \t]\\)[ \t\n]")
getuntilpar = function( ) return getuntilre(")") end
luaword = function( name )
dict[name.."("] = function( )
eval(format("%s(%s)", %name, getuntilpar()))
end
end
dict["luaword"] = function( ) luaword(getword()) end
dict["nasm("] = function( ) eval(format("nasm(%s)", getuntilpar())) end
-- or luaword("nasm") from Lua,
-- or luaword nasm from miniforth.
--% «dbstuff»
-- (find-angg "flua/flua-comp.lua" "dbstuff")
function dbstuff(...)
local dbs, len = {}, 0
local i, obj, rest, _, str, c
for i = 1, getn(arg) do
obj = arg[i]
if type(obj) == "string" then
rest = obj
while rest ~= "" do
_, _, str, c, rest = strfind(rest, "^([ -&(-~]*)(.?)(.*)")
if str ~= "" then
tinsert(dbs, "'" .. str .. "'")
len = len + strlen(str)
end
if c ~= "" then
tinsert(dbs, strbyte(c))
len = len + 1
end
end
elseif type(obj) == "number" then
tinsert(dbs, obj)
len = len + 1
else
error("weird type for db!")
end
end
nasm(len, format("\tdb %s\n", join(dbs, ",")))
end
luaword("dbstuff")