summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOri Bernstein <ori@eigenstate.org>2014-11-04 22:51:08 -0500
committerOri Bernstein <ori@eigenstate.org>2014-11-04 22:51:08 -0500
commitad6b8d8419370d3bc8bb5272cc48b9d0230aec30 (patch)
tree36958eea1c0262d448f4c25501c02ea068f17bb2
parent5e60759629a43ed5b5aeb5c831cadc516bc3c980 (diff)
downloadlibregex-ad6b8d8419370d3bc8bb5272cc48b9d0230aec30.tar.gz
Make all pattern matches comprehensive.
-rw-r--r--compile.myr19
-rw-r--r--types.myr5
2 files changed, 15 insertions, 9 deletions
diff --git a/compile.myr b/compile.myr
index 4e376e4..c2f6a47 100644
--- a/compile.myr
+++ b/compile.myr
@@ -59,7 +59,7 @@ const regexcompile = {re, pat
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 @@ const regexcompile = {re, pat
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 @@ const parse = {re
-> `Some t
else
astfree(t)
- -> `Fail (`Earlystop)
+ -> `Fail `Incomplete
;;
| `None:
-> `None
+ | `Fail st:
+ -> `Fail st
;;
}
@@ -499,7 +501,7 @@ const altexpr = {re
ret = mk(`Alt (ret, rhs))
| `None:
astfree(ret)
- -> `Fail (`Earlystop)
+ -> `Fail (`Incomplete)
| `Fail f:
-> `Fail f
;;
@@ -583,11 +585,12 @@ const baseexpr = {re
-> `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 @@ const escaped = {re
| '.': ret = `Some mk(`Chr '.')
| '+': ret = `Some mk(`Chr '+')
| '?': ret = `Some mk(`Chr '?')
+ | chr: ret = `Fail `Badescape
;;
-> ret
}
@@ -640,7 +644,7 @@ const unicodeclass = {re, neg
var n
if re.pat.len == 0
- -> `Fail (`Earlystop)
+ -> `Fail (`Incomplete)
;;
n = 0
s = re.pat
@@ -703,7 +707,7 @@ const chrclass = {re
;;
if !matchc(re, ']')
std.slfree(rl)
- -> `Fail (`Earlystop)
+ -> `Fail (`Incomplete)
;;
std.sort(rl, {a, b;
@@ -837,6 +841,7 @@ const astfree = {t
/* meta */
| `Cap (m, a): astfree(a)
+ | _: /* other types have no suballocations */
;;
std.free(t)
}
diff --git a/types.myr b/types.myr
index f633380..24e9842 100644
--- a/types.myr
+++ b/types.myr
@@ -2,12 +2,13 @@ use std
pkg regex =
type status = union
- `Earlystop
+ `Noimpl
+ `Incomplete
`Unbalanced
`Emptyparen
`Badrep
`Badrange
- `Noimpl
+ `Badescape
;;
type regex = struct