-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlval.h
73 lines (60 loc) · 1.15 KB
/
lval.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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
#ifndef LVAL_H
#define LVAL_H
typedef struct lval lval;
enum
{
LVAL_NUM,
LVAL_STR,
LVAL_ERR,
LVAL_SYM,
LVAL_SEXPR,
LVAL_QEXPR,
LVAL_FUN,
LVAL_BOOL
};
typedef struct lenv lenv;
typedef lval*(*lbuiltin)(lenv*, lval*);
#define TRUE 1
#define FALSE 0
struct lval
{
int type;
long num;
char* err;
char* sym;
char* str;
lbuiltin builtin;
lenv* env;
lval* formals;
lval* body;
// number of child lvals
int count;
/*
* Pointer to a list of child lvals
* If a struct contains a ref to itself
* append a struct before the declaration
* to avoid circular dependency
* Also, struct can only contain pointers
* to their own type, not instances of their
* own type
*/
struct lval** cell;
char bool_state;
};
void lval_del(lval*);
lval* lval_num(long);
lval* lval_str(char*);
lval* lval_err(char*, ...);
lval* lval_sym(char*);
lval* lval_sexpr(void);
lval* lval_qexpr(void);
lval* lval_bool(int);
lval* lval_fun(lbuiltin);
lval* lval_lambda(lval*, lval*);
lval* lval_copy(lval*);
int lval_eq(lval*, lval*);
void lval_expr_print(lval*, char, char);
void lval_print(lval*);
void lval_println(lval*);
char* ltype_name(int);
#endif