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

384 lines, 250 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 0;
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 1;
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 2;
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 3;
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 static constexpr ObjHeader obj_header() {
286 return ObjHeader::AsdlClass(64, 2);
287 }
288 BigStr* a;
289 BigStr* b;
290
291 DISALLOW_COPY_AND_ASSIGN(prod)
292};
293
294class DoubleQuoted : public expr_t, public word_part_t {
295 public:
296 DoubleQuoted(int left, List<BigStr*>* tokens)
297 : tokens(tokens),
298 left(left) {
299 }
300
301 static DoubleQuoted* CreateNull(bool alloc_lists = false) {
302 return Alloc<DoubleQuoted>(-1, alloc_lists ? Alloc<List<BigStr*>>() :
303 nullptr);
304 }
305
306 hnode_t* PrettyTree(bool do_abbrev, Dict<int, bool>* seen = nullptr);
307
308 static constexpr ObjHeader obj_header() {
309 return ObjHeader::AsdlClass(65, 1);
310 }
311 List<BigStr*>* tokens;
312 int left;
313
314 DISALLOW_COPY_AND_ASSIGN(DoubleQuoted)
315};
316
317class Token : public tok_t {
318 public:
319 Token(int id, BigStr* val)
320 : val(val),
321 id(id) {
322 }
323
324 static Token* CreateNull(bool alloc_lists = false) {
325 return Alloc<Token>(-1, kEmptyString);
326 }
327
328 hnode_t* PrettyTree(bool do_abbrev, Dict<int, bool>* seen = nullptr);
329
330 static constexpr ObjHeader obj_header() {
331 return ObjHeader::AsdlClass(66, 1);
332 }
333 BigStr* val;
334 int id;
335
336 DISALLOW_COPY_AND_ASSIGN(Token)
337};
338
339class tok_struct {
340 public:
341 tok_struct(tok_t* token, int x)
342 : token(token),
343 x(x) {
344 }
345
346 static tok_struct* CreateNull(bool alloc_lists = false) {
347 return Alloc<tok_struct>(nullptr, -1);
348 }
349
350 hnode_t* PrettyTree(bool do_abbrev, Dict<int, bool>* seen = nullptr);
351
352 static constexpr ObjHeader obj_header() {
353 return ObjHeader::AsdlClass(67, 1);
354 }
355 tok_t* token;
356 int x;
357
358 DISALLOW_COPY_AND_ASSIGN(tok_struct)
359};
360
361class tok_array {
362 public:
363 tok_array(List<tok_t*>* tokens)
364 : tokens(tokens) {
365 }
366
367 static tok_array* CreateNull(bool alloc_lists = false) {
368 return Alloc<tok_array>(alloc_lists ? Alloc<List<tok_t*>>() : nullptr);
369 }
370
371 hnode_t* PrettyTree(bool do_abbrev, Dict<int, bool>* seen = nullptr);
372
373 static constexpr ObjHeader obj_header() {
374 return ObjHeader::AsdlClass(68, 1);
375 }
376 List<tok_t*>* tokens;
377
378 DISALLOW_COPY_AND_ASSIGN(tok_array)
379};
380
381
382} // namespace shared_variant_asdl
383
384#endif // SHARED_VARIANT_ASDL