OILS / prebuilt / frontend / args.mycpp.h View on Github | oilshell.org

451 lines, 308 significant
1// prebuilt/frontend/args.mycpp.h: GENERATED by mycpp
2
3#ifndef FRONTEND_ARGS_MYCPP_H
4#define FRONTEND_ARGS_MYCPP_H
5
6#include "_gen/asdl/hnode.asdl.h"
7#include "_gen/display/pretty.asdl.h"
8#include "cpp/data_lang.h"
9#include "mycpp/runtime.h"
10
11#include "_gen/core/runtime.asdl.h"
12#include "_gen/core/value.asdl.h"
13#include "_gen/display/pretty.asdl.h"
14#include "_gen/frontend/syntax.asdl.h"
15#include "cpp/frontend_flag_spec.h"
16
17using value_asdl::value; // This is a bit ad hoc
18using pretty_asdl::doc;
19
20namespace runtime { // forward declare
21
22 class TraversalState;
23
24} // forward declare namespace runtime
25
26namespace format { // forward declare
27
28 class ColorOutput;
29 class TextOutput;
30 class HtmlOutput;
31 class AnsiOutput;
32 class _PrettyPrinter;
33
34} // forward declare namespace format
35
36namespace args { // forward declare
37
38 class _Attributes;
39 class Reader;
40 class _Action;
41 class _ArgAction;
42 class SetToInt;
43 class SetToFloat;
44 class SetToString;
45 class SetAttachedBool;
46 class SetToTrue;
47 class SetOption;
48 class SetNamedOption;
49 class SetAction;
50 class SetNamedAction;
51
52} // forward declare namespace args
53
54namespace runtime { // declare
55
56using hnode_asdl::hnode;
57extern int NO_SPID;
58hnode::Record* NewRecord(BigStr* node_type);
59hnode::Leaf* NewLeaf(BigStr* s, hnode_asdl::color_t e_color);
60class TraversalState {
61 public:
62 TraversalState();
63 Dict<int, bool>* seen;
64 Dict<int, int>* ref_count;
65
66 static constexpr ObjHeader obj_header() {
67 return ObjHeader::ClassScanned(2, sizeof(TraversalState));
68 }
69
70 DISALLOW_COPY_AND_ASSIGN(TraversalState)
71};
72
73extern BigStr* TRUE_STR;
74extern BigStr* FALSE_STR;
75
76} // declare namespace runtime
77
78namespace format { // declare
79
80using hnode_asdl::hnode;
81format::ColorOutput* DetectConsoleOutput(mylib::Writer* f);
82class ColorOutput {
83 public:
84 ColorOutput(mylib::Writer* f);
85 virtual format::ColorOutput* NewTempBuffer();
86 virtual void FileHeader();
87 virtual void FileFooter();
88 virtual void PushColor(hnode_asdl::color_t e_color);
89 virtual void PopColor();
90 virtual void write(BigStr* s);
91 void WriteRaw(Tuple2<BigStr*, int>* raw);
92 int NumChars();
93 Tuple2<BigStr*, int> GetRaw();
94 mylib::Writer* f;
95 int num_chars;
96
97 static constexpr uint32_t field_mask() {
98 return maskbit(offsetof(ColorOutput, f));
99 }
100
101 static constexpr ObjHeader obj_header() {
102 return ObjHeader::ClassFixed(field_mask(), sizeof(ColorOutput));
103 }
104
105 DISALLOW_COPY_AND_ASSIGN(ColorOutput)
106};
107
108class TextOutput : public ::format::ColorOutput {
109 public:
110 TextOutput(mylib::Writer* f);
111 virtual format::TextOutput* NewTempBuffer();
112 virtual void PushColor(hnode_asdl::color_t e_color);
113 virtual void PopColor();
114
115 static constexpr uint32_t field_mask() {
116 return ::format::ColorOutput::field_mask();
117 }
118
119 static constexpr ObjHeader obj_header() {
120 return ObjHeader::ClassFixed(field_mask(), sizeof(TextOutput));
121 }
122
123 DISALLOW_COPY_AND_ASSIGN(TextOutput)
124};
125
126class HtmlOutput : public ::format::ColorOutput {
127 public:
128 HtmlOutput(mylib::Writer* f);
129 virtual format::HtmlOutput* NewTempBuffer();
130 virtual void FileHeader();
131 virtual void FileFooter();
132 virtual void PushColor(hnode_asdl::color_t e_color);
133 virtual void PopColor();
134 virtual void write(BigStr* s);
135
136 static constexpr uint32_t field_mask() {
137 return ::format::ColorOutput::field_mask();
138 }
139
140 static constexpr ObjHeader obj_header() {
141 return ObjHeader::ClassFixed(field_mask(), sizeof(HtmlOutput));
142 }
143
144 DISALLOW_COPY_AND_ASSIGN(HtmlOutput)
145};
146
147class AnsiOutput : public ::format::ColorOutput {
148 public:
149 AnsiOutput(mylib::Writer* f);
150 virtual format::AnsiOutput* NewTempBuffer();
151 virtual void PushColor(hnode_asdl::color_t e_color);
152 virtual void PopColor();
153
154 static constexpr uint32_t field_mask() {
155 return ::format::ColorOutput::field_mask();
156 }
157
158 static constexpr ObjHeader obj_header() {
159 return ObjHeader::ClassFixed(field_mask(), sizeof(AnsiOutput));
160 }
161
162 DISALLOW_COPY_AND_ASSIGN(AnsiOutput)
163};
164
165extern int INDENT;
166class _PrettyPrinter {
167 public:
168 _PrettyPrinter(int max_col);
169 bool _PrintWrappedArray(List<hnode_asdl::hnode_t*>* array, int prefix_len, format::ColorOutput* f, int indent);
170 bool _PrintWholeArray(List<hnode_asdl::hnode_t*>* array, int prefix_len, format::ColorOutput* f, int indent);
171 void _PrintRecord(hnode::Record* node, format::ColorOutput* f, int indent);
172 void PrintNode(hnode_asdl::hnode_t* node, format::ColorOutput* f, int indent);
173 int max_col;
174
175 static constexpr ObjHeader obj_header() {
176 return ObjHeader::ClassScanned(0, sizeof(_PrettyPrinter));
177 }
178
179 DISALLOW_COPY_AND_ASSIGN(_PrettyPrinter)
180};
181
182bool _TrySingleLineObj(hnode::Record* node, format::ColorOutput* f, int max_chars);
183bool _TrySingleLine(hnode_asdl::hnode_t* node, format::ColorOutput* f, int max_chars);
184void PrintTree(hnode_asdl::hnode_t* node, format::ColorOutput* f);
185void PrintTree2(hnode_asdl::hnode_t* node, format::ColorOutput* f);
186
187} // declare namespace format
188
189namespace args { // declare
190
191using syntax_asdl::loc;
192extern int String;
193extern int Int;
194extern int Float;
195extern int Bool;
196class _Attributes {
197 public:
198 _Attributes(Dict<BigStr*, value_asdl::value_t*>* defaults);
199 void SetTrue(BigStr* name);
200 void Set(BigStr* name, value_asdl::value_t* val);
201 Dict<BigStr*, value_asdl::value_t*>* attrs;
202 List<Tuple2<BigStr*, bool>*>* opt_changes;
203 List<Tuple2<BigStr*, bool>*>* shopt_changes;
204 List<BigStr*>* actions;
205 bool show_options;
206 bool saw_double_dash;
207
208 static constexpr ObjHeader obj_header() {
209 return ObjHeader::ClassScanned(4, sizeof(_Attributes));
210 }
211
212 DISALLOW_COPY_AND_ASSIGN(_Attributes)
213};
214
215class Reader {
216 public:
217 Reader(List<BigStr*>* argv, List<syntax_asdl::CompoundWord*>* locs = nullptr);
218 void Next();
219 BigStr* Peek();
220 Tuple2<BigStr*, syntax_asdl::loc_t*> Peek2();
221 BigStr* ReadRequired(BigStr* error_msg);
222 Tuple2<BigStr*, syntax_asdl::loc_t*> ReadRequired2(BigStr* error_msg);
223 List<BigStr*>* Rest();
224 Tuple2<List<BigStr*>*, List<syntax_asdl::CompoundWord*>*> Rest2();
225 bool AtEnd();
226 void Done();
227 syntax_asdl::loc_t* _FirstLocation();
228 syntax_asdl::loc_t* Location();
229 List<BigStr*>* argv;
230 List<syntax_asdl::CompoundWord*>* locs;
231 int n;
232 int i;
233
234 static constexpr ObjHeader obj_header() {
235 return ObjHeader::ClassScanned(2, sizeof(Reader));
236 }
237
238 DISALLOW_COPY_AND_ASSIGN(Reader)
239};
240
241class _Action {
242 public:
243 _Action();
244 virtual bool OnMatch(BigStr* attached_arg, args::Reader* arg_r, args::_Attributes* out);
245
246 static constexpr uint32_t field_mask() {
247 return kZeroMask;
248 }
249
250 static constexpr ObjHeader obj_header() {
251 return ObjHeader::ClassFixed(field_mask(), sizeof(_Action));
252 }
253
254 DISALLOW_COPY_AND_ASSIGN(_Action)
255};
256
257class _ArgAction : public ::args::_Action {
258 public:
259 _ArgAction(BigStr* name, bool quit_parsing_flags, List<BigStr*>* valid = nullptr);
260 virtual value_asdl::value_t* _Value(BigStr* arg, syntax_asdl::loc_t* location);
261 virtual bool OnMatch(BigStr* attached_arg, args::Reader* arg_r, args::_Attributes* out);
262
263 BigStr* name;
264 bool quit_parsing_flags;
265 List<BigStr*>* valid;
266
267 static constexpr uint32_t field_mask() {
268 return ::args::_Action::field_mask()
269 | maskbit(offsetof(_ArgAction, name))
270 | maskbit(offsetof(_ArgAction, valid));
271 }
272
273 static constexpr ObjHeader obj_header() {
274 return ObjHeader::ClassFixed(field_mask(), sizeof(_ArgAction));
275 }
276
277 DISALLOW_COPY_AND_ASSIGN(_ArgAction)
278};
279
280class SetToInt : public ::args::_ArgAction {
281 public:
282 SetToInt(BigStr* name);
283 virtual value_asdl::value_t* _Value(BigStr* arg, syntax_asdl::loc_t* location);
284
285 static constexpr uint32_t field_mask() {
286 return ::args::_ArgAction::field_mask();
287 }
288
289 static constexpr ObjHeader obj_header() {
290 return ObjHeader::ClassFixed(field_mask(), sizeof(SetToInt));
291 }
292
293 DISALLOW_COPY_AND_ASSIGN(SetToInt)
294};
295
296class SetToFloat : public ::args::_ArgAction {
297 public:
298 SetToFloat(BigStr* name);
299 virtual value_asdl::value_t* _Value(BigStr* arg, syntax_asdl::loc_t* location);
300
301 static constexpr uint32_t field_mask() {
302 return ::args::_ArgAction::field_mask();
303 }
304
305 static constexpr ObjHeader obj_header() {
306 return ObjHeader::ClassFixed(field_mask(), sizeof(SetToFloat));
307 }
308
309 DISALLOW_COPY_AND_ASSIGN(SetToFloat)
310};
311
312class SetToString : public ::args::_ArgAction {
313 public:
314 SetToString(BigStr* name, bool quit_parsing_flags, List<BigStr*>* valid = nullptr);
315 virtual value_asdl::value_t* _Value(BigStr* arg, syntax_asdl::loc_t* location);
316
317 static constexpr uint32_t field_mask() {
318 return ::args::_ArgAction::field_mask();
319 }
320
321 static constexpr ObjHeader obj_header() {
322 return ObjHeader::ClassFixed(field_mask(), sizeof(SetToString));
323 }
324
325 DISALLOW_COPY_AND_ASSIGN(SetToString)
326};
327
328class SetAttachedBool : public ::args::_Action {
329 public:
330 SetAttachedBool(BigStr* name);
331 virtual bool OnMatch(BigStr* attached_arg, args::Reader* arg_r, args::_Attributes* out);
332
333 BigStr* name;
334
335 static constexpr uint32_t field_mask() {
336 return ::args::_Action::field_mask()
337 | maskbit(offsetof(SetAttachedBool, name));
338 }
339
340 static constexpr ObjHeader obj_header() {
341 return ObjHeader::ClassFixed(field_mask(), sizeof(SetAttachedBool));
342 }
343
344 DISALLOW_COPY_AND_ASSIGN(SetAttachedBool)
345};
346
347class SetToTrue : public ::args::_Action {
348 public:
349 SetToTrue(BigStr* name);
350 virtual bool OnMatch(BigStr* attached_arg, args::Reader* arg_r, args::_Attributes* out);
351
352 BigStr* name;
353
354 static constexpr uint32_t field_mask() {
355 return ::args::_Action::field_mask()
356 | maskbit(offsetof(SetToTrue, name));
357 }
358
359 static constexpr ObjHeader obj_header() {
360 return ObjHeader::ClassFixed(field_mask(), sizeof(SetToTrue));
361 }
362
363 DISALLOW_COPY_AND_ASSIGN(SetToTrue)
364};
365
366class SetOption : public ::args::_Action {
367 public:
368 SetOption(BigStr* name);
369 virtual bool OnMatch(BigStr* attached_arg, args::Reader* arg_r, args::_Attributes* out);
370
371 BigStr* name;
372
373 static constexpr uint32_t field_mask() {
374 return ::args::_Action::field_mask()
375 | maskbit(offsetof(SetOption, name));
376 }
377
378 static constexpr ObjHeader obj_header() {
379 return ObjHeader::ClassFixed(field_mask(), sizeof(SetOption));
380 }
381
382 DISALLOW_COPY_AND_ASSIGN(SetOption)
383};
384
385class SetNamedOption : public ::args::_Action {
386 public:
387 SetNamedOption(bool shopt = false);
388 void ArgName(BigStr* name);
389 virtual bool OnMatch(BigStr* attached_arg, args::Reader* arg_r, args::_Attributes* out);
390
391 List<BigStr*>* names;
392 bool shopt;
393
394 static constexpr uint32_t field_mask() {
395 return ::args::_Action::field_mask()
396 | maskbit(offsetof(SetNamedOption, names));
397 }
398
399 static constexpr ObjHeader obj_header() {
400 return ObjHeader::ClassFixed(field_mask(), sizeof(SetNamedOption));
401 }
402
403 DISALLOW_COPY_AND_ASSIGN(SetNamedOption)
404};
405
406class SetAction : public ::args::_Action {
407 public:
408 SetAction(BigStr* name);
409 virtual bool OnMatch(BigStr* attached_arg, args::Reader* arg_r, args::_Attributes* out);
410
411 BigStr* name;
412
413 static constexpr uint32_t field_mask() {
414 return ::args::_Action::field_mask()
415 | maskbit(offsetof(SetAction, name));
416 }
417
418 static constexpr ObjHeader obj_header() {
419 return ObjHeader::ClassFixed(field_mask(), sizeof(SetAction));
420 }
421
422 DISALLOW_COPY_AND_ASSIGN(SetAction)
423};
424
425class SetNamedAction : public ::args::_Action {
426 public:
427 SetNamedAction();
428 void ArgName(BigStr* name);
429 virtual bool OnMatch(BigStr* attached_arg, args::Reader* arg_r, args::_Attributes* out);
430
431 List<BigStr*>* names;
432
433 static constexpr uint32_t field_mask() {
434 return ::args::_Action::field_mask()
435 | maskbit(offsetof(SetNamedAction, names));
436 }
437
438 static constexpr ObjHeader obj_header() {
439 return ObjHeader::ClassFixed(field_mask(), sizeof(SetNamedAction));
440 }
441
442 DISALLOW_COPY_AND_ASSIGN(SetNamedAction)
443};
444
445args::_Attributes* Parse(flag_spec::_FlagSpec* spec, args::Reader* arg_r);
446args::_Attributes* ParseLikeEcho(flag_spec::_FlagSpec* spec, args::Reader* arg_r);
447args::_Attributes* ParseMore(flag_spec::_FlagSpecAndMore* spec, args::Reader* arg_r);
448
449} // declare namespace args
450
451#endif // FRONTEND_ARGS_MYCPP_H