|
@@ -280,8 +280,11 @@ void fatal(char *s) {
|
|
|
|
|
|
fprintf(stderr, "|%s error\n", s);
|
|
|
|
|
|
- if (is_interactive)
|
|
|
- longjmp(interactive_checkpoint, 1);
|
|
|
+ if (is_interactive) {
|
|
|
+ rec_depth = 0;
|
|
|
+
|
|
|
+ longjmp(interactive_checkpoint, 1 );
|
|
|
+ }
|
|
|
|
|
|
exit(1);
|
|
|
}
|
|
@@ -1244,14 +1247,14 @@ value_t *each_rank(interpreter_t *state, verb_t *f, value_t *x, unsigned int d,
|
|
|
if (f->mark)
|
|
|
list_pop(state->selfrefs);
|
|
|
|
|
|
- rec_depth--;
|
|
|
+ if (rec_depth > 0) rec_depth--;
|
|
|
|
|
|
return r;
|
|
|
}
|
|
|
|
|
|
list_t *t = x->val.array;
|
|
|
if (!t->data) {
|
|
|
- rec_depth--;
|
|
|
+ if (rec_depth > 0) rec_depth--;
|
|
|
|
|
|
return x;
|
|
|
}
|
|
@@ -1260,12 +1263,17 @@ value_t *each_rank(interpreter_t *state, verb_t *f, value_t *x, unsigned int d,
|
|
|
for (size_t i = 0; i < t->length; i++)
|
|
|
l->data[i] = each_rank(state, f, t->data[i], d + 1, rm);
|
|
|
|
|
|
- rec_depth--;
|
|
|
+ if (rec_depth > 0) rec_depth--;
|
|
|
|
|
|
return value_new_array(l);
|
|
|
}
|
|
|
|
|
|
+value_t *verb_at(interpreter_t *state, verb_t *self, value_t *x, value_t *y);
|
|
|
+
|
|
|
value_t *apply_monad(interpreter_t *state, value_t *f, value_t *x) {
|
|
|
+ if (f->tag == ARRAY)
|
|
|
+ return verb_at(state, NULL, f, x);
|
|
|
+
|
|
|
if (f->tag != VERB)
|
|
|
return state->udf;
|
|
|
|
|
@@ -1295,7 +1303,7 @@ value_t *together(interpreter_t *state, verb_t *f, value_t *x, value_t *y,
|
|
|
if (f->mark)
|
|
|
list_pop(state->selfrefs);
|
|
|
|
|
|
- rec_depth--;
|
|
|
+ if (rec_depth > 0) rec_depth--;
|
|
|
|
|
|
return r;
|
|
|
}
|
|
@@ -1305,7 +1313,7 @@ value_t *together(interpreter_t *state, verb_t *f, value_t *x, value_t *y,
|
|
|
list_t *ty = y->val.array;
|
|
|
|
|
|
if (!tx->data || !ty->data) {
|
|
|
- rec_depth--;
|
|
|
+ if (rec_depth > 0) rec_depth--;
|
|
|
|
|
|
return !tx->data ? x : y;
|
|
|
}
|
|
@@ -1319,14 +1327,14 @@ value_t *together(interpreter_t *state, verb_t *f, value_t *x, value_t *y,
|
|
|
together(state, f, tx->data[i], ty->data[i], dl + 1, dr + 1, rl, rr);
|
|
|
}
|
|
|
|
|
|
- rec_depth--;
|
|
|
+ if (rec_depth > 0) rec_depth--;
|
|
|
|
|
|
return value_new_array(t);
|
|
|
} else if ((x->tag != ARRAY || dl >= rl) && y->tag == ARRAY && dr < rr) {
|
|
|
list_t *ty = y->val.array;
|
|
|
|
|
|
if (!ty->data) {
|
|
|
- rec_depth--;
|
|
|
+ if (rec_depth > 0) rec_depth--;
|
|
|
|
|
|
return y;
|
|
|
}
|
|
@@ -1340,7 +1348,7 @@ value_t *together(interpreter_t *state, verb_t *f, value_t *x, value_t *y,
|
|
|
list_t *tx = x->val.array;
|
|
|
|
|
|
if (!tx->data) {
|
|
|
- rec_depth--;
|
|
|
+ if (rec_depth > 0) rec_depth--;
|
|
|
|
|
|
return x;
|
|
|
}
|
|
@@ -1349,7 +1357,7 @@ value_t *together(interpreter_t *state, verb_t *f, value_t *x, value_t *y,
|
|
|
for (size_t i = 0; i < tx->length; i++)
|
|
|
t->data[i] = together(state, f, tx->data[i], y, dl + 1, dr, rl, rr);
|
|
|
|
|
|
- rec_depth--;
|
|
|
+ if (rec_depth > 0) rec_depth--;
|
|
|
|
|
|
return value_new_array(t);
|
|
|
}
|
|
@@ -1362,12 +1370,15 @@ value_t *together(interpreter_t *state, verb_t *f, value_t *x, value_t *y,
|
|
|
if (f->mark)
|
|
|
list_pop(state->selfrefs);
|
|
|
|
|
|
- rec_depth--;
|
|
|
+ if (rec_depth > 0) rec_depth--;
|
|
|
|
|
|
return r;
|
|
|
}
|
|
|
|
|
|
value_t *apply_dyad(interpreter_t *state, value_t *f, value_t *x, value_t *y) {
|
|
|
+ if (f->tag == ARRAY)
|
|
|
+ return verb_at(state, NULL, verb_at(state, NULL, f, x), y);
|
|
|
+
|
|
|
if (f->tag != VERB)
|
|
|
return state->nil;
|
|
|
|
|
@@ -7063,7 +7074,7 @@ node_t *parser_parse_expr(parser_t *parser) {
|
|
|
|
|
|
if (len >= 3 &&
|
|
|
(is_apply(list_index(ns, -2)) || is_obverse(list_index(ns, -2))) &&
|
|
|
- parser_node_is_verbal(parser, list_index(ns, -1))) {
|
|
|
+ parser_node_is_verbal(parser, list_index(ns, -3))) {
|
|
|
r = list_pop(ns);
|
|
|
m = list_pop(ns);
|
|
|
l = list_pop(ns);
|