Concatenative topics
Concatenative meta
Other languages
Meta
Modal is a matrioshka language based on pattern-matching to rewrite trees.
Modal programs are represented as a series of rules, formatted as tokens delimited by brackets and parentheses, applied to a given tree which gets continually modified until no rules match any given part of the tree.
To define a new rule, start a line with <>, followed by two tokens. The program evaluation starts at the first character of the string and walks through to the end trying to match a transformation rule from that location:
<> hello bye .. hello world 00 bye world
A new rule definition syntax can also be created to suit a specific notation, for instance, here is a rule to define new rules with an infix syntax:
<> ((?x -> ?y)) (<> ?x ?y) (a -> apple) (b -> banana) ((apple banana) -> (fruit-salad)) .. a b 01 apple b 02 apple banana 03 fruit-salad
This revision created on Sat, 13 Apr 2024 15:06:30 by neauoire