Length, string -> std functions

This commit is contained in:
Dmitry Boulytchev 2021-01-31 22:57:12 +03:00
parent 216e716251
commit f1430a1cdf
10 changed files with 21 additions and 39 deletions

View file

@ -317,7 +317,7 @@ public fun lookupMemo (mm@[p, m], v) {
Some (w) -> w
| None ->
case v of
#string -> mm[1] := addMap (m, v, v); v
#str -> mm[1] := addMap (m, v, v); v
| _ ->
var vc = clone (v), i = case vc of #fun -> 1 | _ -> 0 esac;
for skip, i < v.length, i := i + 1 do

View file

@ -18,7 +18,7 @@ public fun logOn () {
public fun initOstap () {
tab := ref (emptyHashTab (1024, hash, compare));
restab := emptyCustomMemo (fun (x) {case x of #string -> true | _ -> false esac}, compare);
restab := emptyCustomMemo (fun (x) {case x of #str -> true | _ -> false esac}, compare);
hct := emptyMemo ()
}
@ -74,8 +74,8 @@ public fun memo (f) {
public fun token (x) {
case x of
#string -> memo $ fun (k) {fun (s) {k $ matchString (s, x)}}
| _ -> memo $ fun (k) {fun (s) {k $ matchRegexp (s, x)}}
#str -> memo $ fun (k) {fun (s) {k $ matchString (s, x)}}
| _ -> memo $ fun (k) {fun (s) {k $ matchRegexp (s, x)}}
esac
}

View file

@ -6,7 +6,7 @@ var
lident = createRegexp ("[a-z][a-zA-Z_]*", "lowercase identifier"),
uident = createRegexp ("[A-Z][a-zA-Z_]*", "uppercase identifier"),
ws = createRegexp ("\\([ \t\n]\\|--[^\n]*\n\\)*", "whitespace"),
str = createRegexp ("""\([^""]\|""""\)*""", "string literal"),
strlit = createRegexp ("""\([^""]\|""""\)*""", "string literal"),
decimal = createRegexp ("[0-9]+", "decimal literal"),
chr = createRegexp ("'[^']'", "character literal");

View file

@ -2,8 +2,8 @@ fun collect_ints_acc (v, tail) {
var i;
case v of
a@#val -> Cons (a, tail)
| #string -> tail
a@#val -> Cons (a, tail)
| #str -> tail
| _ ->
for i := 0, i < v.length, i := i + 1 do
tail := collect_ints_acc (v[i], tail)