1 | // _gen/data_lang/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"
|
10 | using hnode_asdl::hnode_t;
|
11 |
|
12 | namespace pretty_asdl {
|
13 |
|
14 | // use struct instead of namespace so 'using' works consistently
|
15 | #define ASDL_NAMES struct
|
16 |
|
17 | class MeasuredDoc;
|
18 | class Measure;
|
19 | class doc_t;
|
20 | class DocFragment;
|
21 |
|
22 | ASDL_NAMES doc_e {
|
23 | enum no_name {
|
24 | Break = 1,
|
25 | Text = 2,
|
26 | Indent = 3,
|
27 | Concat = 4,
|
28 | Group = 5,
|
29 | };
|
30 | };
|
31 |
|
32 | BigStr* doc_str(int tag, bool dot = true);
|
33 |
|
34 | class doc_t {
|
35 | protected:
|
36 | doc_t() {
|
37 | }
|
38 | public:
|
39 | int tag() const {
|
40 | return ObjHeader::FromObject(this)->type_tag;
|
41 | }
|
42 | hnode_t* PrettyTree(Dict<int, bool>* seen = nullptr);
|
43 | DISALLOW_COPY_AND_ASSIGN(doc_t)
|
44 | };
|
45 |
|
46 | class doc__Break : public doc_t {
|
47 | public:
|
48 | doc__Break(BigStr* string)
|
49 | : string(string) {
|
50 | }
|
51 |
|
52 | static doc__Break* CreateNull(bool alloc_lists = false) {
|
53 | return Alloc<doc__Break>(kEmptyString);
|
54 | }
|
55 |
|
56 | hnode_t* PrettyTree(Dict<int, bool>* seen = nullptr);
|
57 |
|
58 | static constexpr ObjHeader obj_header() {
|
59 | return ObjHeader::AsdlClass(static_cast<uint16_t>(doc_e::Break), 1);
|
60 | }
|
61 |
|
62 | BigStr* string;
|
63 |
|
64 | DISALLOW_COPY_AND_ASSIGN(doc__Break)
|
65 | };
|
66 |
|
67 | class doc__Text : public doc_t {
|
68 | public:
|
69 | doc__Text(BigStr* string)
|
70 | : string(string) {
|
71 | }
|
72 |
|
73 | static doc__Text* CreateNull(bool alloc_lists = false) {
|
74 | return Alloc<doc__Text>(kEmptyString);
|
75 | }
|
76 |
|
77 | hnode_t* PrettyTree(Dict<int, bool>* seen = nullptr);
|
78 |
|
79 | static constexpr ObjHeader obj_header() {
|
80 | return ObjHeader::AsdlClass(static_cast<uint16_t>(doc_e::Text), 1);
|
81 | }
|
82 |
|
83 | BigStr* string;
|
84 |
|
85 | DISALLOW_COPY_AND_ASSIGN(doc__Text)
|
86 | };
|
87 |
|
88 | class doc__Indent : public doc_t {
|
89 | public:
|
90 | doc__Indent(int indent, MeasuredDoc* mdoc)
|
91 | : mdoc(mdoc),
|
92 | indent(indent) {
|
93 | }
|
94 |
|
95 | static doc__Indent* CreateNull(bool alloc_lists = false) {
|
96 | return Alloc<doc__Indent>(-1, nullptr);
|
97 | }
|
98 |
|
99 | hnode_t* PrettyTree(Dict<int, bool>* seen = nullptr);
|
100 |
|
101 | static constexpr ObjHeader obj_header() {
|
102 | return ObjHeader::AsdlClass(static_cast<uint16_t>(doc_e::Indent), 1);
|
103 | }
|
104 |
|
105 | MeasuredDoc* mdoc;
|
106 | int indent;
|
107 |
|
108 | DISALLOW_COPY_AND_ASSIGN(doc__Indent)
|
109 | };
|
110 |
|
111 | class doc__Concat : public doc_t {
|
112 | public:
|
113 | doc__Concat(List<MeasuredDoc*>* mdocs)
|
114 | : mdocs(mdocs) {
|
115 | }
|
116 |
|
117 | static doc__Concat* CreateNull(bool alloc_lists = false) {
|
118 | return Alloc<doc__Concat>(alloc_lists ? Alloc<List<MeasuredDoc*>>() :
|
119 | nullptr);
|
120 | }
|
121 |
|
122 | hnode_t* PrettyTree(Dict<int, bool>* seen = nullptr);
|
123 |
|
124 | static constexpr ObjHeader obj_header() {
|
125 | return ObjHeader::AsdlClass(static_cast<uint16_t>(doc_e::Concat), 1);
|
126 | }
|
127 |
|
128 | List<MeasuredDoc*>* mdocs;
|
129 |
|
130 | DISALLOW_COPY_AND_ASSIGN(doc__Concat)
|
131 | };
|
132 |
|
133 | class doc__Group : public doc_t {
|
134 | public:
|
135 | doc__Group(MeasuredDoc* mdoc)
|
136 | : mdoc(mdoc) {
|
137 | }
|
138 |
|
139 | static doc__Group* CreateNull(bool alloc_lists = false) {
|
140 | return Alloc<doc__Group>(nullptr);
|
141 | }
|
142 |
|
143 | hnode_t* PrettyTree(Dict<int, bool>* seen = nullptr);
|
144 |
|
145 | static constexpr ObjHeader obj_header() {
|
146 | return ObjHeader::AsdlClass(static_cast<uint16_t>(doc_e::Group), 1);
|
147 | }
|
148 |
|
149 | MeasuredDoc* mdoc;
|
150 |
|
151 | DISALLOW_COPY_AND_ASSIGN(doc__Group)
|
152 | };
|
153 |
|
154 | ASDL_NAMES doc {
|
155 | typedef doc__Break Break;
|
156 | typedef doc__Text Text;
|
157 | typedef doc__Indent Indent;
|
158 | typedef doc__Concat Concat;
|
159 | typedef doc__Group Group;
|
160 | };
|
161 |
|
162 | class MeasuredDoc {
|
163 | public:
|
164 | MeasuredDoc(doc_t* doc, Measure* measure)
|
165 | : doc(doc),
|
166 | measure(measure) {
|
167 | }
|
168 |
|
169 | static MeasuredDoc* CreateNull(bool alloc_lists = false) {
|
170 | return Alloc<MeasuredDoc>(nullptr, nullptr);
|
171 | }
|
172 |
|
173 | hnode_t* PrettyTree(Dict<int, bool>* seen = nullptr);
|
174 |
|
175 | static constexpr ObjHeader obj_header() {
|
176 | return ObjHeader::AsdlClass(64, 2);
|
177 | }
|
178 |
|
179 | doc_t* doc;
|
180 | Measure* measure;
|
181 |
|
182 | DISALLOW_COPY_AND_ASSIGN(MeasuredDoc)
|
183 | };
|
184 |
|
185 | class Measure {
|
186 | public:
|
187 | Measure(int flat, int nonflat)
|
188 | : flat(flat),
|
189 | nonflat(nonflat) {
|
190 | }
|
191 |
|
192 | static Measure* CreateNull(bool alloc_lists = false) {
|
193 | return Alloc<Measure>(-1, -1);
|
194 | }
|
195 |
|
196 | hnode_t* PrettyTree(Dict<int, bool>* seen = nullptr);
|
197 |
|
198 | static constexpr ObjHeader obj_header() {
|
199 | return ObjHeader::AsdlClass(65, 0);
|
200 | }
|
201 |
|
202 | int flat;
|
203 | int nonflat;
|
204 |
|
205 | DISALLOW_COPY_AND_ASSIGN(Measure)
|
206 | };
|
207 |
|
208 | class DocFragment {
|
209 | public:
|
210 | DocFragment(MeasuredDoc* mdoc, int indent, bool is_flat, Measure* measure)
|
211 | : mdoc(mdoc),
|
212 | measure(measure),
|
213 | indent(indent),
|
214 | is_flat(is_flat) {
|
215 | }
|
216 |
|
217 | static DocFragment* CreateNull(bool alloc_lists = false) {
|
218 | return Alloc<DocFragment>(nullptr, -1, false, nullptr);
|
219 | }
|
220 |
|
221 | hnode_t* PrettyTree(Dict<int, bool>* seen = nullptr);
|
222 |
|
223 | static constexpr ObjHeader obj_header() {
|
224 | return ObjHeader::AsdlClass(66, 2);
|
225 | }
|
226 |
|
227 | MeasuredDoc* mdoc;
|
228 | Measure* measure;
|
229 | int indent;
|
230 | bool is_flat;
|
231 |
|
232 | DISALLOW_COPY_AND_ASSIGN(DocFragment)
|
233 | };
|
234 |
|
235 |
|
236 | } // namespace pretty_asdl
|
237 |
|
238 | #endif // PRETTY_ASDL
|