local a = "a
local module =
function unknown return "(unknown label)"end
function syntaxerror(text) return "(syntax error: "..text..")"end
function tableReverseFind(Table, callbackTable) if type(callbackTable) ~= "table" then callbackTable = end
for key, val in ipairs(callbackTable) do if type(val) ~= "function" then callbackTable[key] = function(findParam) return findParam
local key = #Table while key > 0 do for _, val in ipairs(callbackTable) do if val(Table[key], key) then return Table[key] end end key = key - 1 end return falseend
module.inputs =
module.inputs.thing =
function module.inputs.thing.main(data) local thing = module.inputs.thing[math.random(#module.inputs.thing)] local singularRequired = false local pluralRequired = false tableReverseFind(data.pointers, function(item, i) if item
that then singularRequired = true elseif item
those then pluralRequired = true return true end end ) if not singularRequired and (pluralRequired or math.random > .5) then return thing.plural end return thing.singend
module.structures =
module.structureNames =
local function pointer(text) local ret = function ret.char(offset) offset = offset or 0 return string.sub(ret.text, ret.position + offset, ret.position + offset) end
function ret:read(unt) if type(unt) ~= "table" then unt = end
for key, val in ipairs(unt) do if type(val) ~= "function" then unt[key] = function(char) return char
local function check local char = self.char if char
local txtRead = "" local charTest = check if charTest then return "" end
repeat txtRead = txtRead .. self.char self.position = self.position + 1 until check
return txtRead end
function ret:find(chars) self:read(chars) return self.position end
return retend
local pointReach = falsefunction chance_number(char) if char ~= "0" and char ~= "1" and char ~= "2" and char ~= "3" and char ~= "4" and char ~= "5" and char ~= "6" and char ~= "7" and char ~= "8" and char ~= "9" and char ~= "." then return true endend
function module.generate(frame) frame = frame or local args = frame.args math.randomseed(args.seed or os.time) local stru = module.structureNames local structure = stru[math.random(#stru)] local text = module.structures[structure] local parser = pointer(text) local rep = "" local output = "" local data = mw.log(parser.text) local i = 0 while parser.text:find("<") and i < 100 do i = i + 1 local Start = parser:find("<") parser.position = parser.position + 1 local labels = local label = parser:read(function(char) return char
">" end) local err = nil if parser.char ~= ">" and parser.char(1) ~= ">" then local expr = nil parser:read(function(char) if char
nil then return end
if char
if char
chance_number and parser.char
chance_number and err ~= nil then output = tonumber(output) if output
mw.log(parser.text:sub(Start, parser.position)) parser.text = parser.text:gsub(parser.text:sub(Start, parser.position), rep )
parser.position = 1 end mw.log(parser.text)end
return module