Module:xum-decl

local export = {};

local format_g = require("Module:gender and number").format_list; local format_link = require("Module:links").full_link; local lang = require("Module:languages").getByCode('xum');

-- these are the noun and adjective declension local cases = {} cases.nom = "nominative"; cases.gen = "genitive"; cases.dat = "dative"; cases.acc = "accusative"; cases['acc-en'] = "accusative + ''" .. format_link({ term = "-en", lang = lang }) .. "";	cases['acc-ars'] = "accusative + " .. format_link({ term = "-ař", lang = lang }) .. "''";	cases.abl = "ablative"; cases['abl-kom'] = "ablative + ''" .. format_link({ term = "-kom", lang = lang }) .. "";	cases['abl-per'] = "ablative + " .. format_link({ term = "-per", lang = lang }) .. "''";	cases.ablkom = "ablative"; -- ??? cases.voc = "vocative"; cases['loc-en'] = "locative + ''" .. format_link({ term = "-en", lang = lang }) .. "";	cases['loc-en?'] = "locative (+ " .. format_link({ term = "-en", lang = lang }) .. "''?)";

local function case_string(str) if (str:match("-s$")) then return cases[str:gsub("-s$", "")] .. " sigular"; elseif (str:match("-p$")) then return cases[str:gsub("-p$", "")] .. " plural"; end if (str:match("-mf")) then return cases[str:gsub("-mf", "")] .. ' m./f. ';	elseif (str:match("-n")) then return cases[str:gsub("-n", "")] .. " neuter"; end return cases[str]; end

-- these are the verb forms local forms = {} forms['3s-impv'] = '3s impv. fut. '	forms['3p-impv'] = '3p impv. fut. '	forms['2s-fut'] = '2s indc. fut. '	forms['3p-fut-pas'] = '3p indc. fut. pass. '	forms['3s-fut-perf'] = '3s perf. fut. '	forms['3p-fut-perf'] = '3p perf. fut. '	forms['3s-subj'] = '3s subj. pres. '	forms['inf'] = ' inf. pres. '	forms['pp'] = "past participle" forms['3s-fut-perf-pas'] = '3s perf. fut. pass. '

local function form_string(str) return forms[str]; end

-- these are the varieties local function format_varname(short, long) return ''' .. short .. "'' "; end

local varieties = {} varieties.eig = format_varname("e.Ig.", "early Iguvine"); varieties.lig = format_varname("l.Ig.", "late Iguvine"); varieties.vel = format_varname("Vel.", "Velitraean");

-- this prints all the attested spellings of only one variety local function format_var(str) local o = varieties[str:gsub(":.+", "")] .. " ";	for k in string.gmatch(str:gsub(".+:", ""), "[^, ]+") do o = o .. format_link({ term = k, lang = lang }) .. ", ";	end return o:sub(1, -3); -- remove final comma

end

-- this prints all of attested spellings of one form local function format_allvars(str) local value = ''; for k in string.gmatch(str, "[^.]+") do value = value .. format_var(k) .. " ";	end return value:sub(1, -6); -- remove final end

-- these three functions help build the wikitable local function make_margin(str) return ' ' .. str .. ' '; end

local function start_table(i, lemma, lemmatized, gendr) return '{| class="inflection-table" style="background: #FAFAFA; border: 1px solid #d0d0d0; text-align: left;' .. (i and 'margin-top:0px; margin-bottom: 0px; width:100%;' or '') .. '"\n|- style="background: #CCC;"\n! colspan="3" | ' .. make_margin('Inflection of ' .. lemma .. '? ' .. gendr) .. '\n'; end

local function start_line(string, second) return '|-\n! style="background-color: #eff7ff;" | ' .. make_margin(string) .. '\n|' .. second .. '\n'; end

-- entry point for function export.show(frame)

local args = frame:getParent.args;

local lemma = "''" .. args[1] .. "''";	local lemma_g = format_g({args[2]});

local o = start_table(args.i, lemma, 'accusaitve', lemma_g);

local i = 3; local arg_i = args[i]; while (arg_i) do o = o .. start_line(case_string(arg_i:gsub("/.+", "")), make_margin(format_allvars(arg_i:gsub(".+/", "")))); i = i + 1; arg_i = args[i]; end

return o .. '|}';

end

-- entry point for function export.show_verb(frame)

local args = frame:getParent.args;

local lemma = "''" .. args[1] .. "''";

local o = start_table(false, lemma, 'present infinitive', '');

local i = 2; local arg_i = args[i]; while (arg_i) do o = o .. start_line (form_string(arg_i:gsub("/.+", "")), arg_i:match("//") and arg_i:gsub(".+//", "") or make_margin(format_allvars(arg_i:gsub(".+/", "")))); i = i + 1; arg_i = args[i]; end

return o .. '|}';

end

-- entry point for function export.show_invar(frame)

return '*' .. format_allvars(frame:getParent.args[1]);

end

return export;