summaryrefslogtreecommitdiff
path: root/lib/regex
diff options
context:
space:
mode:
authorOri Bernstein <ori@eigenstate.org>2016-05-15 15:52:31 -0700
committerOri Bernstein <ori@eigenstate.org>2016-05-15 15:52:31 -0700
commit89393cb48f76d4156105068fa9095d8b8f585b35 (patch)
treedc608c78232b1be0ca8b40f8ac7dc67498393b8a /lib/regex
parentb1e7c8e865c13699c1f3e3ff81ee397a133b4659 (diff)
downloadmc-89393cb48f76d4156105068fa9095d8b8f585b35.tar.gz
add compileast() function for libregex.
Diffstat (limited to 'lib/regex')
-rw-r--r--lib/regex/compile.myr14
1 files changed, 14 insertions, 0 deletions
diff --git a/lib/regex/compile.myr b/lib/regex/compile.myr
index 4889154..c82155b 100644
--- a/lib/regex/compile.myr
+++ b/lib/regex/compile.myr
@@ -6,6 +6,7 @@ use "ranges"
pkg regex =
const parse : (re : byte[:] -> std.result(ast#, status))
const compile : (re : byte[:] -> std.result(regex#, status))
+ const compileast : (re : ast# -> regex#)
const dbgcompile : (re : byte[:] -> std.result(regex#, status))
const free : (re : regex# -> void)
;;
@@ -71,6 +72,19 @@ const regexcompile = {re, id
-> `std.Fail (`Noimpl)
}
+const compileast = {ast
+ var re
+
+ re = std.mk([.pat = "", .nmatch = 1])
+ dump(re, ast, 0)
+ append(re, `Ilbra 0)
+ gen(re, ast)
+ append(re, `Irbra 0)
+ append(re, `Imatch 0)
+ idump(re)
+ -> re
+}
+
const free = {re
/* all the threads should be dead,
so we shouldn't have to free any*/