summaryrefslogtreecommitdiff
path: root/lib/regex
diff options
context:
space:
mode:
authorOri Bernstein <ori@eigenstate.org>2016-06-11 11:55:43 -0400
committerOri Bernstein <ori@eigenstate.org>2016-06-11 11:56:05 -0400
commiteb21d4f1381f73045c81df0840aa50df20515045 (patch)
tree9632bfc34a12b505fada40b529d522a1eb1196a1 /lib/regex
parent3c96292a713f091b96d015aedcf824a7ea82f1cf (diff)
downloadmc-eb21d4f1381f73045c81df0840aa50df20515045.tar.gz
Simplify reluctant match types.
Diffstat (limited to 'lib/regex')
-rw-r--r--lib/regex/compile.myr38
-rw-r--r--lib/regex/types.myr6
2 files changed, 12 insertions, 32 deletions
diff --git a/lib/regex/compile.myr b/lib/regex/compile.myr
index 4439f21..0b85bd1 100644
--- a/lib/regex/compile.myr
+++ b/lib/regex/compile.myr
@@ -100,10 +100,8 @@ const gen = {re, t
|`Alt (a, b): genalt(re, a, b, t)
|`Cat (a, b): gen(re, a); gen(re, b)
/* repetition */
- |`Star a: genstar(re, a, false, t)
- |`Rstar a: genstar(re, a, true, t)
- |`Plus a: gen(re, a); genstar(re, a, false, t)
- |`Rplus a: gen(re, a); genstar(re, a, true, t)
+ |`Star (a, r): genstar(re, a, r, t)
+ |`Plus (a, r): gen(re, a); genstar(re, a, r, t)
|`Quest a: genquest(re, a)
/* end matches */
@@ -434,17 +432,11 @@ const dump = {re, t, indent
dump(re, a, indent + 1)
dump(re, b, indent + 1)
/* repetition */
- | `Star a:
- std.put("Star\n")
+ | `Star (a, r):
+ std.put("Star reluct={}\n", r)
dump(re, a, indent + 1)
- | `Rstar a:
- std.put("Rstar\n")
- dump(re, a, indent + 1)
- | `Plus a:
- std.put("Plus\n")
- dump(re, a, indent + 1)
- | `Rplus a:
- std.put("Rplus\n")
+ | `Plus (a, r):
+ std.put("Plus reluct={}\n", r)
dump(re, a, indent + 1)
| `Quest a:
std.put("Quest\n")
@@ -546,17 +538,9 @@ const repexpr = {re
| `Some t:
idx = re.idx
if matchc(re, '*')
- if matchc(re, '?')
- ret = mk(re, `Rstar t, idx)
- else
- ret = mk(re, `Star t, idx)
- ;;
+ ret = mk(re, `Star (t, matchc(re, '?')), idx)
elif matchc(re, '+')
- if matchc(re, '?')
- ret = mk(re, `Rplus t, idx)
- else
- ret = mk(re, `Plus t, idx)
- ;;
+ ret = mk(re, `Plus (t, matchc(re, '?')), idx)
elif matchc(re, '?')
ret = mk(re, `Quest t, idx)
else
@@ -874,10 +858,8 @@ const astfree = {t
| `Alt (a, b): astfree(a); astfree(b)
| `Cat (a, b): astfree(a); astfree(b)
/* repetition */
- | `Star a: astfree(a)
- | `Rstar a: astfree(a)
- | `Plus a: astfree(a)
- | `Rplus a: astfree(a)
+ | `Star (a, r): astfree(a)
+ | `Plus (a, r): astfree(a)
| `Quest a: astfree(a)
/* end matches */
diff --git a/lib/regex/types.myr b/lib/regex/types.myr
index b1ed4e3..766105b 100644
--- a/lib/regex/types.myr
+++ b/lib/regex/types.myr
@@ -44,10 +44,8 @@ pkg regex =
`Cat (ast#, ast#)
/* repetition */
- `Star ast#
- `Rstar ast#
- `Plus ast#
- `Rplus ast#
+ `Star (ast#, bool)
+ `Plus (ast#, bool)
`Quest ast#
/* end matches */