| 1 | // _gen/data_lang/pretty.asdl.h is generated by asdl_main.py
|
| 2 |
|
| 3 | #ifndef PRETTY_ASDL
|
| 4 | #define PRETTY_ASDL
|
| 5 |
|
| 6 | #include <cstdint>
|
| 7 |
|
| 8 | #include "mycpp/runtime.h"
|
| 9 | #include "_gen/asdl/hnode.asdl.h"
|
| 10 | using hnode_asdl::hnode_t;
|
| 11 |
|
| 12 | namespace pretty_asdl {
|
| 13 |
|
| 14 | // use struct instead of namespace so 'using' works consistently
|
| 15 | #define ASDL_NAMES struct
|
| 16 |
|
| 17 | class doc_t;
|
| 18 |
|
| 19 | ASDL_NAMES doc_e {
|
| 20 | enum no_name {
|
| 21 | Newline = 1,
|
| 22 | Text = 2,
|
| 23 | Indent = 3,
|
| 24 | Cat = 4,
|
| 25 | };
|
| 26 | };
|
| 27 |
|
| 28 | BigStr* doc_str(int tag, bool dot = true);
|
| 29 |
|
| 30 | class doc_t {
|
| 31 | protected:
|
| 32 | doc_t() {
|
| 33 | }
|
| 34 | public:
|
| 35 | int tag() const {
|
| 36 | return ObjHeader::FromObject(this)->type_tag;
|
| 37 | }
|
| 38 | hnode_t* PrettyTree(Dict<int, bool>* seen = nullptr);
|
| 39 | DISALLOW_COPY_AND_ASSIGN(doc_t)
|
| 40 | };
|
| 41 |
|
| 42 | class doc__Newline : public doc_t {
|
| 43 | public:
|
| 44 | doc__Newline() {}
|
| 45 |
|
| 46 | hnode_t* PrettyTree(Dict<int, bool>* seen = nullptr);
|
| 47 |
|
| 48 | static constexpr ObjHeader obj_header() {
|
| 49 | return ObjHeader::AsdlClass(static_cast<uint16_t>(doc_e::Newline), 0);
|
| 50 | }
|
| 51 |
|
| 52 |
|
| 53 | DISALLOW_COPY_AND_ASSIGN(doc__Newline)
|
| 54 | };
|
| 55 |
|
| 56 | class doc__Text : public doc_t {
|
| 57 | public:
|
| 58 | doc__Text(BigStr* s, int width)
|
| 59 | : s(s),
|
| 60 | width(width) {
|
| 61 | }
|
| 62 |
|
| 63 | static doc__Text* CreateNull(bool alloc_lists = false) {
|
| 64 | return Alloc<doc__Text>(kEmptyString, -1);
|
| 65 | }
|
| 66 |
|
| 67 | hnode_t* PrettyTree(Dict<int, bool>* seen = nullptr);
|
| 68 |
|
| 69 | static constexpr ObjHeader obj_header() {
|
| 70 | return ObjHeader::AsdlClass(static_cast<uint16_t>(doc_e::Text), 1);
|
| 71 | }
|
| 72 |
|
| 73 | BigStr* s;
|
| 74 | int width;
|
| 75 |
|
| 76 | DISALLOW_COPY_AND_ASSIGN(doc__Text)
|
| 77 | };
|
| 78 |
|
| 79 | class doc__Indent : public doc_t {
|
| 80 | public:
|
| 81 | doc__Indent(int ind, List<doc_t*>* children)
|
| 82 | : children(children),
|
| 83 | ind(ind) {
|
| 84 | }
|
| 85 |
|
| 86 | static doc__Indent* CreateNull(bool alloc_lists = false) {
|
| 87 | return Alloc<doc__Indent>(-1, alloc_lists ? Alloc<List<doc_t*>>() :
|
| 88 | nullptr);
|
| 89 | }
|
| 90 |
|
| 91 | hnode_t* PrettyTree(Dict<int, bool>* seen = nullptr);
|
| 92 |
|
| 93 | static constexpr ObjHeader obj_header() {
|
| 94 | return ObjHeader::AsdlClass(static_cast<uint16_t>(doc_e::Indent), 1);
|
| 95 | }
|
| 96 |
|
| 97 | List<doc_t*>* children;
|
| 98 | int ind;
|
| 99 |
|
| 100 | DISALLOW_COPY_AND_ASSIGN(doc__Indent)
|
| 101 | };
|
| 102 |
|
| 103 | class doc__Cat : public doc_t {
|
| 104 | public:
|
| 105 | doc__Cat(doc_t* left, doc_t* right)
|
| 106 | : left(left),
|
| 107 | right(right) {
|
| 108 | }
|
| 109 |
|
| 110 | static doc__Cat* CreateNull(bool alloc_lists = false) {
|
| 111 | return Alloc<doc__Cat>(nullptr, nullptr);
|
| 112 | }
|
| 113 |
|
| 114 | hnode_t* PrettyTree(Dict<int, bool>* seen = nullptr);
|
| 115 |
|
| 116 | static constexpr ObjHeader obj_header() {
|
| 117 | return ObjHeader::AsdlClass(static_cast<uint16_t>(doc_e::Cat), 2);
|
| 118 | }
|
| 119 |
|
| 120 | doc_t* left;
|
| 121 | doc_t* right;
|
| 122 |
|
| 123 | DISALLOW_COPY_AND_ASSIGN(doc__Cat)
|
| 124 | };
|
| 125 |
|
| 126 | extern GcGlobal<doc__Newline> gdoc__Newline;
|
| 127 | ASDL_NAMES doc {
|
| 128 | static doc__Newline* Newline;
|
| 129 | typedef doc__Text Text;
|
| 130 | typedef doc__Indent Indent;
|
| 131 | typedef doc__Cat Cat;
|
| 132 | };
|
| 133 |
|
| 134 |
|
| 135 | } // namespace pretty_asdl
|
| 136 |
|
| 137 | #endif // PRETTY_ASDL
|