Module:xum-forms

return { forms = function (frame)

local format_link = require("Module:links").full_link; local lang_xum = require("Module:languages").getByCode('xum'); local function check_error(condition) if condition then error("The input is bad."); end end

local args = frame:getParent.args;

local format_variety = %s ; local varieties = { eig = format_variety:format("early Iguvine", "e.Ig."), lig = format_variety:format("late Iguvine", "l.Ig."), vel = format_variety:format("Velitraean", "Vel."), };

local r = ""; local is_case_first = true; for _, case in ipairs(args) do if is_case_first then is_case_first = false; else r = r .. "\n"; end

local case_value; if (case:find("^[^/]+/[^/]+$")) then case_value = case:gsub(".+/", ""); local case_name = case:gsub("/.+", ""); local case_tags = {}; for case_tag in case_name:gmatch("[^ ]*") do				table.insert(case_tags, case_tag); end r = r .. "* " .. frame:expandTemplate { title = "q", args = { (require("Module:form of").tagged_inflections({ lang = lang_xum, tags = case_tags, nocat = true })					:gsub("%s+ $", " ")) -- TODO: why does the function print a space in the first place? } } .. " ";		elseif (case:find("^[^/]+$")) then case_value = case; else check_error(true); end

local is_variety_first = true; for variety in case_value:gmatch("[^.]+") do if is_variety_first then is_variety_first = false; else r = r .. "; "; end

check_error(not variety:find("^[^:]+:[^:]+$")); local variety_name = varieties[variety:gsub(":.+", "")]; check_error(variety_name == nil); r = r .. variety_name .. " ";

local variety_value = variety:gsub(".+:", "");

local is_form_first = true; for form in variety_value:gmatch("[^,]+") do if is_form_first then is_form_first = false; else r = r .. ", "; end r = r .. format_link { lang = lang_xum, term = form }; end end end return r;

end };