OILS / _devbuild / gen / htm8_asdl.py View on Github | oils.pub

166 lines, 139 significant
1from asdl import pybase
2from mycpp import mops
3from typing import Optional, List, Tuple, Dict, Any, cast, TYPE_CHECKING
4
5from asdl import runtime # For runtime.NO_SPID
6from asdl.runtime import NewRecord, NewLeaf, TraversalState
7from _devbuild.gen.hnode_asdl import color_e, hnode, hnode_e, hnode_t, Field
8
9class h8_id_t(pybase.SimpleObj):
10 pass
11
12class 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 DoubleQuote = h8_id_t(21)
34 SingleQuote = h8_id_t(22)
35
36_h8_id_str = {
37 1: 'Decl',
38 2: 'Comment',
39 3: 'CommentBegin',
40 4: 'Processing',
41 5: 'ProcessingBegin',
42 6: 'CData',
43 7: 'CDataBegin',
44 8: 'StartTag',
45 9: 'StartEndTag',
46 10: 'EndTag',
47 11: 'DecChar',
48 12: 'HexChar',
49 13: 'CharEntity',
50 14: 'RawData',
51 15: 'HtmlCData',
52 16: 'BadAmpersand',
53 17: 'BadGreaterThan',
54 18: 'BadLessThan',
55 19: 'Invalid',
56 20: 'EndOfStream',
57 21: 'DoubleQuote',
58 22: 'SingleQuote',
59}
60
61def h8_id_str(val, dot=True):
62 # type: (h8_id_t, bool) -> str
63 v = _h8_id_str[val]
64 if dot:
65 return "h8_id.%s" % v
66 else:
67 return v
68
69class attr_name_t(pybase.SimpleObj):
70 pass
71
72class attr_name(object):
73 Ok = attr_name_t(1)
74 Done = attr_name_t(2)
75 Invalid = attr_name_t(3)
76
77_attr_name_str = {
78 1: 'Ok',
79 2: 'Done',
80 3: 'Invalid',
81}
82
83def attr_name_str(val, dot=True):
84 # type: (attr_name_t, bool) -> str
85 v = _attr_name_str[val]
86 if dot:
87 return "attr_name.%s" % v
88 else:
89 return v
90
91class h8_val_id_t(pybase.SimpleObj):
92 pass
93
94class h8_val_id(object):
95 UnquotedVal = h8_val_id_t(1)
96 DoubleQuote = h8_val_id_t(2)
97 SingleQuote = h8_val_id_t(3)
98 NoMatch = h8_val_id_t(4)
99
100_h8_val_id_str = {
101 1: 'UnquotedVal',
102 2: 'DoubleQuote',
103 3: 'SingleQuote',
104 4: 'NoMatch',
105}
106
107def h8_val_id_str(val, dot=True):
108 # type: (h8_val_id_t, bool) -> str
109 v = _h8_val_id_str[val]
110 if dot:
111 return "h8_val_id.%s" % v
112 else:
113 return v
114
115class attr_value_t(pybase.SimpleObj):
116 pass
117
118class attr_value_e(object):
119 Missing = attr_value_t(1)
120 Empty = attr_value_t(2)
121 Unquoted = attr_value_t(3)
122 DoubleQuoted = attr_value_t(4)
123 SingleQuoted = attr_value_t(5)
124
125_attr_value_str = {
126 1: 'Missing',
127 2: 'Empty',
128 3: 'Unquoted',
129 4: 'DoubleQuoted',
130 5: 'SingleQuoted',
131}
132
133def attr_value_str(val, dot=True):
134 # type: (attr_value_t, bool) -> str
135 v = _attr_value_str[val]
136 if dot:
137 return "attr_value.%s" % v
138 else:
139 return v
140
141class h8_tag_id_t(pybase.SimpleObj):
142 pass
143
144class h8_tag_id(object):
145 TagName = h8_tag_id_t(1)
146 AttrName = h8_tag_id_t(2)
147 UnquotedValue = h8_tag_id_t(3)
148 QuotedValue = h8_tag_id_t(4)
149 MissingValue = h8_tag_id_t(5)
150
151_h8_tag_id_str = {
152 1: 'TagName',
153 2: 'AttrName',
154 3: 'UnquotedValue',
155 4: 'QuotedValue',
156 5: 'MissingValue',
157}
158
159def h8_tag_id_str(val, dot=True):
160 # type: (h8_tag_id_t, bool) -> str
161 v = _h8_tag_id_str[val]
162 if dot:
163 return "h8_tag_id.%s" % v
164 else:
165 return v
166