1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
|
use std
pkg escfmt =
type escre = byte[:]
const re : (s : byte[:] -> escre)
;;
const __init__ = {
var s = ("" : escre)
std.fmtinstall(std.typeof(s), refmt, [][:])
}
const re = {s
-> (s : escre)
}
const refmt = {sb, ap, args
var s : byte[:]
s = std.vanext(ap)
for c : std.bychar(s)
match c
| '|': std.sbputs(sb, "\\|")
| '*': std.sbputs(sb, "\\*")
| '+': std.sbputs(sb, "\\+")
| '?': std.sbputs(sb, "\\?")
| '[': std.sbputs(sb, "\\[")
| ']': std.sbputs(sb, "\\]")
| '^': std.sbputs(sb, "\\^")
| '$': std.sbputs(sb, "\\$")
| '.': std.sbputs(sb, "\\.")
| '\\': std.sbputs(sb, "\\.")
| '(': std.sbputs(sb, "\\(")
| ')': std.sbputs(sb, "\\)")
| _: std.sbputc(sb, c)
;;
;;
}
|