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
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
|
#ifndef CERC_EXPR_H
#define CERC_EXPR_H
#include <stdbool.h>
#include "lex.h"
#include "literal.h"
#include "type.h"
enum valuekind {
V_LITERAL,
V_NAME,
};
struct value_e {
enum valuekind kind;
union {
struct literal lit;
const char *name;
} v;
};
struct grp_e {
int isgrouped;
union {
struct expr *grouped;
struct value_e value;
} inner;
};
struct call_e {
struct expr *args;
int argsz, arglen;
};
enum access {
AC_NONE,
AC_FIELD,
AC_INDEX,
AC_CALL,
};
struct access_e {
struct grp_e grp;
enum access kind;
union {
const char *field;
struct expr *index;
struct call_e call;
} ac;
struct access_e *next;
};
struct tag_e {
int dotagof;
struct access_e access;
};
enum signop {
SIGN_NONE,
SIGN_POS,
SIGN_NEG,
};
struct sign_e {
enum signop op;
struct tag_e tag;
};
enum invop {
INV_NONE,
INV_BITS,
INV_BOOL,
};
struct inv_e {
enum invop op;
union {
struct inv_e *inv;
struct sign_e sign;
} oper;
};
struct deref_e {
int doderef;
union {
struct deref_e *deref;
struct inv_e inv;
} inner;
};
struct ref_e {
int doref;
struct deref_e inner;
};
struct as_e {
struct ref_e lhs;
struct type *cast;
};
struct bitand_e {
struct as_e lhs;
struct bitand_e *rhs;
};
struct bitxor_e {
struct bitand_e lhs;
struct bitxor_e *rhs;
};
struct bitor_e {
struct bitxor_e lhs;
struct bitor_e *rhs;
};
enum productop {
PRODUCT_NONE,
PRODUCT_MUL,
PRODUCT_DIV,
PRODUCT_REM,
};
struct product_e {
struct bitor_e lhs;
enum productop op;
struct product_e *rhs;
};
enum sumop {
SUM_NONE,
SUM_ADD,
SUM_SUB,
};
struct sum_e {
struct product_e lhs;
enum sumop op;
struct sum_e *rhs;
};
enum shiftop {
SHIFT_NONE,
SHIFT_LEFT,
SHIFT_RIGHT,
};
struct shift_e {
struct sum_e lhs;
enum shiftop op;
struct shift_e *rhs;
};
enum cmpop {
CMP_NONE,
CMP_LESS,
CMP_LESS_EQ,
CMP_EQ,
CMP_NEQ,
CMP_GREATER_EQ,
CMP_GREATER,
};
struct cmp_e {
struct shift_e lhs;
enum cmpop op;
struct shift_e *rhs;
};
struct conjunction_e {
struct cmp_e lhs;
struct conjunction_e *rhs;
};
struct expr {
struct conjunction_e lhs;
struct expr *rhs;
};
#endif
|