Magnogen / MotherTode

language language

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

As of 17th August 2022... I'm currently redesigning and rewriting MotherTode. For the old version, go to the legacy repo.

MotherTode

MotherTode is a language that lets you make languages. It's a language language.
For more info, check out the documentation.

How does it work?

Define your language by defining terms, like these:

Expression :: Number | String
Greeting :: "greet" >> "Hello world!"

What does it look like?

This is a mini language that lets you add numbers (don't worry if you don't understand it yet):

:: Addition {"\n" Addition}
Addition :: Add | Literal
Literal :: /[0-9]/+ ["." /[0-9]/+]
Add (
    :: Addition~Add "+" Addition
    >> ([left, operator, right]) => parseFloat(left) + parseFloat(right)
)

This example takes an input of multiple numbers seperated by + symbols, and return what they add up to.

How do I use it?

You can embed it or import it, using the files located in /build/.

<script src="mothertode-embed.js"></script>
import MotherTode from "./mothertode-import.js"

Then use the MotherTode function like so.

const language = MotherTode(`:: /[a-zA-Z]/+ >> (name) => "Hello " + name + "!"`)
const result = language("world")
console.log(result.output)

About

language language

License:MIT License


Languages

Language:JavaScript 100.0%