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

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