1
0
forked from osmarks/potatOS

Merge pull request 'Integrate further spudulons into hyperpotatospace' (#4) from heavpoot/potatOS:master into master

Reviewed-on: osmarks/potatOS#4
This commit is contained in:
osmarks 2021-01-29 22:13:52 +00:00
commit 457ffd6745

View File

@ -1,3 +1,4 @@
if not unpack then unpack = table.unpack end
function deepclone(t)
local res={}
for i,v in ipairs(t) do
@ -173,7 +174,8 @@ function into_ast(tokens)
local tmp=p()
if (tmp==nil) or tmp==false or tokens[bk][1]=="EOF" then
if tokens[bk][1]~="EOF" then
error("[HL] line "..tokens[bk].line..": some syntax error occured.")
print("line "..tokens[bk].line..": some syntax error occured.")
os.exit(1)
end
ptr=bk
break
@ -265,7 +267,8 @@ function interpret(ast,imports)
end
end
local function throwerror(reason)
error("[HL] line "..cline..": "..reason)
print("line "..cline..": "..reason)
os.exit(1)
end
local function get(k)
local t=top()
@ -298,6 +301,7 @@ function interpret(ast,imports)
["number"]="number",
["boolean"]="bool",
["table"]="list",
["function"]="function",
})[type(v)],value=v})
end
end
@ -363,7 +367,7 @@ function interpret(ast,imports)
if x and x.type=="list" then
local res={type="list",value={}}
for i,v in pairs(x.value) do
table.insert(res.value,i)
table.insert(res.value,to(i))
end
return res
end
@ -419,7 +423,7 @@ function interpret(ast,imports)
tmp[#tmp+1]="(function)"
end
end
print(#args>0 and unpack(tmp) or "nil")
print(unpack(tmp))
return {type="bool",value=true}
end,
["type"]=function(x)
@ -574,4 +578,4 @@ end
local function run(x,lua)
return interpret(into_ast(tokenize(x)),lua)
end
return {run=run, interpret=interpret, into_ast=into_ast, tokenize=tokenize}
return {run=run}