Cosmetics in stdlib/spec

This commit is contained in:
Dmitry Boulytchev 2020-03-08 00:57:25 +03:00
parent 50fc2e9f2a
commit 78305d22b3
6 changed files with 12 additions and 12 deletions

View file

@ -55,7 +55,7 @@ fun createMatcher (buf, pos, line, col) {
fun matchRegexp (r) {
local n;
if (n := regexpMatch (r[0], buf, pos)) > 0
if (n := regexpMatch (r[0], buf, pos)) >= 0
then Succ (substring (buf, pos, n), shift (n))
else Fail (sprintf ("%s expected", r[1]), line, col)
fi

View file

@ -64,11 +64,10 @@ public fun memo (f) {
}
public fun token (x) {
fun (k) {
fun (s) {
k $ matchString (s, x)
}
}
case x of
#string -> fun (k) {fun (s) {k $ matchString (s, x)}}
| _ -> fun (k) {fun (s) {k $ matchRegexp (s, x)}}
esac
}
public fun eof (k) {
@ -130,8 +129,8 @@ public fun bypass (f) {
public fun opt (a) {empty @ lift (None) | a @ fun (x) {Some (x)}}
public fun rep0 (a) {
--memo
(empty @ lift({}) | a |> fun (x) {rep0 (a) @ fun (as) {x : as}})
memo
(empty @ lift({}) | a |> fun (x) {rep0 (a) @ fun (as) {x : as}})
}
public fun rep (a) {