-
Notifications
You must be signed in to change notification settings - Fork 0
/
lval.h
66 lines (53 loc) · 1.41 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
#ifndef LVAL_H
#define LVAL_H
#include "base_types.h"
#include "lenv.h"
#include "mpc.h"
struct lval {
lval_type type;
/* Basic */
long num;
char * err;
char * sym;
char * str;
l_error_type errtype;
/* Expression */
int count;
struct lval ** cell;
/* Function */
lbuiltin builtin;
char * builtin_name;
lenv * env;
lval * formals;
lval * body;
};
/* lval CONSTRUCTORS */
lval * lval_num(long x);
lval * lval_err(char * fmt, ...);
lval * lval_sym(char * symbol);
lval * lval_sexpr(void);
lval * lval_qexpr(void);
lval * lval_fun(lbuiltin fun, char * fun_name);
lval * lval_lambda(lval * formals, lval * body);
lval * lval_exit_error(void);
lval * lval_str(char * s);
/* lval DESTRUCTOR */
void lval_del(lval * v);
/* lval manipulation */
lval * lval_add(lval * v, lval * x);
lval * lval_pop(lval * v, int i);
lval * lval_take(lval * v, int i);
lval * lval_join(lval * x, lval * y);
lval * lval_copy(lval * v);
int lval_eq(lval * x, lval * y);
char * ltype_name(lval_type t);
/* CREATE lval from AST element */
lval *lval_read_num(mpc_ast_t * tag);
lval * lval_read_str(mpc_ast_t * tag);
lval * lval_read(mpc_ast_t * tag);
/* lval printing functions */
void lval_print_str(lval* v);
void lval_expr_print(lval * v, char open, char close);
void lval_print(lval * v);
void lval_println(lval * v);
#endif