-
Notifications
You must be signed in to change notification settings - Fork 0
/
evaluation.h
42 lines (33 loc) · 1 KB
/
evaluation.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#ifndef __MCALC_H__
#define __MCALC_H__
#ifdef __cplusplus
extern "C" {
#endif
typedef struct mcalc_expr {
int type;
union {double value; const double *bound; const void *function;};
void *parameters[1];
} mcalc_expr;
enum {
MCALC_VARIABLE = 0,
MCALC_FUNCTION0 = 8, MCALC_FUNCTION1, MCALC_FUNCTION2, MCALC_FUNCTION3,
MCALC_FUNCTION4, MCALC_FUNCTION5, MCALC_FUNCTION6, MCALC_FUNCTION7,
MCALC_CLOSURE0 = 16, MCALC_CLOSURE1, MCALC_CLOSURE2, MCALC_CLOSURE3,
MCALC_CLOSURE4, MCALC_CLOSURE5, MCALC_CLOSURE6, MCALC_CLOSURE7,
MCALC_FLAG_PURE = 32
};
typedef struct mcalc_variable {
const char *name;
const void *address;
int type;
void *context;
} mcalc_variable;
double mcalc_interp(const char *expression, int *error);
mcalc_expr *mcalc_compile(const char *expression, const mcalc_variable *variables, int var_count, int *error);
double mcalc_eval(const mcalc_expr *n);
void mcalc_print(const mcalc_expr *n);
void mcalc_free(mcalc_expr *n);
#ifdef __cplusplus
}
#endif
#endif