-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtypes.h
108 lines (81 loc) · 1.55 KB
/
types.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
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
#ifndef __TYPES_H__
#define __TYPES_H__
struct amaguq;
enum a_type {
ATOM,
FIXNUM,
BOOLEAN,
CHARLIT,
STRLIT,
LIST,
SYMBOL,
QUOTE,
};
struct atom {
virtual ~atom();
virtual std::string print();
virtual atom* eval();
virtual atom* accept(amaguq*) = 0;
amaguq* interpreter;
a_type atype;
};
struct fixnum : atom {
fixnum(const std::string&);
~fixnum();
virtual std::string print();
virtual atom* eval();
virtual atom* accept(amaguq*);
int value;
};
struct boolean : atom {
boolean(const std::string&);
~boolean();
virtual std::string print();
virtual atom* eval();
virtual atom* accept(amaguq*);
std::string str;
};
struct charlit : atom {
charlit(const std::string&);
~charlit();
virtual std::string print();
virtual atom* eval();
virtual atom* accept(amaguq*);
std::string str;
};
struct strlit : atom {
strlit(const std::string&);
~strlit();
virtual std::string print();
virtual atom* eval();
virtual atom* accept(amaguq*);
std::string str;
};
struct list : atom {
list(atom*, atom*);
~list();
virtual std::string print();
virtual atom* eval();
virtual atom* accept(amaguq*);
atom* car;
atom* cdr;
};
struct symbol : atom {
symbol(const std::string&);
~symbol();
virtual std::string print();
virtual atom* eval();
virtual atom* accept(amaguq*);
atom* accept(amaguq*, list*);
std::string sym;
};
// TODO quotes shouldn't be a first-class, user-accessible type?
struct quote : atom {
quote(atom*);
~quote();
virtual std::string print();
virtual atom* eval();
virtual atom* accept(amaguq*);
atom* q;
};
#endif