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

336 lines, 227 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 class TraversalState;
22}
23
24namespace format { // forward declare
25}
26
27namespace args { // forward declare
28 class _Attributes;
29 class Reader;
30 class _Action;
31 class _ArgAction;
32 class SetToInt;
33 class SetToFloat;
34 class SetToString;
35 class SetAttachedBool;
36 class SetToTrue;
37 class SetOption;
38 class SetNamedOption;
39 class SetAction;
40 class SetNamedAction;
41}
42
43namespace runtime { // declare
44
45extern int NO_SPID;
46hnode::Record* NewRecord(BigStr* node_type);
47hnode::Leaf* NewLeaf(BigStr* s, hnode_asdl::color_t e_color);
48class TraversalState {
49 public:
50 TraversalState();
51 Dict<int, bool>* seen{};
52 Dict<int, int>* ref_count{};
53
54 static constexpr ObjHeader obj_header() {
55 return ObjHeader::ClassScanned(2, sizeof(TraversalState));
56 }
57
58 DISALLOW_COPY_AND_ASSIGN(TraversalState)
59};
60
61extern BigStr* TRUE_STR;
62extern BigStr* FALSE_STR;
63
64} // declare namespace runtime
65
66namespace format { // declare
67
68int _HNodeCount(hnode_asdl::hnode_t* h);
69int _DocCount(pretty_asdl::doc_t* d);
70void _HNodePrettyPrint(bool perf_stats, bool doc_debug, hnode_asdl::hnode_t* node, mylib::Writer* f, int max_width = 80);
71void HNodePrettyPrint(hnode_asdl::hnode_t* node, mylib::Writer* f, int max_width = 80);
72
73} // declare namespace format
74
75namespace args { // declare
76
77extern int String;
78extern int Int;
79extern int Float;
80extern int Bool;
81class _Attributes {
82 public:
83 _Attributes(Dict<BigStr*, value_asdl::value_t*>* defaults);
84 void SetTrue(BigStr* name);
85 void Set(BigStr* name, value_asdl::value_t* val);
86 Dict<BigStr*, value_asdl::value_t*>* attrs{};
87 List<Tuple2<BigStr*, bool>*>* opt_changes{};
88 List<Tuple2<BigStr*, bool>*>* shopt_changes{};
89 List<BigStr*>* actions{};
90 bool show_options{};
91 bool saw_double_dash{};
92
93 static constexpr ObjHeader obj_header() {
94 return ObjHeader::ClassScanned(4, sizeof(_Attributes));
95 }
96
97 DISALLOW_COPY_AND_ASSIGN(_Attributes)
98};
99
100class Reader {
101 public:
102 Reader(List<BigStr*>* argv, List<syntax_asdl::CompoundWord*>* locs = nullptr);
103 void Next();
104 BigStr* Peek();
105 Tuple2<BigStr*, syntax_asdl::loc_t*> Peek2();
106 BigStr* ReadRequired(BigStr* error_msg);
107 Tuple2<BigStr*, syntax_asdl::loc_t*> ReadRequired2(BigStr* error_msg);
108 List<BigStr*>* Rest();
109 Tuple2<List<BigStr*>*, List<syntax_asdl::CompoundWord*>*> Rest2();
110 bool AtEnd();
111 void Done();
112 syntax_asdl::loc_t* _FirstLocation();
113 syntax_asdl::loc_t* Location();
114 List<BigStr*>* argv{};
115 List<syntax_asdl::CompoundWord*>* locs{};
116 int n{};
117 int i{};
118
119 static constexpr ObjHeader obj_header() {
120 return ObjHeader::ClassScanned(2, sizeof(Reader));
121 }
122
123 DISALLOW_COPY_AND_ASSIGN(Reader)
124};
125
126class _Action {
127 public:
128 _Action();
129 virtual bool OnMatch(BigStr* attached_arg, args::Reader* arg_r, args::_Attributes* out);
130
131 static constexpr uint32_t field_mask() {
132 return kZeroMask;
133 }
134
135 static constexpr ObjHeader obj_header() {
136 return ObjHeader::ClassFixed(field_mask(), sizeof(_Action));
137 }
138
139 DISALLOW_COPY_AND_ASSIGN(_Action)
140};
141
142class _ArgAction : public ::args::_Action {
143 public:
144 _ArgAction(BigStr* name, bool quit_parsing_flags, List<BigStr*>* valid = nullptr);
145 virtual value_asdl::value_t* _Value(BigStr* arg, syntax_asdl::loc_t* location);
146 virtual bool OnMatch(BigStr* attached_arg, args::Reader* arg_r, args::_Attributes* out);
147
148 BigStr* name{};
149 bool quit_parsing_flags{};
150 List<BigStr*>* valid{};
151
152 static constexpr uint32_t field_mask() {
153 return ::args::_Action::field_mask()
154 | maskbit(offsetof(_ArgAction, name))
155 | maskbit(offsetof(_ArgAction, valid));
156 }
157
158 static constexpr ObjHeader obj_header() {
159 return ObjHeader::ClassFixed(field_mask(), sizeof(_ArgAction));
160 }
161
162 DISALLOW_COPY_AND_ASSIGN(_ArgAction)
163};
164
165class SetToInt : public ::args::_ArgAction {
166 public:
167 SetToInt(BigStr* name);
168 virtual value_asdl::value_t* _Value(BigStr* arg, syntax_asdl::loc_t* location);
169
170 static constexpr uint32_t field_mask() {
171 return ::args::_ArgAction::field_mask();
172 }
173
174 static constexpr ObjHeader obj_header() {
175 return ObjHeader::ClassFixed(field_mask(), sizeof(SetToInt));
176 }
177
178 DISALLOW_COPY_AND_ASSIGN(SetToInt)
179};
180
181class SetToFloat : public ::args::_ArgAction {
182 public:
183 SetToFloat(BigStr* name);
184 virtual value_asdl::value_t* _Value(BigStr* arg, syntax_asdl::loc_t* location);
185
186 static constexpr uint32_t field_mask() {
187 return ::args::_ArgAction::field_mask();
188 }
189
190 static constexpr ObjHeader obj_header() {
191 return ObjHeader::ClassFixed(field_mask(), sizeof(SetToFloat));
192 }
193
194 DISALLOW_COPY_AND_ASSIGN(SetToFloat)
195};
196
197class SetToString : public ::args::_ArgAction {
198 public:
199 SetToString(BigStr* name, bool quit_parsing_flags, List<BigStr*>* valid = nullptr);
200 virtual value_asdl::value_t* _Value(BigStr* arg, syntax_asdl::loc_t* location);
201
202 static constexpr uint32_t field_mask() {
203 return ::args::_ArgAction::field_mask();
204 }
205
206 static constexpr ObjHeader obj_header() {
207 return ObjHeader::ClassFixed(field_mask(), sizeof(SetToString));
208 }
209
210 DISALLOW_COPY_AND_ASSIGN(SetToString)
211};
212
213class SetAttachedBool : public ::args::_Action {
214 public:
215 SetAttachedBool(BigStr* name);
216 virtual bool OnMatch(BigStr* attached_arg, args::Reader* arg_r, args::_Attributes* out);
217
218 BigStr* name{};
219
220 static constexpr uint32_t field_mask() {
221 return ::args::_Action::field_mask()
222 | maskbit(offsetof(SetAttachedBool, name));
223 }
224
225 static constexpr ObjHeader obj_header() {
226 return ObjHeader::ClassFixed(field_mask(), sizeof(SetAttachedBool));
227 }
228
229 DISALLOW_COPY_AND_ASSIGN(SetAttachedBool)
230};
231
232class SetToTrue : public ::args::_Action {
233 public:
234 SetToTrue(BigStr* name);
235 virtual bool OnMatch(BigStr* attached_arg, args::Reader* arg_r, args::_Attributes* out);
236
237 BigStr* name{};
238
239 static constexpr uint32_t field_mask() {
240 return ::args::_Action::field_mask()
241 | maskbit(offsetof(SetToTrue, name));
242 }
243
244 static constexpr ObjHeader obj_header() {
245 return ObjHeader::ClassFixed(field_mask(), sizeof(SetToTrue));
246 }
247
248 DISALLOW_COPY_AND_ASSIGN(SetToTrue)
249};
250
251class SetOption : public ::args::_Action {
252 public:
253 SetOption(BigStr* name);
254 virtual bool OnMatch(BigStr* attached_arg, args::Reader* arg_r, args::_Attributes* out);
255
256 BigStr* name{};
257
258 static constexpr uint32_t field_mask() {
259 return ::args::_Action::field_mask()
260 | maskbit(offsetof(SetOption, name));
261 }
262
263 static constexpr ObjHeader obj_header() {
264 return ObjHeader::ClassFixed(field_mask(), sizeof(SetOption));
265 }
266
267 DISALLOW_COPY_AND_ASSIGN(SetOption)
268};
269
270class SetNamedOption : public ::args::_Action {
271 public:
272 SetNamedOption(bool shopt = false);
273 void ArgName(BigStr* name);
274 virtual bool OnMatch(BigStr* attached_arg, args::Reader* arg_r, args::_Attributes* out);
275
276 List<BigStr*>* names{};
277 bool shopt{};
278
279 static constexpr uint32_t field_mask() {
280 return ::args::_Action::field_mask()
281 | maskbit(offsetof(SetNamedOption, names));
282 }
283
284 static constexpr ObjHeader obj_header() {
285 return ObjHeader::ClassFixed(field_mask(), sizeof(SetNamedOption));
286 }
287
288 DISALLOW_COPY_AND_ASSIGN(SetNamedOption)
289};
290
291class SetAction : public ::args::_Action {
292 public:
293 SetAction(BigStr* name);
294 virtual bool OnMatch(BigStr* attached_arg, args::Reader* arg_r, args::_Attributes* out);
295
296 BigStr* name{};
297
298 static constexpr uint32_t field_mask() {
299 return ::args::_Action::field_mask()
300 | maskbit(offsetof(SetAction, name));
301 }
302
303 static constexpr ObjHeader obj_header() {
304 return ObjHeader::ClassFixed(field_mask(), sizeof(SetAction));
305 }
306
307 DISALLOW_COPY_AND_ASSIGN(SetAction)
308};
309
310class SetNamedAction : public ::args::_Action {
311 public:
312 SetNamedAction();
313 void ArgName(BigStr* name);
314 virtual bool OnMatch(BigStr* attached_arg, args::Reader* arg_r, args::_Attributes* out);
315
316 List<BigStr*>* names{};
317
318 static constexpr uint32_t field_mask() {
319 return ::args::_Action::field_mask()
320 | maskbit(offsetof(SetNamedAction, names));
321 }
322
323 static constexpr ObjHeader obj_header() {
324 return ObjHeader::ClassFixed(field_mask(), sizeof(SetNamedAction));
325 }
326
327 DISALLOW_COPY_AND_ASSIGN(SetNamedAction)
328};
329
330args::_Attributes* Parse(flag_spec::_FlagSpec* spec, args::Reader* arg_r);
331args::_Attributes* ParseLikeEcho(flag_spec::_FlagSpec* spec, args::Reader* arg_r);
332args::_Attributes* ParseMore(flag_spec::_FlagSpecAndMore* spec, args::Reader* arg_r);
333
334} // declare namespace args
335
336#endif // FRONTEND_ARGS_MYCPP_H