summaryrefslogtreecommitdiff
path: root/test/matchbind.myr
diff options
context:
space:
mode:
authorOri Bernstein <ori@eigenstate.org>2012-06-30 18:46:38 -0400
committerOri Bernstein <ori@eigenstate.org>2012-06-30 18:46:55 -0400
commitdfe3ca01782c70e9daf16165441af0eba8cfda8d (patch)
tree44906171daa76a75766a608b38e0696e4b4dfd5f /test/matchbind.myr
parent31d5350f573cf2b2c176082ae26de473ee1f885c (diff)
downloadmc-dfe3ca01782c70e9daf16165441af0eba8cfda8d.tar.gz
Add parenthesized submatches.
This allows clear, unambiguous sub-patterns.
Diffstat (limited to 'test/matchbind.myr')
-rw-r--r--test/matchbind.myr26
1 files changed, 26 insertions, 0 deletions
diff --git a/test/matchbind.myr b/test/matchbind.myr
new file mode 100644
index 0000000..8d56185
--- /dev/null
+++ b/test/matchbind.myr
@@ -0,0 +1,26 @@
+type u = union
+ `Int int
+ `Chr char
+ `Nil
+;;
+
+const main = {
+ var v
+
+ v = `Int 11
+ match v
+ `Int 127:
+ -> 42
+ ;;
+ `Int (var x):
+ -> x
+ ;;
+ `Chr 'a':
+ -> 4
+ ;;
+ `Nil:
+ -> 6
+ ;;
+ ;;
+}
+