lower than

This commit is contained in:
Christian Barthel 2019-06-30 22:44:14 +02:00
parent 68ecc91523
commit e718421f17
1 changed files with 27 additions and 0 deletions

View File

@ -306,6 +306,31 @@ eval_add(struct ast *a, struct env *e)
NULL));
}
/* (lt <ausdruck::NUM> <audsruck::NUM>) -> BOOL*/
struct ast *
eval_lt(struct ast *a, struct env *e)
{
assert (a != NULL &&
a->next != NULL &&
a->next->next != NULL &&
a->next->next->next == NULL);
struct ast *op1 = eval(a->next, e);
struct ast *op2 = eval(a->next->next, e);
assert (op1 != NULL &&
op1->type == AST_TOK &&
op1->v.token->type == NUM &&
op2 != NULL &&
op2->type == AST_TOK &&
op2->v.token->type == NUM);
return make_ast(AST_TOK,
make_token(BOOL,
op1->v.token->v.num <
op2->v.token->v.num,
NULL));
}
/* (inv <ausdruck::NUM>) -> NUM */
struct ast *
eval_inv(struct ast *a, struct env *e)
@ -336,6 +361,8 @@ eval_sym(struct ast *a, struct env *e)
return eval_inv(a, e);
} else if (strcmp(a->v.token->v.str, "add") == 0) {
return eval_add(a, e);
} else if (strcmp(a->v.token->v.str, "lt") == 0) {
return eval_lt(a, e);
} else if (strcmp(a->v.token->v.str, "nand") == 0) {
return eval_nand(a, e);
} else if (strcmp(a->v.token->v.str, "q") == 0) {