Piznium source codes for versions/14-03-2022

Compiled at 14 March 2022 9:48 UTC -- Define variables code = {} -- The code Sent Lua will execute logs = {} -- Some logs doing = 0 -- The current line we're doing status = 6 -- The status of the compilation

olr = {} -- One line ram ram = {} -- Many line ram i = 0 -- i, Index, used in loops installed = {} -- All installed modules currently

hasComment = false -- Whether the line we're doing has a comment module = "" -- The module of the given line command = "" -- The command of the given line params = {} -- The parameters of the given line

-- Configs which shouldn't really be changed but ok useStrictMode = false deleteIndents = true maxCodeLength = 10000

showLogs = true -- TEMPORARY - disable when actual usage showErrors = true showStatusOnEnd = true

-- Define modules modules = { "sys", "main", "math", "tt", "time", }

-- Get code (TEMPORARY) code = { "main.main", "main.print.hi haha", }

-- Logging functions and replace function log(message) table.insert(logs,message) if showLogs then print("Something logged: " .. message) end end

function error(message) table.insert(logs,message) if showErrors then print("Error at line " .. doing .. ": \n " .. message) end end

function replace(str,from,to) -- Basically string.gsub - same params, same usage, this exists because string.gsub is kinda a confusing name. noNumAfter = string.gsub(str,from,to) return noNumAfter end

-- Generic table functions function tableLength(table) local count = 0 for i in pairs(table) do   count = count + 1 end return count end

codelen = tableLength(code) -- The length of the code given

if codelen > maxCodeLength then error("Code is too long, max length is " .. maxCodeLength .. ". Proceeding to not execute following code.") return end

function displayTable(table) for i in pairs(table) do     print(table[i]) end end

-- Prepare strict mode and delete indents if enabled if useStrictMode then -- Meh, nothing for now (TEMPORARY) end if deleteIndents then for i in pairs(code) do   code[i] = code[i]:gsub("%s*","") end end

-- Parameter tool functions function param(index) return params[index] -- TEMPORARY - need more checks here etc end

function paramType(index) return "str" -- TEMPORARY end

underscoreVars = { "dot", "dashslash", } underscoreHas = { ".", "-/-", }

function parseFormatStr(string) -- Parse formatted strings -- Includes both underscore vars and normal vars local parsing = string local doing = 1 repeat parsing = replace(parsing,"{_" .. underscoreVars[doing] .. "}",underscoreHas[doing]) doing = doing + 1 until doing > tableLength(underscoreVars) return parsing end

-- Globally used generic but pretty useful functions function strSplit(inputstr,sep) local t = {} for str in string.gmatch(inputstr, "([^"..sep.."]+)") do   table.insert(t, str) end return t end

function isAllSpaces(str) -- All spaces or blank local removedLength = string.len(string.gsub(str,"%s","")) if removedLength == 0 then return true else return false end end

-- Execute function function execFunc(module,command,params) if module == "main" then if command == "main" then error("Unexpected main.main call.") elseif command == "print" then if paramType(1) == "str" then print(param(1)) elseif paramType(1) == "num" then print(tostring(param(1))) else error("Needed string or number, got " .. paramType(1) .. ".") end end else error("The module \"" .. module .. "\" doesn't exist, but is called up.") end end

repeat -- Increment the current line and is it a blank line or comment doing = doing + 1 if isAllSpaces(code[doing]) then hasComment = true log("Line " .. doing .. " is a blank line.") else hasComment = false

-- Get module, command, and params params = strSplit(code[doing],".") if params[1] == nil then module = "main" command = "main" else module = params[1] table.remove(params,1) if params[1] == nil then command = "main" else command = params[1] end table.remove(params,1) end -- Check if a module is requested to be installed or the given module is installed -- if module == "install" then --   table.insert(installed,command) --   return -- end -- if installed[module] == nil then --   error("Module " .. module .. " is not installed.") -- end -- TEMPORARY - IT DOESNT WORK YET -- Is it a coating -- TEMPORARY - NOT IMPLEMENTED YET

-- It is a function and we have everything properly set up for the function runner, so run it! execFunc(module,command,params) end until doing >= codelen