diff options
-rw-r--r-- | bench/regex-match.myr | 12 | ||||
-rw-r--r-- | lib/regex/interp.myr | 2 |
2 files changed, 12 insertions, 2 deletions
diff --git a/bench/regex-match.myr b/bench/regex-match.myr index 90b1ead..bb268f2 100644 --- a/bench/regex-match.myr +++ b/bench/regex-match.myr @@ -3,7 +3,7 @@ use regex use testr var str -var dotstar, hello +var dotstar, hello, world const main = { str = std.sldup("hello world!") @@ -11,13 +11,16 @@ const main = { str = std.strcat(str, str) str = std.strcat(str, str) str = std.strcat(str, str) + str = std.strcat(str, "x") dotstar = std.try(regex.compile(".*")) hello = std.try(regex.compile("hel*o")) + world = std.try(regex.compile("wor*l*d!x")) testr.bench([ [.name="matchall", .fn=matchall], [.name="searchhello", .fn=searchhello], + [.name="searchworld", .fn=searchworld], ][:]) } @@ -34,3 +37,10 @@ const searchhello = {ctx | `std.None: std.fatal("Didn't match regex\n") ;; } + +const searchworld = {ctx + match regex.search(world, str) + | `std.Some m: regex.matchfree(m) + | `std.None: std.fatal("Didn't match regex\n") + ;; +} diff --git a/lib/regex/interp.myr b/lib/regex/interp.myr index 4e2c0de..7ca1be5 100644 --- a/lib/regex/interp.myr +++ b/lib/regex/interp.myr @@ -364,7 +364,7 @@ const step = {re, thr, curip die(re, thr) ;; | _: - std.die("bad match") + std.die("corrupt regex bytecode") ;; -> true } |