1 | // _gen/asdl/examples/shared_variant.asdl.h is generated by asdl_main.py
|
2 |
|
3 | #ifndef SHARED_VARIANT_ASDL
|
4 | #define SHARED_VARIANT_ASDL
|
5 |
|
6 | #include <cstdint>
|
7 |
|
8 | #include "mycpp/runtime.h"
|
9 | #include "_gen/asdl/hnode.asdl.h"
|
10 | using hnode_asdl::hnode_t;
|
11 |
|
12 | namespace shared_variant_asdl {
|
13 |
|
14 | // use struct instead of namespace so 'using' works consistently
|
15 | #define ASDL_NAMES struct
|
16 |
|
17 | class prod;
|
18 | class DoubleQuoted;
|
19 | class expr_t;
|
20 | class Token;
|
21 | class tok_t;
|
22 | class tok_struct;
|
23 | class tok_array;
|
24 | class word_part_t;
|
25 | class cflow_t;
|
26 |
|
27 | ASDL_NAMES expr_e {
|
28 | enum no_name {
|
29 | Binary = 1,
|
30 | DoubleQuoted = 65,
|
31 | };
|
32 | };
|
33 |
|
34 | BigStr* expr_str(int tag, bool dot = true);
|
35 |
|
36 | class expr_t {
|
37 | protected:
|
38 | expr_t() {
|
39 | }
|
40 | public:
|
41 | int tag() const {
|
42 | return ObjHeader::FromObject(this)->type_tag;
|
43 | }
|
44 | hnode_t* PrettyTree(Dict<int, bool>* seen = nullptr);
|
45 | DISALLOW_COPY_AND_ASSIGN(expr_t)
|
46 | };
|
47 |
|
48 | class expr__Binary : public expr_t {
|
49 | public:
|
50 | expr__Binary(expr_t* left, expr_t* right)
|
51 | : left(left),
|
52 | right(right) {
|
53 | }
|
54 |
|
55 | static expr__Binary* CreateNull(bool alloc_lists = false) {
|
56 | return Alloc<expr__Binary>(nullptr, nullptr);
|
57 | }
|
58 |
|
59 | hnode_t* PrettyTree(Dict<int, bool>* seen = nullptr);
|
60 |
|
61 | static constexpr ObjHeader obj_header() {
|
62 | return ObjHeader::AsdlClass(static_cast<uint16_t>(expr_e::Binary), 2);
|
63 | }
|
64 |
|
65 | expr_t* left;
|
66 | expr_t* right;
|
67 |
|
68 | DISALLOW_COPY_AND_ASSIGN(expr__Binary)
|
69 | };
|
70 |
|
71 | ASDL_NAMES expr {
|
72 | typedef expr__Binary Binary;
|
73 | };
|
74 |
|
75 | ASDL_NAMES tok_e {
|
76 | enum no_name {
|
77 | Eof = 1,
|
78 | Token = 66,
|
79 | };
|
80 | };
|
81 |
|
82 | BigStr* tok_str(int tag, bool dot = true);
|
83 |
|
84 | class tok_t {
|
85 | protected:
|
86 | tok_t() {
|
87 | }
|
88 | public:
|
89 | int tag() const {
|
90 | return ObjHeader::FromObject(this)->type_tag;
|
91 | }
|
92 | hnode_t* PrettyTree(Dict<int, bool>* seen = nullptr);
|
93 | DISALLOW_COPY_AND_ASSIGN(tok_t)
|
94 | };
|
95 |
|
96 | class tok__Eof : public tok_t {
|
97 | public:
|
98 | tok__Eof() {}
|
99 |
|
100 | hnode_t* PrettyTree(Dict<int, bool>* seen = nullptr);
|
101 |
|
102 | static constexpr ObjHeader obj_header() {
|
103 | return ObjHeader::AsdlClass(static_cast<uint16_t>(tok_e::Eof), 0);
|
104 | }
|
105 |
|
106 |
|
107 | DISALLOW_COPY_AND_ASSIGN(tok__Eof)
|
108 | };
|
109 |
|
110 | extern GcGlobal<tok__Eof> gtok__Eof;
|
111 | ASDL_NAMES tok {
|
112 | static tok__Eof* Eof;
|
113 | };
|
114 |
|
115 | ASDL_NAMES word_part_e {
|
116 | enum no_name {
|
117 | Literal = 1,
|
118 | DoubleQuoted = 65,
|
119 | };
|
120 | };
|
121 |
|
122 | BigStr* word_part_str(int tag, bool dot = true);
|
123 |
|
124 | class word_part_t {
|
125 | protected:
|
126 | word_part_t() {
|
127 | }
|
128 | public:
|
129 | int tag() const {
|
130 | return ObjHeader::FromObject(this)->type_tag;
|
131 | }
|
132 | hnode_t* PrettyTree(Dict<int, bool>* seen = nullptr);
|
133 | DISALLOW_COPY_AND_ASSIGN(word_part_t)
|
134 | };
|
135 |
|
136 | class word_part__Literal : public word_part_t {
|
137 | public:
|
138 | word_part__Literal(BigStr* s)
|
139 | : s(s) {
|
140 | }
|
141 |
|
142 | static word_part__Literal* CreateNull(bool alloc_lists = false) {
|
143 | return Alloc<word_part__Literal>(kEmptyString);
|
144 | }
|
145 |
|
146 | hnode_t* PrettyTree(Dict<int, bool>* seen = nullptr);
|
147 |
|
148 | static constexpr ObjHeader obj_header() {
|
149 | return ObjHeader::AsdlClass(static_cast<uint16_t>(word_part_e::Literal), 1);
|
150 | }
|
151 |
|
152 | BigStr* s;
|
153 |
|
154 | DISALLOW_COPY_AND_ASSIGN(word_part__Literal)
|
155 | };
|
156 |
|
157 | ASDL_NAMES word_part {
|
158 | typedef word_part__Literal Literal;
|
159 | };
|
160 |
|
161 | ASDL_NAMES cflow_e {
|
162 | enum no_name {
|
163 | Break = 1,
|
164 | Continue = 2,
|
165 | Return = 3,
|
166 | };
|
167 | };
|
168 |
|
169 | BigStr* cflow_str(int tag, bool dot = true);
|
170 |
|
171 | class cflow_t {
|
172 | protected:
|
173 | cflow_t() {
|
174 | }
|
175 | public:
|
176 | int tag() const {
|
177 | return ObjHeader::FromObject(this)->type_tag;
|
178 | }
|
179 | hnode_t* PrettyTree(Dict<int, bool>* seen = nullptr);
|
180 | DISALLOW_COPY_AND_ASSIGN(cflow_t)
|
181 | };
|
182 |
|
183 | class cflow__Break : public cflow_t {
|
184 | public:
|
185 | cflow__Break() {}
|
186 |
|
187 | hnode_t* PrettyTree(Dict<int, bool>* seen = nullptr);
|
188 |
|
189 | static constexpr ObjHeader obj_header() {
|
190 | return ObjHeader::AsdlClass(static_cast<uint16_t>(cflow_e::Break), 0);
|
191 | }
|
192 |
|
193 |
|
194 | DISALLOW_COPY_AND_ASSIGN(cflow__Break)
|
195 | };
|
196 |
|
197 | class cflow__Continue : public cflow_t {
|
198 | public:
|
199 | cflow__Continue() {}
|
200 |
|
201 | hnode_t* PrettyTree(Dict<int, bool>* seen = nullptr);
|
202 |
|
203 | static constexpr ObjHeader obj_header() {
|
204 | return ObjHeader::AsdlClass(static_cast<uint16_t>(cflow_e::Continue), 0);
|
205 | }
|
206 |
|
207 |
|
208 | DISALLOW_COPY_AND_ASSIGN(cflow__Continue)
|
209 | };
|
210 |
|
211 | class cflow__Return : public cflow_t {
|
212 | public:
|
213 | cflow__Return(int val)
|
214 | : val(val) {
|
215 | }
|
216 |
|
217 | static cflow__Return* CreateNull(bool alloc_lists = false) {
|
218 | return Alloc<cflow__Return>(-1);
|
219 | }
|
220 |
|
221 | hnode_t* PrettyTree(Dict<int, bool>* seen = nullptr);
|
222 |
|
223 | static constexpr ObjHeader obj_header() {
|
224 | return ObjHeader::AsdlClass(static_cast<uint16_t>(cflow_e::Return), 0);
|
225 | }
|
226 |
|
227 | int val;
|
228 |
|
229 | DISALLOW_COPY_AND_ASSIGN(cflow__Return)
|
230 | };
|
231 |
|
232 | extern GcGlobal<cflow__Break> gcflow__Break;
|
233 | extern GcGlobal<cflow__Continue> gcflow__Continue;
|
234 | ASDL_NAMES cflow {
|
235 | static cflow__Break* Break;
|
236 | static cflow__Continue* Continue;
|
237 | typedef cflow__Return Return;
|
238 | };
|
239 |
|
240 | class prod {
|
241 | public:
|
242 | prod(BigStr* a, BigStr* b)
|
243 | : a(a),
|
244 | b(b) {
|
245 | }
|
246 |
|
247 | static prod* CreateNull(bool alloc_lists = false) {
|
248 | return Alloc<prod>(kEmptyString, kEmptyString);
|
249 | }
|
250 |
|
251 | hnode_t* PrettyTree(Dict<int, bool>* seen = nullptr);
|
252 |
|
253 | static constexpr ObjHeader obj_header() {
|
254 | return ObjHeader::AsdlClass(64, 2);
|
255 | }
|
256 |
|
257 | BigStr* a;
|
258 | BigStr* b;
|
259 |
|
260 | DISALLOW_COPY_AND_ASSIGN(prod)
|
261 | };
|
262 |
|
263 | class DoubleQuoted : public expr_t, public word_part_t {
|
264 | public:
|
265 | DoubleQuoted(int left, List<BigStr*>* tokens)
|
266 | : tokens(tokens),
|
267 | left(left) {
|
268 | }
|
269 |
|
270 | static DoubleQuoted* CreateNull(bool alloc_lists = false) {
|
271 | return Alloc<DoubleQuoted>(-1, alloc_lists ? Alloc<List<BigStr*>>() :
|
272 | nullptr);
|
273 | }
|
274 |
|
275 | hnode_t* PrettyTree(Dict<int, bool>* seen = nullptr);
|
276 |
|
277 | static constexpr ObjHeader obj_header() {
|
278 | return ObjHeader::AsdlClass(65, 1);
|
279 | }
|
280 |
|
281 | List<BigStr*>* tokens;
|
282 | int left;
|
283 |
|
284 | DISALLOW_COPY_AND_ASSIGN(DoubleQuoted)
|
285 | };
|
286 |
|
287 | class Token : public tok_t {
|
288 | public:
|
289 | Token(int id, BigStr* val)
|
290 | : val(val),
|
291 | id(id) {
|
292 | }
|
293 |
|
294 | static Token* CreateNull(bool alloc_lists = false) {
|
295 | return Alloc<Token>(-1, kEmptyString);
|
296 | }
|
297 |
|
298 | hnode_t* PrettyTree(Dict<int, bool>* seen = nullptr);
|
299 |
|
300 | static constexpr ObjHeader obj_header() {
|
301 | return ObjHeader::AsdlClass(66, 1);
|
302 | }
|
303 |
|
304 | BigStr* val;
|
305 | int id;
|
306 |
|
307 | DISALLOW_COPY_AND_ASSIGN(Token)
|
308 | };
|
309 |
|
310 | class tok_struct {
|
311 | public:
|
312 | tok_struct(tok_t* token, int x)
|
313 | : token(token),
|
314 | x(x) {
|
315 | }
|
316 |
|
317 | static tok_struct* CreateNull(bool alloc_lists = false) {
|
318 | return Alloc<tok_struct>(nullptr, -1);
|
319 | }
|
320 |
|
321 | hnode_t* PrettyTree(Dict<int, bool>* seen = nullptr);
|
322 |
|
323 | static constexpr ObjHeader obj_header() {
|
324 | return ObjHeader::AsdlClass(67, 1);
|
325 | }
|
326 |
|
327 | tok_t* token;
|
328 | int x;
|
329 |
|
330 | DISALLOW_COPY_AND_ASSIGN(tok_struct)
|
331 | };
|
332 |
|
333 | class tok_array {
|
334 | public:
|
335 | tok_array(List<tok_t*>* tokens)
|
336 | : tokens(tokens) {
|
337 | }
|
338 |
|
339 | static tok_array* CreateNull(bool alloc_lists = false) {
|
340 | return Alloc<tok_array>(alloc_lists ? Alloc<List<tok_t*>>() : nullptr);
|
341 | }
|
342 |
|
343 | hnode_t* PrettyTree(Dict<int, bool>* seen = nullptr);
|
344 |
|
345 | static constexpr ObjHeader obj_header() {
|
346 | return ObjHeader::AsdlClass(68, 1);
|
347 | }
|
348 |
|
349 | List<tok_t*>* tokens;
|
350 |
|
351 | DISALLOW_COPY_AND_ASSIGN(tok_array)
|
352 | };
|
353 |
|
354 |
|
355 | } // namespace shared_variant_asdl
|
356 |
|
357 | #endif // SHARED_VARIANT_ASDL
|