From 3219555785ac31c40fa1b5a52b4a21c1ade6f4ca Mon Sep 17 00:00:00 2001 From: Louis Burke Date: Wed, 27 Mar 2024 01:26:58 -0400 Subject: [PATCH] Trying out kotlin and nim --- dictionary.kts | 80 ++++++++++++++++++++++++++++++++++++++++++++++++++ dictionary.nim | 74 ++++++++++++++++++++++++++++++++++++++++++++++ dsl.kt | 20 +++++++++++++ dsl.nim | 37 +++++++++++++++++++++++ 4 files changed, 211 insertions(+) create mode 100644 dictionary.kts create mode 100644 dictionary.nim create mode 100644 dsl.kt create mode 100644 dsl.nim diff --git a/dictionary.kts b/dictionary.kts new file mode 100644 index 0000000..d6af80f --- /dev/null +++ b/dictionary.kts @@ -0,0 +1,80 @@ +#!/usr/bin/kscript + +@file:Import("dsl.kt") + +glyphs { // in font encoding and alphabetical order + // bare vowels + glyph(vowel, "i", outer) + glyph(vowel, "e", outer, slashed) + glyph(vowel, "a", slashed) + glyph(vowel, "o", `inner`, slashed) + glyph(vowel, "u", `inner`) + glyph(vowel, "y", both) + + // consonant clusters (note: both core can be written with a dot in most cases) + glyph(cluster, "θ", left, top) + glyph(cluster, "∫", left, middle) + glyph(cluster, "x", left, bottom) + glyph(cluster, "n", center, middle) + glyph(cluster, "p", right, top) + glyph(cluster, "t", right, middle) + glyph(cluster, "k", right, bottom) + glyph(cluster, "θl", left, top, tall) + glyph(cluster, "∫l", left, middle, tall) + glyph(cluster, "xl", left, bottom, tall) + glyph(cluster, "nl", center, middle, tall) + glyph(cluster, "pl", right, top, tall) + glyph(cluster, "tl", right, middle, tall) + glyph(cluster, "kl", right, bottom, tall) + glyph(cluster, "θr", left, top, wide) + glyph(cluster, "∫r", left, middle, wide) + glyph(cluster, "xr", left, bottom, wide) + glyph(cluster, "nr", center, middle, wide) + glyph(cluster, "pr", right, top, wide) + glyph(cluster, "tr", right, middle, wide) + glyph(cluster, "kr", right, bottom, wide) + glyph(cluster, "sθ", left, top, both) + glyph(cluster, "s∫", left, middle, both) + glyph(cluster, "sx", left, bottom, both) + glyph(cluster, "sn", center, middle, both) + glyph(cluster, "sp", right, top, both) + glyph(cluster, "st", right, middle, both) + glyph(cluster, "sk", right, bottom, both) + + syllables() + + glyph(punctuation, "«", left) + glyph(punctuation, ".") + glyph(punctuation, "»", right) + + glyph(numeric, "0", circle) + glyph(numeric, "1", dash) + glyph(numeric, "2", vee) + glyph(numeric, "3", hump) + glyph(numeric, "4", dash, hump) + glyph(numeric, "5", vee, hump) + glyph(numeric, ".", dump) +} + +dialect("jukashenikan") { + replace("x", "ç") + replace("p", "j") + // ... +} + +dialect("gazhenigan") { + replace("k", "g") + replace("∫", "ʒ") + replace("s", "z") + replace("θ", "ð") + replace("t", "d") + // ... +} + +romanization { + // TODO +} + +dictionary { + // TODO +} diff --git a/dictionary.nim b/dictionary.nim new file mode 100644 index 0000000..061d94b --- /dev/null +++ b/dictionary.nim @@ -0,0 +1,74 @@ +import dsl +import macros + +dumpTree: # dictionary: + glyphs: + vowel "i" outer + vowel "e" outer slashed + vowel "a" slashed + vowel "o" inner slashed + vowel "u" inner + vowel "y" both + + cluster θ left top + cluster ∫ left middle + cluster x left bottom + cluster n center middle + cluster p right top + cluster t right middle + cluster k right bottom + cluster θl left top tall + cluster ∫l left middle tall + cluster xl left bottom tall + cluster nl center middle tall + cluster pl right top tall + cluster tl right middle tall + cluster kl right bottom tall + cluster θr left top wide + cluster ∫r left middle wide + cluster xr left bottom wide + cluster nr center middle wide + cluster pr right top wide + cluster tr right middle wide + cluster kr right bottom wide + cluster sθ left top both + cluster s∫ left middle both + cluster sx left bottom both + cluster sn center middle both + cluster sp right top both + cluster st right middle both + cluster sk right bottom both + + syllables + + punctuation « left + punctuation `.` + punctuation » right + + numeric 0 circle + numeric 1 dash + numeric 2 vee + numeric 4 dash hump + numeric 5 vee hump + numeric `.` dump + + dialect jukashenikan: + replace x ç + replace p j + # ... + + dialect gazhenigan: + replace k g + replace ∫ ʒ + replace s z + replace θ ð + replace t d + # ... + + romanization: + discard # ... + + dictionary: + discard # ... + +#when isMainModule: diff --git a/dsl.kt b/dsl.kt new file mode 100644 index 0000000..93b7496 --- /dev/null +++ b/dsl.kt @@ -0,0 +1,20 @@ +class Database { +} + +enum class GlyphType(val repr: String) { + Vowel("vowel"), + Cluster("cluster"), + Syllable("syllable"), + Punctuation("punctuation"), + Numeric("numeric"), +} + +open class Feature + +data class Glyph( + val type: GlyphType, + val unicode: String, + val features: Array, +) { + constructor(t: GlyphType, u: String, vararg f: Feature) : this(t, u, f) {} +} diff --git a/dsl.nim b/dsl.nim new file mode 100644 index 0000000..2a7b790 --- /dev/null +++ b/dsl.nim @@ -0,0 +1,37 @@ +import std/macros +import std/genasts + +type + VowelAttribute* = enum Outer, Slashed, Inner + GlyphKind* = enum Vowel + Glyph* = object + spelling*: string + case kind*: GlyphKind + of Vowel: vattrs*: set[VowelAttribute] + + Dictionary* = object + glyphs*: seq[Glyph] + +template dictionary*(body: untyped) = + var dict {.inject.}: Dictionary + dict.glyphs = @[] + + macro vowel(arg: untyped) = + var v: Glyph = Glyph(spelling: arg[0].strVal) + echo arg.treeRepr + + # TODO: populate attributes of v, then implement similar for other glyphs + + let x = newLit(v) + result = genAst(x): + dict.glyphs.add `x` + + echo result.repr + + body + +when isMainModule: + dictionary: + vowel "x" outer slashed inner + + echo dict