-
Notifications
You must be signed in to change notification settings - Fork 1
/
sform.c
122 lines (100 loc) · 2.75 KB
/
sform.c
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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
#include <stddef.h>
#include "object.h"
#include "sform.h"
static object *g_quote_symbol;
static object *g_quasiquote_symbol;
static object *g_unquote_symbol;
static object *g_unquotesplicing_symbol;
static object *g_set_symbol;
static object *g_define_symbol;
static object *g_nrv_symbol; /* No Return Value symbol */
static object *g_if_symbol;
static object *g_lambda_symbol;
static object *g_begin_symbol;
static object *g_cond_symbol;
static object *g_else_symbol;
static object *g_let_symbol;
static object *g_and_symbol;
static object *g_or_symbol;
static object *g_callwcc_symbol;
static object *g_definemacro_symbol;
#define DEFINE_SYMBOL(var, sym) \
{ \
object *obj; \
obj = make_symbol(sym); \
if (obj == NULL) { \
return -1; \
} \
var = obj; \
}
int sform_init(void) {
DEFINE_SYMBOL(g_quote_symbol, "quote");
DEFINE_SYMBOL(g_set_symbol, "set!");
DEFINE_SYMBOL(g_define_symbol, "define");
DEFINE_SYMBOL(g_nrv_symbol, "; no value returned");
DEFINE_SYMBOL(g_if_symbol, "if");
DEFINE_SYMBOL(g_lambda_symbol, "lambda");
DEFINE_SYMBOL(g_begin_symbol, "begin");
DEFINE_SYMBOL(g_cond_symbol, "cond");
DEFINE_SYMBOL(g_else_symbol, "else");
DEFINE_SYMBOL(g_let_symbol, "let");
DEFINE_SYMBOL(g_and_symbol, "and");
DEFINE_SYMBOL(g_or_symbol, "or");
DEFINE_SYMBOL(g_callwcc_symbol, "call-with-current-continuation");
DEFINE_SYMBOL(g_definemacro_symbol, "define-macro");
DEFINE_SYMBOL(g_quasiquote_symbol, "quasiquote");
DEFINE_SYMBOL(g_unquote_symbol, "unquote");
DEFINE_SYMBOL(g_unquotesplicing_symbol, "unquote-splicing");
return 0;
}
object* get_quote_symbol(void) {
return g_quote_symbol;
}
object* get_set_symbol(void) {
return g_set_symbol;
}
object* get_define_symbol(void) {
return g_define_symbol;
}
object* get_nrv_symbol(void) {
return g_nrv_symbol;
}
object* get_if_symbol(void) {
return g_if_symbol;
}
object* get_lambda_symbol(void) {
return g_lambda_symbol;
}
object* get_begin_symbol(void) {
return g_begin_symbol;
}
object* get_cond_symbol(void) {
return g_cond_symbol;
}
object* get_else_symbol(void) {
return g_else_symbol;
}
object* get_let_symbol(void) {
return g_let_symbol;
}
object* get_and_symbol(void) {
return g_and_symbol;
}
object* get_or_symbol(void) {
return g_or_symbol;
}
object* get_callwcc_symbol(void) {
return g_callwcc_symbol;
}
object* get_definemacro_symbol(void) {
return g_definemacro_symbol;
}
object* get_quasiquote_symbol(void) {
return g_quasiquote_symbol;
}
object* get_unquote_symbol(void) {
return g_unquote_symbol;
}
object* get_unquotesplicing_symbol(void) {
return g_unquotesplicing_symbol;
}