Syntax Highlighting Sample

This sample code includes all constructs in the language and can be used as a test case for syntax highlighters. It can be found at https://codeberg.org/zhuriel/tadpole/src/branch/master/syntax/sample.tp.

// this is a file for testing syntax highlighting.
// it is not intended to and in fact should not work as a proper sound changer,
// however it should parse.
/* 
    block comments are supported too
*/

config validate_symbols = true;
config class_as_string = false;

feature feat1 = fvalue1;
syllables feature feat2 = *fvalue2 +fvalue3 -fvalue4 _fvalue5 +_fvalue6
    default *fvalue2;

modifier (syl before) '\'' = [fvalue1];
modifier (soft after) '*' = [+fvalue3];
modifier (hard at 0) '^' = [-fvalue4];
modifier '\"' = [+_fvalue6];

symbol 'a' = [fvalue1 *fvalue2];

class vow = 'a' 'e' 'i' 'o' 'u';
class stop = 'p' 't' 'k';
class nasal = 'm' 'n';
class cons = stop | nasal | 'r';

segmentation symbol;
segmentation class all;
segmentation class vow cons;
segmentation clear;
segmentation rebuild;

syllables explicit;
syllables match cons? vow;
syllables {
    match cons vow = [[fvalue1]];
    match cons <: vow :> cons;
    bias = 50;
}
syllables clear;
syllables rebuild;

macro matcher m1 = ();
macro replacer m2 = ();
macro rule m3 = !() -> ();

input in1 = 'a' -> 'b';
input in2 = {
    segmentation class all;
    syllables explicit;
    rule = 'a' -> 'b';
    resegment = true;
}

hooks pre = {
    rule pre_hook = () -> ();
}
hooks post add {
    rule post_hook = () -> ();
}
hooks disable pre_hook;
hooks enable post_hook;

generator gen = (50%)cons@(uniform) vow@(zipf 1.0) (10%) cons@(6 5 4 3 2 1);

rule base_elems = # . ^ ## -> ();
rule strings = "test" 'a' -> 'a' "test";
rule macro_call = {
    $m1 -> $m2;
    $m3;
}
rule bindings = {
    .@a vow@_1 [fvalue1]@long_name <a> -> [*fvalue2]@a <_1> <long_name>;
}
rule features = {
    [fvalue1 !*fvalue2 feat1@a feat2@_1]@b -> [+_fvalue6 <a> <_1>]@b;
}
rule syl_matchers = {
    syl [[fvalue1 !*fvalue2 feat1@a feat2@_1]]@b -> [[+_fvalue6 <a> <_1>]]@b;
}
rule repeats = {
    'a'+ 'b'* 'c'? 'd'{1,2} 'e'{3} -> ();
}
rule other_ops = {
    'a'(!) 'b'(~) !'c' -> ();
    'b' >> 'c' & 'd' && 'e' -> ();
}
rule environments = {
    'a' -> 'b' in 'pre' _ 'post' or 'pre' _ or _ 'post';
    'a' -> 'b' except "pre" _ "post";
}
rule flow = {
    'a' -> 'b';
    then {
        'c' -> 'd';
        else
        'e' -> 'f';
    }
}
rule annotations = {
    #{with config validate_symbols = false;} 'f' -> ();
    #{word} () -> ();
    #{filter vow} () -> ();
    #{converging} () -> ();
    #{rtl} () -> ();
    #{ltr} () -> ();
    #{50%} () -> ();
}

branch branch1;
from branch1;

output out1 = segmentation with ('' '.' ' ');
output out2 = () -> ();
output out3 = {
    rule = 'b' -> 'c';
    segmentation with ('|' '.' ' ');
}