OILS / prebuilt / frontend / args.mycpp.h View on Github | oils.pub

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