shithub: mc

Download patch

ref: 89393cb48f76d4156105068fa9095d8b8f585b35
parent: b1e7c8e865c13699c1f3e3ff81ee397a133b4659
author: Ori Bernstein <ori@eigenstate.org>
date: Sun May 15 11:52:31 EDT 2016

add compileast() function for libregex.

--- a/lib/regex/compile.myr
+++ b/lib/regex/compile.myr
@@ -6,6 +6,7 @@
 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)
 ;;
@@ -69,6 +70,19 @@
 		-> `std.Ok re
 	;;
 	-> `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