| 1 | # Homogeneous tree for pretty-printing ASDL schemas! | 
| 2 | # To avoid bootstrapping problems, it can't be pretty-printed! | 
| 3 | # It's generated first with a special flag. | 
| 4 |  | 
| 5 | module hnode { | 
| 6 |  | 
| 7 | color = | 
| 8 | TypeName | 
| 9 | | StringConst | 
| 10 | | OtherConst | 
| 11 | | UserType  # e.g. for Id | 
| 12 | | External | 
| 13 |  | 
| 14 | Field = (str name, hnode val) | 
| 15 |  | 
| 16 | hnode = | 
| 17 | # Used to prevent infinite loops | 
| 18 | AlreadySeen(int heap_id) | 
| 19 | | Record(str node_type, List[Field] fields, | 
| 20 | bool abbrev, str left, str right, List[hnode] unnamed_fields) | 
| 21 | | Array(List[hnode] children) | 
| 22 | | Leaf(str s, color color) | 
| 23 | # Used for a few value_t variants like value.BuiltinFunc, that point back | 
| 24 | # to mycpp classes | 
| 25 | | External(any obj) | 
| 26 |  | 
| 27 | # NIL8 pretty-printing -- see doc/pretty-printing.md | 
| 28 |  | 
| 29 | # Idea for bit flags for CreateNull().  NOT part of pretty printing / hnode. | 
| 30 | # We just use a single param alloc_lists=True now | 
| 31 |  | 
| 32 | alloc_members = | 
| 33 | List | 
| 34 | | Dict | 
| 35 | | Struct  # ASDL product or sum types | 
| 36 | generate [bit_set] | 
| 37 | # Could also generate alloc_members_b::{None,All} | 
| 38 |  | 
| 39 | # Related: | 
| 40 | # - it would be nice to have ASDL value types (pass by value), | 
| 41 | #   e.g. val[Token] or inline[Token] | 
| 42 | # - we should be able to pack i8, i16, u8, u16, or even bitfields | 
| 43 | #   Point = (int x, int y) | 
| 44 | #   Point = (int[signed, 16] x, int[unsigned, 8] y) | 
| 45 | # It's not i16 and u8 because we recognize C++ implicit int conversions. | 
| 46 | # This is storage only. | 
| 47 | } |