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 | | Subtype(str node_type, List[hnode] children)
|
23 | | Leaf(str s, color color)
|
24 | # Used for a few value_t variants like value.BuiltinFunc, that point back
|
25 | # to mycpp classes
|
26 | | External(any obj)
|
27 |
|
28 | # NIL8 pretty-printing -- see doc/pretty-printing.md
|
29 |
|
30 | # Idea for bit flags for CreateNull(). NOT part of pretty printing / hnode.
|
31 | # We just use a single param alloc_lists=True now
|
32 |
|
33 | alloc_members =
|
34 | List
|
35 | | Dict
|
36 | | Struct # ASDL product or sum types
|
37 | generate [bit_set]
|
38 | # Could also generate alloc_members_b::{None,All}
|
39 |
|
40 | # Related:
|
41 | # - it would be nice to have ASDL value types (pass by value),
|
42 | # e.g. val[Token] or inline[Token]
|
43 | # - we should be able to pack i8, i16, u8, u16, or even bitfields
|
44 | # Point = (int x, int y)
|
45 | # Point = (int[signed, 16] x, int[unsigned, 8] y)
|
46 | # It's not i16 and u8 because we recognize C++ implicit int conversions.
|
47 | # This is storage only.
|
48 | }
|