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