Tode

→ language creator

Write Tode to show how to translate one language into another.

This is what it looks like:

Name [Text] :: "name" => Luke

Rules


Tode is a bunch of rules.
All parts of a rule are optional.


The pattern shows the translater how to identify the rule.

"name"


The output shows how to translate into the target language.

"name" => Luke


The rule name can help to identify the rule.

Name :: "name" => Luke


A rule can have a type.

[Text] :: "name" => Luke


A rule can have a name and type.

Name [Text] :: "name" => Luke

Pattern


The pattern is a list of items.
It shows how to identify a rule.

It can consist of these items:


Text

"name" => Luke


Regex

/name/ => Luke


Rule Name

Name => Luke


Type

[Text] => {1}


Value

{2 + 2} => 5

Output


The output shows Tode how to translate into the target language.


Translate

"name" => Luke


Dynamic Translate

The output can be generated dynamically from the pattern.

"greet" Whitespace [Text] => Hello {3}!


Bake

The output of a rule can be calculated at compile time.

[Number] "+" [Number] -> {1} + {3}


Re-Translate

The output can be re-translated afterwards in your language.

"name" >> "Luke"