-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.c
74 lines (70 loc) · 1.07 KB
/
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
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
#include "dat.h"
#include "fn.h"
GC *gc;
static void
SExprint(Object *obj)
{
if(obj == 0)
return;
switch(obj->type){
default:
return;
case OCELL:
printf("(");
SExprint(obj->car);
printf(" . ");
SExprint(obj->cdr);
printf(")");
break;
case OINT:
printf("%ld", obj->num);
break;
case OIDENT:
printf("%s", obj->beg);
break;
case OSTRING:
printf("\"%s\"", obj->beg);
break;
case OBLTIN:
case OSYMBOL:
printf("%s", obj->beg);
break;
case OBLOCK:
printf("\n<block-%s>\n", obj->tag->beg);
break;
case OFRAME:
printf("\n<frame-%s>\n", obj->tag->beg);
printexpr(obj->local);
printexpr(obj->block);
break;
case OENV:
printf("<env>");
printexpr(obj->frames);
break;
case OMACRO:
printf("<macro>");
goto func;
case OFUNC:
printf("<func>");
func:
printf("<");
SExprint(obj->params);
SExprint(obj->body);
printf(">");
break;
}
}
void
printexpr(Object *obj)
{
SExprint(obj);
printf("\n");
}
int
main(int argc, char *argv[])
{
*argv = "lib/lib.lisp";
gc = newgc(&argc, 24000);
lispmain(argv);
panic("unreachable");
}