ref: 25bfea9b4ab857720f4d184fb2f7e1c42c3fdae5
parent: 750f64d65eaa7af67dc7377ee948dda823c68476
author: Ori Bernstein <[email protected]>
date: Sun Oct 27 09:25:47 EDT 2013
Remove dot operator in favor of range operator.
--- a/compile.myr
+++ b/compile.myr
@@ -19,8 +19,7 @@
/* end matches */
`Byte byte
`Chr char
- `Class [char, char][:]
- `Dot
+ `Class [char, char]
/* meta */
`Cap tree#
@@ -68,12 +67,9 @@
`Quest a: genquest(re, a);;
/* end matches */
- `Class sl:
- std.die("Can't gen class\n")
- ;;
`Byte b: append(re, `Ibyte b);;
`Chr c: genchar(re, c);;
- `Dot: genrange(re, 0, std.Maxcharval);;
+ `Class (a, b): genrange(re, a, b);;
/* meta */
`Bol:
@@ -282,9 +278,6 @@
std.put("Eol\n")
;;
/* end matches */
- `Class sl:
- std.put("Class [a..b]\n")
- ;;
`Byte b:
std.put("Byte %b\n", b)
;;
@@ -291,8 +284,8 @@
`Chr c:
std.put("Char %c\n", c)
;;
- `Dot:
- std.put("Dot\n")
+ `Class (a, b):
+ std.put("Class (%c-%c)\n", a, b)
;;
/* meta */
@@ -397,8 +390,8 @@
'*': -> `Fail (`Badrep);;
'+': -> `Fail (`Badrep);;
'?': -> `Fail (`Badrep);;
- '[': ret = chrclass(re);;
- '.': getc(re); ret = mk(`Dot);;
+ '[': -> chrclass(re);;
+ '.': getc(re); ret = mk(`Class (0, std.Maxcharval));;
'^': getc(re); ret = mk(`Bol);;
'$': getc(re); ret = mk(`Eol);;
'(':
@@ -427,12 +420,17 @@
-> `Some ret
}
-const chrclass = {pat
+const chrclass = {re
var t
+ matchc(re, '[')
+ if !matchc(re, ']')
+ -> `Fail (`Earlystop)
+ ;;
+
t = std.alloc()
- t# = `Class [][:]
- -> t
+ t# = `Class (0, 1)
+ -> `Some t
}
const matchc = {re, c
@@ -480,10 +478,9 @@
`Quest a: free(a);;
/* end matches */
- `Class sl: std.slfree(sl);;
`Byte b: ;;
`Chr c: ;;
- `Dot: ;;
+ `Class (a, b): ;;
/* meta */
`Cap a: free(a);;