OILS / _gen / asdl / examples / shared_variant.asdl.h View on Github | oils.pub

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