Module:Gearmáinis

Ón Vicífhoclóir, an foclóir ábhair shaor.

Documentation for this module may be created at Module:Gearmáinis/doc

local p = {}

function setArgs(argTable)
	return {
		["args"] = ((type(argTable) == type({})) and argTable) or {argTable}
	}
end

function p.shiftNil(frame)
	local value = frame.args[1]
	local default = frame.args[2] or ""
	local emptiedPattern = frame.args[3] or " "
	if value then
		if mw.ustring.match(value, emptiedPattern, 1) then
			return ""
		end
		return value
	end
	return default
end

function p.suffixVerb(frame)
	local root = frame.args[1]
	local suffix = frame.args[2]
	local touch = mw.ustring.sub(root, -1)
	if touch == mw.ustring.sub(suffix, 1, 1) then
		if touch == "e" or touch == "s" then
			return root .. mw.ustring.sub(suffix, 2)
		elseif touch == "t" then
			return root .. "e" .. suffix
		end
	end
	return root .. suffix
end

function p.test(frame)
	frame = frame or {["args"] = {"schalt", "t"}}
	return p.shiftNil(
		setArgs(
			{
				p.suffixVerb(setArgs({frame.args[1], frame.args[2]})),
				"leer",
				"leer"
			}
		)
	)
end

return p