shenikan/dsl.cue
2024-09-16 22:10:11 -04:00

150 lines
2.9 KiB
CUE

package shenikan
import ( "strings"
// Generate json output via `cue export -p shenikan`
)
dictionary: {
_glyphs: vowel: [Orthography=_]: [...#VowelAttribute] | *null
_glyphs: cluster: [Orthography=_]: [...#ClusterAttribute] | *null
_glyphs: punctuation: [Orthography=_]: [...#PunctuationAttribute] | *null
_glyphs: numeric: [Orthography=_]: [...#NumericAttribute] | *null
glyphs: [
for k, datum in _glyphs
for o, glyph in datum {
kind: k
ortho: o
attrs: glyph
},
for v, vglyph in _glyphs.vowel
for c, cglyph in _glyphs.cluster {
kind: "syllable"
ortho: c + v
attrs: vglyph + cglyph
},
]
_dialects: [Name=_]: [Old=_]: string
dialects: [
for d, dialect in _dialects {
name: d
replacements: [
for o, n in dialect {
old: o
new: n
},
]
},
]
#RawDefinition: string | {[string]: string} | *""
_words: [Orthography=_]: {
[#PartOfSpeech]: #RawDefinition
}
// create { _defn: ..., { _#Definition } } to populate a proper definition
_#Definition: {
_defn: string | {[string]: string}
short: _defn & string | [for brief, long in _defn {brief}][0]
_long: *([for brief, long in _defn {long}][0]) | null
if _long != null {
long: _long
}
}
words: [
for o, word in _words {
spelling: o
definitions: [
for p, defn in word {
_defn: defn
pos: p
{_#Definition}
},
]
},
for o, penta in _pentas
for v in _vowels
if penta["\(v)"] != null {
spelling: strings.Replace(o, " ", v, 1)
definitions: [
for p, defn in penta["\(v)"] {
_defn: defn
pos: p
{_#Definition}
},
]
},
for o, icosa in _icosas
for v1 in _vowels
for v2 in _vowels
if icosa["\(v1)\(v2)"] != null {
spelling: strings.Replace(strings.Replace(o, " ", v1, 1), " ", v2, 1)
definitions: [
for p, defn in icosa["\(v1)\(v2)"] {
_defn: defn
pos: p
{_#Definition}
},
]
},
]
_pentas: [Orthography=_]: {
name?: string
extremes: {
i?: string
u?: string
}
for v in _vowels {
"\(v)": {[#PartOfSpeech]: #RawDefinition} | *null
}
}
pentas: [
for o, penta in _pentas {
if penta.name != _|_ {name: penta.name}
if penta.extremes != _|_ {
extremes: {
if penta.extremes.i != _|_ {i: penta.extremes.i}
if penta.extremes.u != _|_ {u: penta.extremes.u}
}
}
},
]
_icosas: [Orthography=_]: {
name?: string
extremes: {
ix?: string
ux?: string
xi?: string
xu?: string
}
for v1 in _vowels
for v2 in _vowels {
"\(v1)\(v2)": {[#PartOfSpeech]: #RawDefinition} | *null
}
}
icosas: [
for o, icosa in _icosas {
if icosa.name != _|_ {name: icosa.name}
if icosa.extremes != _|_ {
extremes: {
if icosa.extremes.ix != _|_ {ix: icosa.extremes.ix}
if icosa.extremes.ux != _|_ {ux: icosa.extremes.ux}
if icosa.extremes.xi != _|_ {xi: icosa.extremes.xi}
if icosa.extremes.xu != _|_ {xu: icosa.extremes.xu}
}
}
},
]
}