1 | from asdl import pybase
|
2 | from mycpp import mops
|
3 | from typing import Optional, List, Tuple, Dict, Any, cast, TYPE_CHECKING
|
4 |
|
5 | from asdl import runtime # For runtime.NO_SPID
|
6 | from asdl.runtime import NewRecord, NewLeaf, TraversalState
|
7 | from _devbuild.gen.hnode_asdl import color_e, hnode, hnode_e, hnode_t, Field
|
8 |
|
9 | class h8_id_t(pybase.SimpleObj):
|
10 | pass
|
11 |
|
12 | class h8_id(object):
|
13 | Decl = h8_id_t(1)
|
14 | Comment = h8_id_t(2)
|
15 | CommentBegin = h8_id_t(3)
|
16 | Processing = h8_id_t(4)
|
17 | ProcessingBegin = h8_id_t(5)
|
18 | CData = h8_id_t(6)
|
19 | CDataBegin = h8_id_t(7)
|
20 | StartTag = h8_id_t(8)
|
21 | StartEndTag = h8_id_t(9)
|
22 | EndTag = h8_id_t(10)
|
23 | DecChar = h8_id_t(11)
|
24 | HexChar = h8_id_t(12)
|
25 | CharEntity = h8_id_t(13)
|
26 | RawData = h8_id_t(14)
|
27 | HtmlCData = h8_id_t(15)
|
28 | BadAmpersand = h8_id_t(16)
|
29 | BadGreaterThan = h8_id_t(17)
|
30 | BadLessThan = h8_id_t(18)
|
31 | Invalid = h8_id_t(19)
|
32 | EndOfStream = h8_id_t(20)
|
33 |
|
34 | _h8_id_str = {
|
35 | 1: 'Decl',
|
36 | 2: 'Comment',
|
37 | 3: 'CommentBegin',
|
38 | 4: 'Processing',
|
39 | 5: 'ProcessingBegin',
|
40 | 6: 'CData',
|
41 | 7: 'CDataBegin',
|
42 | 8: 'StartTag',
|
43 | 9: 'StartEndTag',
|
44 | 10: 'EndTag',
|
45 | 11: 'DecChar',
|
46 | 12: 'HexChar',
|
47 | 13: 'CharEntity',
|
48 | 14: 'RawData',
|
49 | 15: 'HtmlCData',
|
50 | 16: 'BadAmpersand',
|
51 | 17: 'BadGreaterThan',
|
52 | 18: 'BadLessThan',
|
53 | 19: 'Invalid',
|
54 | 20: 'EndOfStream',
|
55 | }
|
56 |
|
57 | def h8_id_str(val, dot=True):
|
58 | # type: (h8_id_t, bool) -> str
|
59 | v = _h8_id_str[val]
|
60 | if dot:
|
61 | return "h8_id.%s" % v
|
62 | else:
|
63 | return v
|
64 |
|
65 | class h8_tag_id_t(pybase.SimpleObj):
|
66 | pass
|
67 |
|
68 | class h8_tag_id(object):
|
69 | TagName = h8_tag_id_t(1)
|
70 | AttrName = h8_tag_id_t(2)
|
71 | UnquotedValue = h8_tag_id_t(3)
|
72 | QuotedValue = h8_tag_id_t(4)
|
73 | MissingValue = h8_tag_id_t(5)
|
74 |
|
75 | _h8_tag_id_str = {
|
76 | 1: 'TagName',
|
77 | 2: 'AttrName',
|
78 | 3: 'UnquotedValue',
|
79 | 4: 'QuotedValue',
|
80 | 5: 'MissingValue',
|
81 | }
|
82 |
|
83 | def h8_tag_id_str(val, dot=True):
|
84 | # type: (h8_tag_id_t, bool) -> str
|
85 | v = _h8_tag_id_str[val]
|
86 | if dot:
|
87 | return "h8_tag_id.%s" % v
|
88 | else:
|
89 | return v
|
90 |
|
91 | class attr_name_e(object):
|
92 | Ok = 1
|
93 | Eof = 2
|
94 | Error = 3
|
95 |
|
96 | _attr_name_str = {
|
97 | 1: 'Ok',
|
98 | 2: 'Eof',
|
99 | 3: 'Error',
|
100 | }
|
101 |
|
102 | def attr_name_str(tag, dot=True):
|
103 | # type: (int, bool) -> str
|
104 | v = _attr_name_str[tag]
|
105 | if dot:
|
106 | return "attr_name.%s" % v
|
107 | else:
|
108 | return v
|
109 |
|
110 | class attr_name_t(pybase.CompoundObj):
|
111 | def tag(self):
|
112 | # type: () -> int
|
113 | return self._type_tag
|
114 |
|
115 | class attr_name__Ok(attr_name_t):
|
116 | _type_tag = 1
|
117 | __slots__ = ()
|
118 |
|
119 | def __init__(self, ):
|
120 | # type: () -> None
|
121 | pass
|
122 |
|
123 | def PrettyTree(self, do_abbrev, trav=None):
|
124 | # type: (bool, Optional[TraversalState]) -> hnode_t
|
125 | trav = trav or TraversalState()
|
126 | heap_id = id(self)
|
127 | if heap_id in trav.seen:
|
128 | return hnode.AlreadySeen(heap_id)
|
129 | trav.seen[heap_id] = True
|
130 |
|
131 | out_node = NewRecord('attr_name.Ok')
|
132 | L = out_node.fields
|
133 |
|
134 | return out_node
|
135 |
|
136 | class attr_name__Eof(attr_name_t):
|
137 | _type_tag = 2
|
138 | __slots__ = ()
|
139 |
|
140 | def __init__(self, ):
|
141 | # type: () -> None
|
142 | pass
|
143 |
|
144 | def PrettyTree(self, do_abbrev, trav=None):
|
145 | # type: (bool, Optional[TraversalState]) -> hnode_t
|
146 | trav = trav or TraversalState()
|
147 | heap_id = id(self)
|
148 | if heap_id in trav.seen:
|
149 | return hnode.AlreadySeen(heap_id)
|
150 | trav.seen[heap_id] = True
|
151 |
|
152 | out_node = NewRecord('attr_name.Eof')
|
153 | L = out_node.fields
|
154 |
|
155 | return out_node
|
156 |
|
157 | class attr_name(object):
|
158 | Ok = attr_name__Ok()
|
159 |
|
160 | Eof = attr_name__Eof()
|
161 |
|
162 | class Error(attr_name_t):
|
163 | _type_tag = 3
|
164 | __slots__ = ('pos',)
|
165 |
|
166 | def __init__(self, pos):
|
167 | # type: (int) -> None
|
168 | self.pos = pos
|
169 |
|
170 | @staticmethod
|
171 | def CreateNull(alloc_lists=False):
|
172 | # type: () -> attr_name.Error
|
173 | return attr_name.Error(-1)
|
174 |
|
175 | def PrettyTree(self, do_abbrev, trav=None):
|
176 | # type: (bool, Optional[TraversalState]) -> hnode_t
|
177 | trav = trav or TraversalState()
|
178 | heap_id = id(self)
|
179 | if heap_id in trav.seen:
|
180 | return hnode.AlreadySeen(heap_id)
|
181 | trav.seen[heap_id] = True
|
182 |
|
183 | out_node = NewRecord('attr_name.Error')
|
184 | L = out_node.fields
|
185 |
|
186 | x0 = hnode.Leaf(str(self.pos), color_e.OtherConst)
|
187 | L.append(Field('pos', x0))
|
188 |
|
189 | return out_node
|
190 |
|
191 | pass
|
192 |
|
193 | class attr_value_t(pybase.SimpleObj):
|
194 | pass
|
195 |
|
196 | class attr_value(object):
|
197 | Missing = attr_value_t(1)
|
198 | Empty = attr_value_t(2)
|
199 | Unquoted = attr_value_t(3)
|
200 | Quoted = attr_value_t(4)
|
201 |
|
202 | _attr_value_str = {
|
203 | 1: 'Missing',
|
204 | 2: 'Empty',
|
205 | 3: 'Unquoted',
|
206 | 4: 'Quoted',
|
207 | }
|
208 |
|
209 | def attr_value_str(val, dot=True):
|
210 | # type: (attr_value_t, bool) -> str
|
211 | v = _attr_value_str[val]
|
212 | if dot:
|
213 | return "attr_value.%s" % v
|
214 | else:
|
215 | return v
|
216 |
|