let's give our term type a translate method. it takes a string
and returns a TRANSLATED string.
/**
* @typedef {object} Term
* ...
* @property {(text: string) => string} translate
*/
we'll add it to our "string" term. we'll [just] get it to emit the string for now.
Term.string = (string) => ({
//...
translate(text) {
const bites = this.bite(text)
if (bites.length === 0) {
throw new Error(`Expected "${string}" but found '${text}'!`)
}
return string
},
})
then use it.
function translate(text) {
return Term.Root.translate(text)
}
here it is.
back to the dream