@zsnout/ithkuil
Version:
A set of tools which can generate and parse romanized Ithkuil text and which can generate Ithkuil script from text and JSON data.
34 lines (33 loc) • 1.08 kB
JavaScript
import { parseAffix } from "../formative/affix.js";
import { singleAffixAffixualAdjunct } from "../lex/adjunct/single-affix.js";
import { VowelForm } from "../vowel-form.js";
const VS_TO_SCOPE_MAP = {
undefined: undefined,
a: "V:DOM",
u: "V:SUB",
e: "VII:DOM",
i: "VII:SUB",
o: "FORMATIVE",
ö: "ADJACENT",
};
/**
* Builds a single-affix affixual adjunct.
*
* @param word The word to be built.
* @param stress The stress of the adjunct.
* @returns Either a parsed `AffixualAdjunct` indicating a success, or
* `undefined` indicating a tokenization failure. Throws if the adjunct was
* successfully tokenized but had another error in it (e.g. invalid Cs slot,
* etc.).
*/
export function buildSingleAffixAffixualAdjunct(word, stress) {
const match = singleAffixAffixualAdjunct.exec(word);
if (!match) {
return;
}
return {
affixes: [parseAffix(VowelForm.parseOrThrow(match[1]), match[2], false)],
scope: VS_TO_SCOPE_MAP[match[3]],
appliesToConcatenatedStemOnly: stress == "ultimate",
};
}