]> git.lizzy.rs Git - nothing.git/blob - src/script/interpreter.h
(#317) return new scope from eval
[nothing.git] / src / script / interpreter.h
1 #ifndef INTERPRETER_H_
2 #define INTERPRETER_H_
3
4 #include <stdbool.h>
5 #include <stdlib.h>
6 #include <stdio.h>
7 #include "expr.h"
8
9 struct EvalResult
10 {
11     bool is_error;
12     struct Expr expr;
13     struct Expr scope;
14     // TODO: make EvalResult.error a struct Expr
15     const char *error;
16 };
17
18 struct EvalResult eval_success(struct Expr expr, struct Expr scope);
19 struct EvalResult eval_failure(const char *error, struct Expr expr, struct Expr scope);
20
21 struct EvalResult eval(Gc *gc, struct Expr scope, struct Expr expr);
22
23 void print_eval_error(FILE *stream, struct EvalResult result);
24
25 #endif  // INTERPRETER_H_