OILS / _gen / display / pretty.asdl.h View on Github | oilshell.org

286 lines, 178 significant
1// _gen/display/pretty.asdl.h is generated by asdl_main.py
2
3#ifndef PRETTY_ASDL
4#define PRETTY_ASDL
5
6#include <cstdint>
7
8#include "mycpp/runtime.h"
9#include "_gen/asdl/hnode.asdl.h"
10using hnode_asdl::hnode_t;
11
12namespace pretty_asdl {
13
14// use struct instead of namespace so 'using' works consistently
15#define ASDL_NAMES struct
16
17class MeasuredDoc;
18class Measure;
19class doc_t;
20class DocFragment;
21
22ASDL_NAMES doc_e {
23 enum no_name {
24 Break = 1,
25 Text = 2,
26 Indent = 3,
27 Concat = 4,
28 Group = 5,
29 IfFlat = 6,
30 Flat = 7,
31 };
32};
33
34BigStr* doc_str(int tag, bool dot = true);
35
36class doc_t {
37 protected:
38 doc_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(doc_t)
46};
47
48class doc__Break : public doc_t {
49 public:
50 doc__Break(BigStr* string)
51 : string(string) {
52 }
53
54 static doc__Break* CreateNull(bool alloc_lists = false) {
55 return Alloc<doc__Break>(kEmptyString);
56 }
57
58 hnode_t* PrettyTree(Dict<int, bool>* seen = nullptr);
59
60 static constexpr ObjHeader obj_header() {
61 return ObjHeader::AsdlClass(static_cast<uint16_t>(doc_e::Break), 1);
62 }
63
64 BigStr* string;
65
66 DISALLOW_COPY_AND_ASSIGN(doc__Break)
67};
68
69class doc__Text : public doc_t {
70 public:
71 doc__Text(BigStr* string)
72 : string(string) {
73 }
74
75 static doc__Text* CreateNull(bool alloc_lists = false) {
76 return Alloc<doc__Text>(kEmptyString);
77 }
78
79 hnode_t* PrettyTree(Dict<int, bool>* seen = nullptr);
80
81 static constexpr ObjHeader obj_header() {
82 return ObjHeader::AsdlClass(static_cast<uint16_t>(doc_e::Text), 1);
83 }
84
85 BigStr* string;
86
87 DISALLOW_COPY_AND_ASSIGN(doc__Text)
88};
89
90class doc__Indent : public doc_t {
91 public:
92 doc__Indent(int indent, MeasuredDoc* mdoc)
93 : mdoc(mdoc),
94 indent(indent) {
95 }
96
97 static doc__Indent* CreateNull(bool alloc_lists = false) {
98 return Alloc<doc__Indent>(-1, nullptr);
99 }
100
101 hnode_t* PrettyTree(Dict<int, bool>* seen = nullptr);
102
103 static constexpr ObjHeader obj_header() {
104 return ObjHeader::AsdlClass(static_cast<uint16_t>(doc_e::Indent), 1);
105 }
106
107 MeasuredDoc* mdoc;
108 int indent;
109
110 DISALLOW_COPY_AND_ASSIGN(doc__Indent)
111};
112
113class doc__Concat : public doc_t {
114 public:
115 doc__Concat(List<MeasuredDoc*>* mdocs)
116 : mdocs(mdocs) {
117 }
118
119 static doc__Concat* CreateNull(bool alloc_lists = false) {
120 return Alloc<doc__Concat>(alloc_lists ? Alloc<List<MeasuredDoc*>>() :
121 nullptr);
122 }
123
124 hnode_t* PrettyTree(Dict<int, bool>* seen = nullptr);
125
126 static constexpr ObjHeader obj_header() {
127 return ObjHeader::AsdlClass(static_cast<uint16_t>(doc_e::Concat), 1);
128 }
129
130 List<MeasuredDoc*>* mdocs;
131
132 DISALLOW_COPY_AND_ASSIGN(doc__Concat)
133};
134
135class doc__Group : public doc_t {
136 public:
137 doc__Group(MeasuredDoc* mdoc)
138 : mdoc(mdoc) {
139 }
140
141 static doc__Group* CreateNull(bool alloc_lists = false) {
142 return Alloc<doc__Group>(nullptr);
143 }
144
145 hnode_t* PrettyTree(Dict<int, bool>* seen = nullptr);
146
147 static constexpr ObjHeader obj_header() {
148 return ObjHeader::AsdlClass(static_cast<uint16_t>(doc_e::Group), 1);
149 }
150
151 MeasuredDoc* mdoc;
152
153 DISALLOW_COPY_AND_ASSIGN(doc__Group)
154};
155
156class doc__IfFlat : public doc_t {
157 public:
158 doc__IfFlat(MeasuredDoc* flat_mdoc, MeasuredDoc* nonflat_mdoc)
159 : flat_mdoc(flat_mdoc),
160 nonflat_mdoc(nonflat_mdoc) {
161 }
162
163 static doc__IfFlat* CreateNull(bool alloc_lists = false) {
164 return Alloc<doc__IfFlat>(nullptr, nullptr);
165 }
166
167 hnode_t* PrettyTree(Dict<int, bool>* seen = nullptr);
168
169 static constexpr ObjHeader obj_header() {
170 return ObjHeader::AsdlClass(static_cast<uint16_t>(doc_e::IfFlat), 2);
171 }
172
173 MeasuredDoc* flat_mdoc;
174 MeasuredDoc* nonflat_mdoc;
175
176 DISALLOW_COPY_AND_ASSIGN(doc__IfFlat)
177};
178
179class doc__Flat : public doc_t {
180 public:
181 doc__Flat(MeasuredDoc* mdoc)
182 : mdoc(mdoc) {
183 }
184
185 static doc__Flat* CreateNull(bool alloc_lists = false) {
186 return Alloc<doc__Flat>(nullptr);
187 }
188
189 hnode_t* PrettyTree(Dict<int, bool>* seen = nullptr);
190
191 static constexpr ObjHeader obj_header() {
192 return ObjHeader::AsdlClass(static_cast<uint16_t>(doc_e::Flat), 1);
193 }
194
195 MeasuredDoc* mdoc;
196
197 DISALLOW_COPY_AND_ASSIGN(doc__Flat)
198};
199
200ASDL_NAMES doc {
201 typedef doc__Break Break;
202 typedef doc__Text Text;
203 typedef doc__Indent Indent;
204 typedef doc__Concat Concat;
205 typedef doc__Group Group;
206 typedef doc__IfFlat IfFlat;
207 typedef doc__Flat Flat;
208};
209
210class MeasuredDoc {
211 public:
212 MeasuredDoc(doc_t* doc, Measure* measure)
213 : doc(doc),
214 measure(measure) {
215 }
216
217 static MeasuredDoc* CreateNull(bool alloc_lists = false) {
218 return Alloc<MeasuredDoc>(nullptr, nullptr);
219 }
220
221 hnode_t* PrettyTree(Dict<int, bool>* seen = nullptr);
222
223 static constexpr ObjHeader obj_header() {
224 return ObjHeader::AsdlClass(64, 2);
225 }
226
227 doc_t* doc;
228 Measure* measure;
229
230 DISALLOW_COPY_AND_ASSIGN(MeasuredDoc)
231};
232
233class Measure {
234 public:
235 Measure(int flat, int nonflat)
236 : flat(flat),
237 nonflat(nonflat) {
238 }
239
240 static Measure* CreateNull(bool alloc_lists = false) {
241 return Alloc<Measure>(-1, -1);
242 }
243
244 hnode_t* PrettyTree(Dict<int, bool>* seen = nullptr);
245
246 static constexpr ObjHeader obj_header() {
247 return ObjHeader::AsdlClass(65, 0);
248 }
249
250 int flat;
251 int nonflat;
252
253 DISALLOW_COPY_AND_ASSIGN(Measure)
254};
255
256class DocFragment {
257 public:
258 DocFragment(MeasuredDoc* mdoc, int indent, bool is_flat, Measure* measure)
259 : mdoc(mdoc),
260 measure(measure),
261 indent(indent),
262 is_flat(is_flat) {
263 }
264
265 static DocFragment* CreateNull(bool alloc_lists = false) {
266 return Alloc<DocFragment>(nullptr, -1, false, nullptr);
267 }
268
269 hnode_t* PrettyTree(Dict<int, bool>* seen = nullptr);
270
271 static constexpr ObjHeader obj_header() {
272 return ObjHeader::AsdlClass(66, 2);
273 }
274
275 MeasuredDoc* mdoc;
276 Measure* measure;
277 int indent;
278 bool is_flat;
279
280 DISALLOW_COPY_AND_ASSIGN(DocFragment)
281};
282
283
284} // namespace pretty_asdl
285
286#endif // PRETTY_ASDL