Trying out kotlin and nim
This commit is contained in:
parent
a5c3c0c9b9
commit
3219555785
80
dictionary.kts
Normal file
80
dictionary.kts
Normal file
|
@ -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
|
||||
}
|
74
dictionary.nim
Normal file
74
dictionary.nim
Normal file
|
@ -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:
|
20
dsl.kt
Normal file
20
dsl.kt
Normal file
|
@ -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<Feature>,
|
||||
) {
|
||||
constructor(t: GlyphType, u: String, vararg f: Feature) : this(t, u, f) {}
|
||||
}
|
37
dsl.nim
Normal file
37
dsl.nim
Normal file
|
@ -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
|
Loading…
Reference in a new issue