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

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