summaryrefslogtreecommitdiff
path: root/lib/regex
diff options
context:
space:
mode:
authorOri Bernstein <ori@eigenstate.org>2016-05-17 22:00:50 -0700
committerOri Bernstein <ori@eigenstate.org>2016-05-17 22:00:50 -0700
commit7aac15b2bfcc5eec279aa14f9f199685f9d7e0d9 (patch)
treec9434a55ea6850aee7103f608c6333cfe3148d60 /lib/regex
parentc96238b89583ed91e92ad909c507797d00015e95 (diff)
downloadmc-7aac15b2bfcc5eec279aa14f9f199685f9d7e0d9.tar.gz
New syntax for casts.
Diffstat (limited to 'lib/regex')
-rw-r--r--lib/regex/compile.myr8
-rw-r--r--lib/regex/interp.myr10
2 files changed, 9 insertions, 9 deletions
diff --git a/lib/regex/compile.myr b/lib/regex/compile.myr
index c5ac674..7c4c56b 100644
--- a/lib/regex/compile.myr
+++ b/lib/regex/compile.myr
@@ -157,7 +157,7 @@ const bound = {buf, len, fill
if len == 1
buf[0] = 0x7f
else
- s = len castto(byte)
+ s = (len : byte)
buf[0] = (0xff << (8 - s)) | (fill >> (s + 1))
for var i = 1; i < len; i++
buf[i] = 0x80 | (fill >> 2)
@@ -388,11 +388,11 @@ const idump = {re
std.put("{}@{}:\t", i, re.pcidx[i])
match re.prog[i]
/* Char matching. Consume exactly one byte from the string. */
- | `Ibyte b: std.put("`Ibyte {} ({})\n", b, b castto(char))
+ | `Ibyte b: std.put("`Ibyte {} ({})\n", b, (b : char))
| `Irange (start, end):
std.put("`Irange ({},{})", start, end)
- if std.isalnum(start castto(char)) && std.isalnum(end castto(char))
- std.put("\t/* {}-{} */", start castto(char), end castto(char))
+ if std.isalnum((start : char)) && std.isalnum((end : char))
+ std.put("\t/* {}-{} */", (start : char), (end : char))
;;
std.put("\n")
/* capture groups */
diff --git a/lib/regex/interp.myr b/lib/regex/interp.myr
index c1226ee..829384b 100644
--- a/lib/regex/interp.myr
+++ b/lib/regex/interp.myr
@@ -9,7 +9,7 @@ pkg regex =
;;
/* Ugly: for performance. std.option() should be used instead when unions get faster. */
-const Zthr = 0 castto(rethread#)
+const Zthr = (0 : rethread#)
const exec = {re, str
var thr
@@ -168,7 +168,7 @@ const step = {re, thr, curip
match re.prog[thr.ip]
/* Char matching. Consume exactly one byte from the string. */
| `Ibyte b:
- trace(re, thr, "\t{}:\tByte {} ({})\n", thr.ip, b, b castto(char))
+ trace(re, thr, "\t{}:\tByte {} ({})\n", thr.ip, b, (b : char))
if !within(re, str)
die(re, thr, "end of string")
elif b != str[re.strp]
@@ -178,7 +178,7 @@ const step = {re, thr, curip
trace(re, thr, "\t\tmatched {} with {}\n", b, str[re.strp])
;;
| `Irange (start, end):
- trace(re, thr, "\t{}:\tRange ({}, {}) /* {} - {} */\n", thr.ip, start, end, start castto(char), end castto(char))
+ trace(re, thr, "\t{}:\tRange ({}, {}) /* {} - {} */\n", thr.ip, start, end, (start : char), (end : char))
if !within(re, str) || start > str[re.strp] || end < str[re.strp]
die(re, thr, "bad range")
else
@@ -190,7 +190,7 @@ const step = {re, thr, curip
*/
| `Ibol:
trace(re, thr, "\t{}:\tBol\n", thr.ip)
- if re.strp == 0 || str[re.strp - 1] == '\n' castto(byte)
+ if re.strp == 0 || str[re.strp - 1] == ('\n' : byte)
thr.ip++
-> false
else
@@ -198,7 +198,7 @@ const step = {re, thr, curip
;;
| `Ieol:
trace(re, thr, "\t{}:\tEol\n", thr.ip)
- if re.strp == str.len || str[re.strp] == '\n' castto(byte)
+ if re.strp == str.len || str[re.strp] == ('\n' : byte)
thr.ip++
-> false
else