nomsu/lib/plurals.nom
2018-01-07 16:51:29 -08:00

25 lines
697 B
Plaintext

require "lib/core.nom"
# Plurals
using:
<%endings> = (chain {x="es",c="es",s="es"} to "s")
<%plurals> = (chain {} to (: "\%\((<%endings>)->(%| -1|))"))
<%singulars> = (..)
chain {} to:
when:
* (((%| -2|) == "es") and (=lua"rawget(\(<%endings>), \(%| -3|))")):
%|1 - -3|
* (%| -1| == "s"):
%|1 - -2|
else: %
..do:
rule [the plural of %singular is %plural] =:
(<%plurals>)->%singular = %plural
(<%singulars>)->%plural = %singular
rule [singular %plural] =:
(<%singulars>)->%plural
rule [plural %singular] =:
(<%plurals>)->%singular