summaryrefslogtreecommitdiff
path: root/libregex/redump.myr
diff options
context:
space:
mode:
authorOri Bernstein <ori@eigenstate.org>2015-06-12 11:19:06 -0400
committerOri Bernstein <ori@eigenstate.org>2015-06-12 11:19:06 -0400
commita6ba17d4905ac66f9b96843b1cfa8b6981b096f1 (patch)
tree3ca982bfae2ddb135f0863c12e2be7afa2db9927 /libregex/redump.myr
parent58d7f56805e5e6def788c847c49b1051f164bd6c (diff)
downloadmc-a6ba17d4905ac66f9b96843b1cfa8b6981b096f1.tar.gz
Migrate to fmt2.myr
We're trying out fmt2 as a step towards removing the current fmt code.
Diffstat (limited to 'libregex/redump.myr')
-rw-r--r--libregex/redump.myr19
1 files changed, 16 insertions, 3 deletions
diff --git a/libregex/redump.myr b/libregex/redump.myr
index ea85d94..416d8a9 100644
--- a/libregex/redump.myr
+++ b/libregex/redump.myr
@@ -13,7 +13,7 @@ const main = {args
cmd = std.optparse(args, &opts)
match regex.dbgcompile(cmd.args[0])
| `std.Fail m:
- std.fatal("unable to compile regex: %s\n", regex.failmsg(m))
+ std.f2fatal("unable to compile regex: {}\n", regex.failmsg(m))
| `std.Ok re:
if cmd.args.len > 1
runall(re, cmd.args)
@@ -33,7 +33,7 @@ const runall = {re, files
dump(re, fd)
bio.close(fd)
| `std.None:
- std.fatal("failed to open %s\n", f)
+ std.f2fatal("failed to open {}\n", f)
;;
;;
}
@@ -42,7 +42,7 @@ const dump = {re, fd
while true
match bio.readln(fd)
| `std.Some ln:
- regex.exec(re, ln)
+ show(regex.exec(re, ln))
std.slfree(ln)
| `std.None:
break
@@ -50,3 +50,16 @@ const dump = {re, fd
;;
}
+const show = {mg
+ var i
+
+ match mg
+ | `std.Some rl:
+ std.f2put("Matched: {}\n", rl[0])
+ for i = 1; i < rl.len; i++
+ std.f2put("group {}: {}\n", i, rl[i])
+ ;;
+ | `std.None:
+ std.f2put("Match failed\n")
+ ;;
+}