@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.
39 lines (38 loc) • 1.01 kB
JavaScript
import { deepFreezeAndNullPrototype } from "../../generate/helpers/deep-freeze.js";
const CN_TO_CASE_SCOPE = /* @__PURE__ */ deepFreezeAndNullPrototype({
h: "CCN",
hl: "CCA",
hr: "CCS",
hm: "CCQ",
hn: "CCP",
hň: "CCV",
});
const CN_TO_ASPECTUAL_CASE_SCOPE = /* @__PURE__ */ deepFreezeAndNullPrototype({
w: "CCN",
y: "CCN",
hw: "CCA",
hrw: "CCS",
hmw: "CCQ",
hnw: "CCP",
hňw: "CCV",
});
/**
* Parsed a Cn form as a case scope.
*
* @param cn The Cn form to be parsed.
* @returns An array containing the parsed case scope and a boolean value
* indicating whether the case scope indicates the corresponding Vn form is an
* aspect.
*/
export function parseCaseScope(cn) {
if (cn in CN_TO_CASE_SCOPE) {
return [CN_TO_CASE_SCOPE[cn], false];
}
if (cn in CN_TO_ASPECTUAL_CASE_SCOPE) {
return [
CN_TO_ASPECTUAL_CASE_SCOPE[cn],
true,
];
}
throw new Error("Invalid Cn: '" + cn + "'.");
}