Merge branch 'post-historic' of https://github.com/dboulytchev/compiler-workout-private into post-historic

This commit is contained in:
kverty 2019-09-10 00:49:43 +03:00
commit 686e3ff9d7
5 changed files with 18 additions and 5 deletions

View file

@ -0,0 +1,2 @@
0
3

8
regression/test055.expr Normal file
View file

@ -0,0 +1,8 @@
fun len(l) {
case l of
_ : xs -> return len(xs) + 1
|{} -> return 0
esac
}
write(len({}));
write(len({1, 2, 3}))

0
regression/test055.input Normal file
View file

View file

@ -66,7 +66,7 @@ char* de_hash (int n) {
static char *chars = (char*) BOX (NULL);
static char buf[6] = {0,0,0,0,0,0};
char *p = (char *) BOX (NULL);
chars = "_abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNJPQRSTUVWXYZ";
chars = "_abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
p = &buf[5];
#ifdef DEBUG_PRINT
@ -316,6 +316,8 @@ extern void* Bsexp (int n, ...) {
extern int Btag (void *d, int t, int n) {
data *r = (data *) BOX (NULL);
if (UNBOXED(d)) return BOX(0);
else {
r = TO_DATA(d);
#ifndef DEBUG_PRINT
return BOX(TAG(r->tag) == SEXP_TAG && TO_SEXP(d)->tag == t && LEN(r->tag) == n);
@ -324,6 +326,7 @@ extern int Btag (void *d, int t, int n) {
GET_SEXP_TAG(TO_SEXP(d)->tag) == t && LEN(r->tag) == n);
#endif
}
}
extern int Barray_patt (void *d, int n) {
data *r = BOX(NULL);

View file

@ -389,7 +389,7 @@ module M = Map.Make (String)
(* Environment implementation *)
class env =
let chars = "_abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNJPQRSTUVWXYZ" in
let chars = "_abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ" in
let make_assoc l i = List.combine l (List.init (List.length l) (fun x -> x + i)) in
let rec assoc x = function [] -> raise Not_found | l :: ls -> try List.assoc x l with Not_found -> assoc x ls in
object (self)