MotherTode is a language that helps me to make languages. It's a language language.
For more info, check out the documentation.
Define your language by defining terms, like these:
let Expression = Number | String
let Greeting = {
match "greeting"
emit "Hello world!"
}
This is a mini language that lets you add numbers (don't worry if you don't understand it yet):
match Number
let Number = Add | Literal
let Literal = /[0-9]/+
let Add = {
match @(Number - Add) "+" @Number
emit (left, right) => left + right
)
You can embed it, like this:
<script src="https://github.com/TodePond/MotherTode/raw/main/mothertode-embed.js"></script>
<script>
const language = MotherTode("emit (name) => `Hello ${name}!`")
console.log(language("world")) //Hello world!
</script>
Or import it, like this:
import { MotherTode } from "./mothertode-import.js"
const language = MotherTode("emit (name) => `Hello ${name}!`")
console.log(language("world")) //Hello world!
Or use it from the command line, like this:
mothertode ./hello.mt "world"