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

358 lines, 242 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
95 static constexpr ObjHeader obj_header() {
96 return ObjHeader::ClassScanned(5, sizeof(_Attributes));
97 }
98
99 DISALLOW_COPY_AND_ASSIGN(_Attributes)
100};
101
102class Reader {
103 public:
104 Reader(List<BigStr*>* argv, List<syntax_asdl::CompoundWord*>* locs = nullptr);
105 void Next();
106 BigStr* Peek();
107 Tuple2<BigStr*, syntax_asdl::loc_t*> Peek2();
108 BigStr* ReadRequired(BigStr* error_msg);
109 Tuple2<BigStr*, syntax_asdl::CompoundWord*> ReadRequired2(BigStr* error_msg);
110 List<BigStr*>* Rest();
111 Tuple2<List<BigStr*>*, List<syntax_asdl::CompoundWord*>*> Rest2();
112 bool AtEnd();
113 void Done();
114 syntax_asdl::loc_t* _FirstLocation();
115 syntax_asdl::loc_t* Location();
116 List<BigStr*>* argv{};
117 List<syntax_asdl::CompoundWord*>* locs{};
118 int n{};
119 int i{};
120
121 static constexpr ObjHeader obj_header() {
122 return ObjHeader::ClassScanned(2, sizeof(Reader));
123 }
124
125 DISALLOW_COPY_AND_ASSIGN(Reader)
126};
127
128class _Action {
129 public:
130 _Action();
131 virtual bool OnMatch(BigStr* attached_arg, args::Reader* arg_r, args::_Attributes* out);
132
133 static constexpr uint32_t field_mask() {
134 return kZeroMask;
135 }
136
137 static constexpr ObjHeader obj_header() {
138 return ObjHeader::ClassFixed(field_mask(), sizeof(_Action));
139 }
140
141 DISALLOW_COPY_AND_ASSIGN(_Action)
142};
143
144class AppendEvalFlag : public ::args::_Action {
145 public:
146 AppendEvalFlag(BigStr* name);
147 virtual bool OnMatch(BigStr* attached_arg, args::Reader* arg_r, args::_Attributes* out);
148
149 bool is_pure{};
150 BigStr* name{};
151
152 static constexpr uint32_t field_mask() {
153 return ::args::_Action::field_mask()
154 | maskbit(offsetof(AppendEvalFlag, name));
155 }
156
157 static constexpr ObjHeader obj_header() {
158 return ObjHeader::ClassFixed(field_mask(), sizeof(AppendEvalFlag));
159 }
160
161 DISALLOW_COPY_AND_ASSIGN(AppendEvalFlag)
162};
163
164class _ArgAction : public ::args::_Action {
165 public:
166 _ArgAction(BigStr* name, bool quit_parsing_flags, List<BigStr*>* valid = nullptr);
167 virtual value_asdl::value_t* _Value(BigStr* arg, syntax_asdl::loc_t* location);
168 virtual bool OnMatch(BigStr* attached_arg, args::Reader* arg_r, args::_Attributes* out);
169
170 BigStr* name{};
171 bool quit_parsing_flags{};
172 List<BigStr*>* valid{};
173
174 static constexpr uint32_t field_mask() {
175 return ::args::_Action::field_mask()
176 | maskbit(offsetof(_ArgAction, name))
177 | maskbit(offsetof(_ArgAction, valid));
178 }
179
180 static constexpr ObjHeader obj_header() {
181 return ObjHeader::ClassFixed(field_mask(), sizeof(_ArgAction));
182 }
183
184 DISALLOW_COPY_AND_ASSIGN(_ArgAction)
185};
186
187class SetToInt : public ::args::_ArgAction {
188 public:
189 SetToInt(BigStr* name);
190 virtual value_asdl::value_t* _Value(BigStr* arg, syntax_asdl::loc_t* location);
191
192 static constexpr uint32_t field_mask() {
193 return ::args::_ArgAction::field_mask();
194 }
195
196 static constexpr ObjHeader obj_header() {
197 return ObjHeader::ClassFixed(field_mask(), sizeof(SetToInt));
198 }
199
200 DISALLOW_COPY_AND_ASSIGN(SetToInt)
201};
202
203class SetToFloat : public ::args::_ArgAction {
204 public:
205 SetToFloat(BigStr* name);
206 virtual value_asdl::value_t* _Value(BigStr* arg, syntax_asdl::loc_t* location);
207
208 static constexpr uint32_t field_mask() {
209 return ::args::_ArgAction::field_mask();
210 }
211
212 static constexpr ObjHeader obj_header() {
213 return ObjHeader::ClassFixed(field_mask(), sizeof(SetToFloat));
214 }
215
216 DISALLOW_COPY_AND_ASSIGN(SetToFloat)
217};
218
219class SetToString : public ::args::_ArgAction {
220 public:
221 SetToString(BigStr* name, bool quit_parsing_flags, List<BigStr*>* valid = nullptr);
222 virtual value_asdl::value_t* _Value(BigStr* arg, syntax_asdl::loc_t* location);
223
224 static constexpr uint32_t field_mask() {
225 return ::args::_ArgAction::field_mask();
226 }
227
228 static constexpr ObjHeader obj_header() {
229 return ObjHeader::ClassFixed(field_mask(), sizeof(SetToString));
230 }
231
232 DISALLOW_COPY_AND_ASSIGN(SetToString)
233};
234
235class SetAttachedBool : public ::args::_Action {
236 public:
237 SetAttachedBool(BigStr* name);
238 virtual bool OnMatch(BigStr* attached_arg, args::Reader* arg_r, args::_Attributes* out);
239
240 BigStr* name{};
241
242 static constexpr uint32_t field_mask() {
243 return ::args::_Action::field_mask()
244 | maskbit(offsetof(SetAttachedBool, name));
245 }
246
247 static constexpr ObjHeader obj_header() {
248 return ObjHeader::ClassFixed(field_mask(), sizeof(SetAttachedBool));
249 }
250
251 DISALLOW_COPY_AND_ASSIGN(SetAttachedBool)
252};
253
254class SetToTrue : public ::args::_Action {
255 public:
256 SetToTrue(BigStr* name);
257 virtual bool OnMatch(BigStr* attached_arg, args::Reader* arg_r, args::_Attributes* out);
258
259 BigStr* name{};
260
261 static constexpr uint32_t field_mask() {
262 return ::args::_Action::field_mask()
263 | maskbit(offsetof(SetToTrue, name));
264 }
265
266 static constexpr ObjHeader obj_header() {
267 return ObjHeader::ClassFixed(field_mask(), sizeof(SetToTrue));
268 }
269
270 DISALLOW_COPY_AND_ASSIGN(SetToTrue)
271};
272
273class SetOption : public ::args::_Action {
274 public:
275 SetOption(BigStr* name);
276 virtual bool OnMatch(BigStr* attached_arg, args::Reader* arg_r, args::_Attributes* out);
277
278 BigStr* name{};
279
280 static constexpr uint32_t field_mask() {
281 return ::args::_Action::field_mask()
282 | maskbit(offsetof(SetOption, name));
283 }
284
285 static constexpr ObjHeader obj_header() {
286 return ObjHeader::ClassFixed(field_mask(), sizeof(SetOption));
287 }
288
289 DISALLOW_COPY_AND_ASSIGN(SetOption)
290};
291
292class SetNamedOption : public ::args::_Action {
293 public:
294 SetNamedOption(bool shopt = false);
295 void ArgName(BigStr* name);
296 virtual bool OnMatch(BigStr* attached_arg, args::Reader* arg_r, args::_Attributes* out);
297
298 List<BigStr*>* names{};
299 bool shopt{};
300
301 static constexpr uint32_t field_mask() {
302 return ::args::_Action::field_mask()
303 | maskbit(offsetof(SetNamedOption, names));
304 }
305
306 static constexpr ObjHeader obj_header() {
307 return ObjHeader::ClassFixed(field_mask(), sizeof(SetNamedOption));
308 }
309
310 DISALLOW_COPY_AND_ASSIGN(SetNamedOption)
311};
312
313class SetAction : public ::args::_Action {
314 public:
315 SetAction(BigStr* name);
316 virtual bool OnMatch(BigStr* attached_arg, args::Reader* arg_r, args::_Attributes* out);
317
318 BigStr* name{};
319
320 static constexpr uint32_t field_mask() {
321 return ::args::_Action::field_mask()
322 | maskbit(offsetof(SetAction, name));
323 }
324
325 static constexpr ObjHeader obj_header() {
326 return ObjHeader::ClassFixed(field_mask(), sizeof(SetAction));
327 }
328
329 DISALLOW_COPY_AND_ASSIGN(SetAction)
330};
331
332class SetNamedAction : public ::args::_Action {
333 public:
334 SetNamedAction();
335 void ArgName(BigStr* name);
336 virtual bool OnMatch(BigStr* attached_arg, args::Reader* arg_r, args::_Attributes* out);
337
338 List<BigStr*>* names{};
339
340 static constexpr uint32_t field_mask() {
341 return ::args::_Action::field_mask()
342 | maskbit(offsetof(SetNamedAction, names));
343 }
344
345 static constexpr ObjHeader obj_header() {
346 return ObjHeader::ClassFixed(field_mask(), sizeof(SetNamedAction));
347 }
348
349 DISALLOW_COPY_AND_ASSIGN(SetNamedAction)
350};
351
352args::_Attributes* Parse(flag_spec::_FlagSpec* spec, args::Reader* arg_r);
353args::_Attributes* ParseLikeEcho(flag_spec::_FlagSpec* spec, args::Reader* arg_r);
354args::_Attributes* ParseMore(flag_spec::_FlagSpecAndMore* spec, args::Reader* arg_r);
355
356} // declare namespace args
357
358#endif // FRONTEND_ARGS_MYCPP_H