implemented pattern macros

This commit is contained in:
krangelov
2021-09-29 17:38:53 +02:00
parent 6efb878c43
commit 0229329d7c
14 changed files with 71 additions and 47 deletions

View File

@@ -3,4 +3,12 @@ resource param_table = {
param Q = Q1 | Q2 ;
param P = P1 | P2 Q ;
oper ab_patt = #["ab"];
oper test : Str -> Q = \s ->
case s of {
#ab_patt + _ => Q1 ;
_ => Q2
} ;
}

View File

@@ -23,3 +23,6 @@ cc <case "abcdefghi" of {""+x => x; _ => "?"} : Str>
cc <case "abcdefghi" of {x+"" => x; _ => "?"} : Str>
cc <case "aaaaxy" of {"a"* + x => x; _ => "?"} : Str>
cc <case "xybbbbb" of {x + "b"* => x; _ => "?"} : Str>
cc <case "xyababbbab" of {x + #ab_patt* => x; _ => "?"} : Str>
cc test "abcd"
cc test "xyz"

View File

@@ -22,3 +22,6 @@ param_table.Q2
"abcdefghi"
"aaaaxy"
"xy"
"xy"
param_table.Q1
param_table.Q2