mirror of
https://github.com/ProgramSnail/Lama.git
synced 2025-12-06 06:48:48 +00:00
Cosmetics in stdlib/spec
This commit is contained in:
parent
50fc2e9f2a
commit
78305d22b3
6 changed files with 12 additions and 12 deletions
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue