La documentació d'ús d'aquest mòdul es pot crear a Mòdul:ca-verb/morir/ús

-- Formes irregulars del verb morir i premorir.
local export = {}

local function llista_zones(llista, zona)
	local zones = {}
	for k, v in pairs(llista) do
		if zona[v == "or" and "ori" or v == "n-occ" and "nocc" or v] then
			table.insert(zones, v)
		end
	end
	return #zones > 3 and "" or table.concat(zones, ", ")
end

function export.make_irregulars(forma, zona)
	local radical = forma.inf:gsub("ir$", "")
	local radical_u = radical:gsub("o", "ui")
	local radical_u_velar = radical_u:gsub("r$", "")

	forma.part[1]["m-s"] = radical .. "t"
	forma.part[1]["f-s"] = radical .. "ta"
	forma.part[1]["m-p"] = radical .. "ts"
	forma.part[1]["f-p"] = radical .. "tes"
	
	if (zona.bal or zona.alg) and zona.val then
		forma["pres-ind"][2]["nota"] = llista_zones({"bal", "alg"}, zona)
	end
	
	fila = #forma["pres-ind"] + 1
	if zona.val then
		forma["pres-ind"][fila] = {}
		forma["pres-ind"][fila][1] = radical_u
		forma["pres-ind"][fila]["nota"] = "val"
	end
	
	if zona.occ then
		forma["pres-subj"][2]["nota"] = "n-occ"
		if zona.val then
			forma["pres-subj"][3] = {}
			forma["pres-subj"][3][1] = radical_u .. "a"
			forma["pres-subj"][3][2] = radical_u .. "es"
			forma["pres-subj"][3][3] = radical_u .. "a"
			forma["pres-subj"][3][6] = radical_u .. "en"
			forma["pres-subj"][3]["nota"] = "val"
		end
	end
	
	fila = #forma["pres-subj"] + 1
	if zona.bal then
		forma["pres-subj"][fila] = {}
		forma["pres-subj"][fila][1] = radical_u .. "i"
		forma["pres-subj"][fila][2] = radical_u .. "is"
		forma["pres-subj"][fila][3] = radical_u .. "i"
		forma["pres-subj"][fila][4] = radical .. "iguem"
		forma["pres-subj"][fila][5] = radical .. "igueu"
		forma["pres-subj"][fila][6] = radical_u .. "in"
		forma["pres-subj"][fila]["nota"] = "bal"
	end
	
	fila = 2
	if zona.nocc then
		forma["imp"][2] = {}
		forma["imp"][2][3] = radical .. "a"
		forma["imp"][2][6] = radical .. "en"
		forma["imp"][2]["nota"] = "n-occ"
		fila = fila + 1
	end
	if zona.val then
		forma["imp"][fila] = {}
		forma["imp"][fila][2] = radical_u
		forma["imp"][fila][3] = radical_u .. "a"
		forma["imp"][fila][6] = radical_u .. "en"
		forma["imp"][fila]["nota"] = "val"
		fila = fila + 1
	end
	if zona.bal then
		forma["imp"][fila] = {}
		forma["imp"][fila][3] = radical_u .. "i"
		forma["imp"][fila][4] = radical .. "iguem"
		forma["imp"][fila][6] = radical_u .. "in"
		forma["imp"][fila]["nota"] = "bal"
	end
	
	if zona.centr or zona.nocc or zona.bal then
		forma["no-ger"] = radical .. "iguent"
	end
	
	if zona.centr or zona.nocc then
		forma["no-part"] = {}
		forma["no-part"]["m-s"] = radical .. "it"
		forma["no-part"]["f-s"] = radical .. "ida"
		forma["no-part"]["m-p"] = radical .. "its"
		forma["no-part"]["f-p"] = radical .. "ides"
		forma["no-part"]["nota"] = llista_zones({"centr", "n-occ"}, zona)
	end
	
	if zona.val or zona.alg then
		forma["no-pres-ind"] = {}
		fila = 1
		if zona.val then
			forma["no-pres-ind"][1] = {}
			forma["no-pres-ind"][1][1] = radical_u_velar .. "c"
			forma["no-pres-ind"][1]["nota"] = "val"
			forma["no-pres-ind"][2] = {}
			forma["no-pres-ind"][2][1] = radical .. "c"
			forma["no-pres-ind"][2]["nota"] = "val"
			fila = 3
		end
		if zona.alg then
			forma["no-pres-ind"][fila] = {}
			forma["no-pres-ind"][fila][2] = radical .. "is"
			forma["no-pres-ind"][fila]["nota"] = "alg"
		end
	end
	
	if zona.occ then
		forma["no-pres-subj"] = {}
		fila = 1
		if zona.nocc then
			forma["no-pres-subj"][1] = {}
			forma["no-pres-subj"][1][1] = radical .. "ga"
			forma["no-pres-subj"][1][2] = radical .. "gues"
			forma["no-pres-subj"][1][3] = radical .. "gue"
			forma["no-pres-subj"][1][4] = radical .. "guem"
			forma["no-pres-subj"][1][5] = radical .. "gueu"
			forma["no-pres-subj"][1][6] = radical .. "guen"
			forma["no-pres-subj"][1]["nota"] = "n-occ"
			fila = 2
		end
		if zona.val then
			forma["no-pres-subj"][fila] = {}
			forma["no-pres-subj"][fila][1] = radical_u_velar .. "ga"
			forma["no-pres-subj"][fila][2] = radical_u_velar .. "gues"
			forma["no-pres-subj"][fila][3] = radical_u_velar .. "ga"
			forma["no-pres-subj"][fila][4] = radical_u_velar .. "guem"
			forma["no-pres-subj"][fila][5] = radical_u_velar .. "gueu"
			forma["no-pres-subj"][fila][6] = radical_u_velar .. "guen"
			forma["no-pres-subj"][fila]["nota"] = "val"
			fila = fila + 1
		end
	end
	
	forma["no-imperf-subj"][1]["nota"] = llista_zones({"centr", "bal"}, zona)
	if zona.alg then
		forma["no-imperf-subj"][2]["nota"] = "alg"
	end
	fila = 3
	if zona.nocc then
		forma["no-imperf-subj"][3] = {}
		forma["no-imperf-subj"][3][1] = radical .. "issa"
		forma["no-imperf-subj"][3]["nota"] = "n-occ"
		fila = 4
	end
	if zona.val then
		forma["no-imperf-subj"][fila] = {}
		forma["no-imperf-subj"][fila][1] = radical .. "guera"
		forma["no-imperf-subj"][fila][2] = radical .. "gueres"
		forma["no-imperf-subj"][fila][3] = radical .. "guera"
		forma["no-imperf-subj"][fila][4] = radical .. "guérem"
		forma["no-imperf-subj"][fila][5] = radical .. "guéreu"
		forma["no-imperf-subj"][fila][6] = radical .. "gueren"
		forma["no-imperf-subj"][fila]["nota"] = "val"
	end
	
	return forma
end

return export