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

162 lines, 135 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
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
57def 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
65class h8_tag_id_t(pybase.SimpleObj):
66 pass
67
68class 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
83def 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
91class attr_name_t(pybase.SimpleObj):
92 pass
93
94class attr_name(object):
95 Ok = attr_name_t(1)
96 Done = attr_name_t(2)
97 Invalid = attr_name_t(3)
98
99_attr_name_str = {
100 1: 'Ok',
101 2: 'Done',
102 3: 'Invalid',
103}
104
105def attr_name_str(val, dot=True):
106 # type: (attr_name_t, bool) -> str
107 v = _attr_name_str[val]
108 if dot:
109 return "attr_name.%s" % v
110 else:
111 return v
112
113class attr_value_id_t(pybase.SimpleObj):
114 pass
115
116class attr_value_id(object):
117 UnquotedVal = attr_value_id_t(1)
118 DoubleQuote = attr_value_id_t(2)
119 SingleQuote = attr_value_id_t(3)
120 Invalid = attr_value_id_t(4)
121
122_attr_value_id_str = {
123 1: 'UnquotedVal',
124 2: 'DoubleQuote',
125 3: 'SingleQuote',
126 4: 'Invalid',
127}
128
129def attr_value_id_str(val, dot=True):
130 # type: (attr_value_id_t, bool) -> str
131 v = _attr_value_id_str[val]
132 if dot:
133 return "attr_value_id.%s" % v
134 else:
135 return v
136
137class attr_value_t(pybase.SimpleObj):
138 pass
139
140class attr_value(object):
141 Missing = attr_value_t(1)
142 Empty = attr_value_t(2)
143 Unquoted = attr_value_t(3)
144 DoubleQuote = attr_value_t(4)
145 SingleQuote = attr_value_t(5)
146
147_attr_value_str = {
148 1: 'Missing',
149 2: 'Empty',
150 3: 'Unquoted',
151 4: 'DoubleQuote',
152 5: 'SingleQuote',
153}
154
155def attr_value_str(val, dot=True):
156 # type: (attr_value_t, bool) -> str
157 v = _attr_value_str[val]
158 if dot:
159 return "attr_value.%s" % v
160 else:
161 return v
162