mirror of
https://github.com/GrammaticalFramework/gf-core.git
synced 2026-04-22 19:22:50 -06:00
implemented pattern macros
This commit is contained in:
@@ -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
|
||||
} ;
|
||||
|
||||
}
|
||||
|
||||
@@ -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"
|
||||
|
||||
@@ -22,3 +22,6 @@ param_table.Q2
|
||||
"abcdefghi"
|
||||
"aaaaxy"
|
||||
"xy"
|
||||
"xy"
|
||||
param_table.Q1
|
||||
param_table.Q2
|
||||
|
||||
Reference in New Issue
Block a user