shithub: mc

Download patch

ref: ad6b8d8419370d3bc8bb5272cc48b9d0230aec30
parent: 5e60759629a43ed5b5aeb5c831cadc516bc3c980
author: Ori Bernstein <[email protected]>
date: Tue Nov 4 17:51:08 EST 2014

Make all pattern matches comprehensive.

--- a/compile.myr
+++ b/compile.myr
@@ -59,7 +59,7 @@
 	re.pat = pat
 	re.nmatch = 1 /* whole match */
 	match parse(re)
-	| `None:	-> `std.Fail (`Earlystop)
+	| `None:	-> `std.Fail (`Incomplete)
 	| `Fail f:	-> `std.Fail f
 	| `Some t:
 		/*
@@ -67,7 +67,7 @@
 		an incorrectly encoded char
 		*/
 		if re.pat.len > 0
-			-> `std.Fail (`Earlystop)
+			-> `std.Fail (`Incomplete)
 		;;
 		dump(re, t, 0)
 		append(re, `Ilbra 0)
@@ -480,10 +480,12 @@
 			-> `Some t
 		else
 			astfree(t)
-			-> `Fail (`Earlystop)
+			-> `Fail `Incomplete
 		;;
 	| `None:
 		-> `None
+	| `Fail st:
+		-> `Fail st
 	;;
 }
 
@@ -499,7 +501,7 @@
 				ret = mk(`Alt (ret, rhs))
 			| `None:
 				astfree(ret)
-				-> `Fail (`Earlystop)
+				-> `Fail (`Incomplete)
 			| `Fail f:
 				-> `Fail f
 			;;
@@ -583,11 +585,12 @@
 				-> `Fail `Unbalanced
 			;;
 		| `None:	-> `Fail `Emptyparen
+		| `Fail st:	-> `Fail st
 		;;
 	| '\\':
 		getc(re) /* consume the slash */
 		if re.pat.len == 0
-			-> `Fail `Earlystop
+			-> `Fail `Incomplete
 		;;
 		-> escaped(re)
 	| c:
@@ -629,6 +632,7 @@
 	| '.': ret = `Some mk(`Chr '.')
 	| '+': ret = `Some mk(`Chr '+')
 	| '?': ret = `Some mk(`Chr '?')
+	| chr: ret = `Fail `Badescape
 	;;
 	-> ret
 }
@@ -640,7 +644,7 @@
 	var n
 
 	if re.pat.len == 0
-		-> `Fail (`Earlystop)
+		-> `Fail (`Incomplete)
 	;;
 	n = 0
 	s = re.pat
@@ -703,7 +707,7 @@
 	;;
 	if !matchc(re, ']')
 		std.slfree(rl)
-		-> `Fail (`Earlystop)
+		-> `Fail (`Incomplete)
 	;;
 
 	std.sort(rl, {a, b;
@@ -837,6 +841,7 @@
 
 	/* meta */
 	| `Cap	(m, a):	astfree(a)
+	| _:	/* other types have no suballocations */
 	;;
 	std.free(t)
 }
--- a/types.myr
+++ b/types.myr
@@ -2,12 +2,13 @@
 
 pkg regex =
 	type status = union
-		`Earlystop
+		`Noimpl
+		`Incomplete
 		`Unbalanced
 		`Emptyparen
 		`Badrep
 		`Badrange
-		`Noimpl
+		`Badescape
 	;;
 
 	type regex = struct