This commit is contained in:
Dmitry Boulytchev 2022-11-01 09:22:19 +03:00
parent 80b391aff1
commit f47d872df1
5 changed files with 15 additions and 13 deletions

View file

@ -632,6 +632,8 @@ extern void* Lsubstring (void *subj, int p, int l) {
extern struct re_pattern_buffer *Lregexp (char *regexp) { extern struct re_pattern_buffer *Lregexp (char *regexp) {
regex_t *b = (regex_t*) malloc (sizeof (regex_t)); regex_t *b = (regex_t*) malloc (sizeof (regex_t));
/* printf ("regexp: %s,\t%x\n", regexp, b); */
memset (b, 0, sizeof (regex_t)); memset (b, 0, sizeof (regex_t));
int n = (int) re_compile_pattern (regexp, strlen (regexp), b); int n = (int) re_compile_pattern (regexp, strlen (regexp), b);
@ -652,6 +654,8 @@ extern int LregexpMatch (struct re_pattern_buffer *b, char *s, int pos) {
res = re_match (b, s, LEN(TO_DATA(s)->tag), UNBOX(pos), 0); res = re_match (b, s, LEN(TO_DATA(s)->tag), UNBOX(pos), 0);
/* printf ("regexpMatch %x: %s, res=%d\n", b, s+UNBOX(pos), res); */
if (res) { if (res) {
return BOX (res); return BOX (res);
} }

View file

@ -1 +1 @@
let version = "Version 1.10, 1a1c2e628, Tue Oct 11 17:05:26 2022 +0300" let version = "Version 1.10, 80b391aff, Tue Oct 25 02:57:51 2022 +0300"

View file

@ -16,8 +16,8 @@ fun printColl ([m, _]) {
| MNode (k, v, b, l, r) -> | MNode (k, v, b, l, r) ->
printf ("** key = %s, bf = %d **\n", k.string, b); printf ("** key = %s, bf = %d **\n", k.string, b);
printf (off); printf (off);
printf (" values :\n"); printf (" values : %s\n", v.string);
iter (fun ([x, _]) {printf (off); printf (" %s\n", x.string)}, v); -- iter (fun ([x, _]) {printf (off); printf (" %s\n", x.string)}, v);
inner (" " ++ off, l); inner (" " ++ off, l);
inner (" " ++ off, r) inner (" " ++ off, r)
esac esac
@ -34,7 +34,7 @@ public fun validateColl ([t, compare]) {
if verify (k) if verify (k)
then then
var lh = inner (l, fun (x) {compare (x, k) < 0}), var lh = inner (l, fun (x) {compare (x, k) < 0}),
rh = inner (r, fun (x) {compare (x, k) > 0}); rh = inner (r, fun (x) {compare (x, k) > 0});
if bf == lh - rh if bf == lh - rh
then 1 + if lh > rh then lh else rh fi then 1 + if lh > rh then lh else rh fi
@ -260,7 +260,7 @@ public fun isEmptySet (s) {
} }
public fun addSet (s, v) { public fun addSet (s, v) {
insertColl (s, v, true, Set) insertColl (s, v, true, Set)
} }
public fun memSet (s, v) { public fun memSet (s, v) {
@ -317,10 +317,6 @@ public fun lookupMemo (mm@[p, m], v) {
| _ -> false | _ -> false
esac; esac;
if f then
skip -- printf ("Looked up 0x%.8x | 0x%.8x | %s\n", mm, v, v.string)
fi;
case case
fun (x) { fun (x) {
case p of case p of

View file

@ -66,7 +66,7 @@ fun createMatcher (buf, pos, line, col) {
if x < y then x else y fi if x < y then x else y fi
} }
-- printf ("Matching regexp %s against %s...\n", r.string, substring (buf, pos, min (10, buf.length - pos))); -- printf ("Matching regexp %x against %s...\n", r, substring (buf, pos, min (10, buf.length - pos)));
if (n := regexpMatch (r[0], buf, pos)) >= 0 if (n := regexpMatch (r[0], buf, pos)) >= 0
then Succ (substring (buf, pos, n), shift (n)) then Succ (substring (buf, pos, n), shift (n))

View file

@ -41,6 +41,7 @@ public fun memo (f) {
case findHashTab (deref (tab), f) of case findHashTab (deref (tab), f) of
Some (t) -> t Some (t) -> t
esac; esac;
if log then printf ("Applying memoized parser to %s\n", s.string) fi; if log then printf ("Applying memoized parser to %s\n", s.string) fi;
case findMap (deref (t), s) of case findMap (deref (t), s) of
None -> None ->
@ -53,6 +54,7 @@ public fun memo (f) {
})]); })]);
f (fun (r) { f (fun (r) {
--r := lookupMemo (restab, r); --r := lookupMemo (restab, r);
if log then printf ("Running continuation with result %s\n", r.string) fi; if log then printf ("Running continuation with result %s\n", r.string) fi;
case findMap (deref (t), s) of case findMap (deref (t), s) of
Some ([ks, rs]) -> Some ([ks, rs]) ->
@ -117,7 +119,7 @@ public fun seq (a, b) {
a (fun (ar) { a (fun (ar) {
case ar of case ar of
Succ (x, s) -> b (x) (k) (s) Succ (x, s) -> b (x) (k) (s)
| _ -> k (ar) | _ -> k (ar)
esac esac
}) (s) }) (s)
} }
@ -130,7 +132,7 @@ public infixr |> after | (a, b) {seq (a, b)}
public infix @ at * (a, f) { public infix @ at * (a, f) {
fun (k) { fun (k) {
fun (s) { fun (s) {
a (fun (x) {k (case x of a (fun (x) {k (case x of
Succ (x, s) -> Succ (f (x), s) Succ (x, s) -> Succ (f (x), s)
| _ -> x | _ -> x
esac)}) (s) esac)}) (s)
@ -142,7 +144,7 @@ public infix @@ at * ([name, a], f) {
fun (k) { fun (k) {
fun (s) { fun (s) {
var aa = var aa =
a (fun (x) {k (case x of a (fun (x) {k (case x of
Succ (x, s) -> Succ (f (x), s) Succ (x, s) -> Succ (f (x), s)
| _ -> x | _ -> x
esac)}); esac)});