-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathmain.c
50 lines (43 loc) · 921 Bytes
/
main.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
#include <stdio.h>
#include <inttypes.h>
#include <stdlib.h>
#include "types.h"
#include "runtime.h"
FILE* in;
FILE* out;
void (*error_handler)();
void print_result(int64_t);
void print_char(int64_t);
void error_exit() {
printf("err\n");
exit(1);
}
void raise_error() {
return error_handler();
}
int main(int argc, char** argv) {
in = stdin;
out = stdout;
error_handler = &error_exit;
print_result(entry());
return 0;
}
void print_result(int64_t result) {
if (int_type_tag == (int_type_mask & result)) {
printf("%" PRId64 "\n", result >> int_shift);
} else if (char_type_tag == (char_type_mask & result)) {
print_char(result);
printf("\n");
} else {
switch (result) {
case val_true:
printf("#t\n"); break;
case val_false:
printf("#f\n"); break;
case val_eof:
printf("#<eof>\n"); break;
case val_void:
/* nothing */ break;
}
}
}