1
0
mirror of https://github.com/HybridDog/pdisc.git synced 2025-07-02 16:20:41 +02:00

buxfixes and more instructions

M  README.md
M  faden.lua
M  parser.lua
M  standardbefehlssatz.lua
This commit is contained in:
Hybrid Dog
2016-12-28 18:27:41 +01:00
parent d57e096706
commit 53c47b17ab
4 changed files with 115 additions and 13 deletions

View File

@ -25,12 +25,73 @@ s = {
if t1 == "number" then
return true, p1 + p2
end
if t1 == "string" then
return true, p1 .. p2
if t1 == "boolean" then
return true, p1 and p2
end
return true, p1 .. p2
end,
mul = function(params)
if #params ~= 2 then
return false, WNOA
end
local p1,p2 = unpack(params)
local t1 = type(p1)
local t2 = type(p2)
if t1 == "string"
and t2 == "number" then
return true, p1:rep(p2)
end
if t1 ~= t2 then
return false, "different argument types"
end
if t1 == "number" then
return true, p1 * p2
end
if t1 == "boolean" then
return true, p1 or p2
end
return false, UAT
end,
neg = function(params)
if #params ~= 1 then
return false, WNOA
end
local v = params[1]
local t = type(v)
if t == "number" then
return true, -v
end
if t == "boolean" then
return true, not v
end
return true, v:rev()
end,
inv = function(params)
if #params ~= 1 then
return false, WNOA
end
local p = params[1]
if type(p) ~= "number" then
return false, UAT
end
return true, 1 / p
end,
mod = function(params)
if #params ~= 2 then
return false, WNOA
end
local p1,p2 = unpack(params)
if type(p1) ~= "number" or type(p2) ~= "number" then
return false, UAT
end
return true, p1 % p2
end,
jmp = function(params, faden)
if #params ~= 1 then
return false, WNOA
@ -131,8 +192,39 @@ s = {
return true
end,
tostring = function(params)
if #params ~= 1 then
return false, WNOA
end
return true, tostring(params[1])
end,
print = function(params, faden)
for i = 1,#params do
params[i] = tostring(params[i])
end
faden.log = faden.log .. table.concat(params, "\t") .. "\n"
return true
end,
flush = function(params, faden)
return faden:flush(params)
end,
}
local so_math_fcts = {"sin", "asin", "cos", "acos", "tan", "atan",
"abs", "sign", "floor", "ceil"}
for i = 1,#so_math_fcts do
i = so_math_fcts[i]
s[i] = function(params)
if #params ~= 1 then
return false, WNOA
end
local p = params[1]
if type(p) ~= "number" then
return false, UAT
end
return true, math[i](p)
end
end
return s