OILS / demo / shedskin / demo_asdl.py View on Github | oilshell.org

255 lines, 173 significant
1import const # For const.NO_INTEGER
2import runtime
3#from pylib import unpickle
4
5#from core import util
6
7#f = util.GetResourceLoader().open('_devbuild/demo_asdl.pickle')
8#TYPE_LOOKUP = unpickle.load_v2_subset(f)
9#f.close()
10#TYPE_LOOKUP = {}
11
12class op_id_e(runtime.SimpleObj):
13 #ASDL_TYPE = TYPE_LOOKUP['op_id']
14 pass
15
16op_id_e.Plus = op_id_e(1, 'Plus')
17op_id_e.Minus = op_id_e(2, 'Minus')
18op_id_e.Star = op_id_e(3, 'Star')
19
20class cflow_e(object):
21 Break = 1
22 Continue = 2
23 Return = 3
24
25class cflow(runtime.CompoundObj):
26 #ASDL_TYPE = TYPE_LOOKUP['cflow']
27 pass
28
29class cflow__Break(cflow):
30 #ASDL_TYPE = TYPE_LOOKUP['cflow__Break']
31 tag = 1
32
33class cflow__Continue(cflow):
34 #ASDL_TYPE = TYPE_LOOKUP['cflow__Continue']
35 tag = 2
36
37class cflow__Return(cflow):
38 tag = 3
39 #ASDL_TYPE = TYPE_LOOKUP['cflow__Return']
40 __slots__ = ('status', 'spids')
41
42 def __init__(self, status=None, spids=None):
43 self.status = status
44 self.spids = spids or []
45
46cflow.Break = cflow__Break
47cflow.Continue = cflow__Continue
48cflow.Return = cflow__Return
49
50class source_location(runtime.CompoundObj):
51 #ASDL_TYPE = TYPE_LOOKUP['source_location']
52 __slots__ = ('path', 'line', 'col', 'length', 'spids')
53
54 def __init__(self, path=None, line=None, col=None, length=None, spids=None):
55 self.path = path
56 self.line = line
57 self.col = col
58 self.length = length
59 self.spids = spids or []
60
61class token(runtime.CompoundObj):
62 #ASDL_TYPE = TYPE_LOOKUP['token']
63 __slots__ = ('id', 'value', 'span_id', 'spids')
64
65 def __init__(self, id=None, value=None, span_id=None, spids=None):
66 self.id = id
67 self.value = value
68 self.span_id = span_id or const.NO_INTEGER
69 self.spids = spids or []
70
71class assign(runtime.CompoundObj):
72 #ASDL_TYPE = TYPE_LOOKUP['assign']
73 __slots__ = ('name', 'flags', 'spids')
74
75 def __init__(self, name=None, flags=None, spids=None):
76 self.name = name
77 self.flags = flags or []
78 self.spids = spids or []
79
80class arith_expr_e(object):
81 Const = 1
82 ArithVar = 2
83 ArithUnary = 3
84 ArithBinary = 4
85 FuncCall = 5
86 ForwardRef = 6
87 Index = 7
88 Slice = 8
89
90class arith_expr(runtime.CompoundObj):
91 #ASDL_TYPE = TYPE_LOOKUP['arith_expr']
92 pass
93
94class arith_expr__Const(arith_expr):
95 tag = 1
96 #ASDL_TYPE = TYPE_LOOKUP['arith_expr__Const']
97 __slots__ = ('i', 'spids')
98
99 def __init__(self, i=None, spids=None):
100 self.i = i
101 self.spids = spids or []
102
103class arith_expr__ArithVar(arith_expr):
104 tag = 2
105 #ASDL_TYPE = TYPE_LOOKUP['arith_expr__ArithVar']
106 __slots__ = ('name', 'spids')
107
108 def __init__(self, name=None, spids=None):
109 self.name = name
110 self.spids = spids or []
111
112class arith_expr__ArithUnary(arith_expr):
113 tag = 3
114 #ASDL_TYPE = TYPE_LOOKUP['arith_expr__ArithUnary']
115 __slots__ = ('op_id', 'a', 'spids')
116
117 def __init__(self, op_id=None, a=None, spids=None):
118 self.op_id = op_id
119 self.a = a
120 self.spids = spids or []
121
122class arith_expr__ArithBinary(arith_expr):
123 tag = 4
124 #ASDL_TYPE = TYPE_LOOKUP['arith_expr__ArithBinary']
125 __slots__ = ('op_id', 'left', 'right', 'spids')
126
127 def __init__(self, op_id=None, left=None, right=None, spids=None):
128 self.op_id = op_id
129 self.left = left
130 self.right = right
131 self.spids = spids or []
132
133class arith_expr__FuncCall(arith_expr):
134 tag = 5
135 #ASDL_TYPE = TYPE_LOOKUP['arith_expr__FuncCall']
136 __slots__ = ('name', 'args', 'spids')
137
138 def __init__(self, name=None, args=None, spids=None):
139 self.name = name
140 self.args = args or []
141 self.spids = spids or []
142
143class arith_expr__ForwardRef(arith_expr):
144 tag = 6
145 #ASDL_TYPE = TYPE_LOOKUP['arith_expr__ForwardRef']
146 __slots__ = ('b', 'spids')
147
148 def __init__(self, b=None, spids=None):
149 self.b = b
150 self.spids = spids or []
151
152class arith_expr__Index(arith_expr):
153 tag = 7
154 #ASDL_TYPE = TYPE_LOOKUP['arith_expr__Index']
155 __slots__ = ('a', 'index', 'spids')
156
157 def __init__(self, a=None, index=None, spids=None):
158 self.a = a
159 self.index = index
160 self.spids = spids or []
161
162class arith_expr__Slice(arith_expr):
163 tag = 8
164 #ASDL_TYPE = TYPE_LOOKUP['arith_expr__Slice']
165 __slots__ = ('a', 'begin', 'end', 'stride', 'spids')
166
167 def __init__(self, a=None, begin=None, end=None, stride=None, spids=None):
168 self.a = a
169 self.begin = begin or None
170 self.end = end or None
171 self.stride = stride or None
172 self.spids = spids or []
173
174arith_expr.Const = arith_expr__Const
175arith_expr.ArithVar = arith_expr__ArithVar
176arith_expr.ArithUnary = arith_expr__ArithUnary
177arith_expr.ArithBinary = arith_expr__ArithBinary
178arith_expr.FuncCall = arith_expr__FuncCall
179arith_expr.ForwardRef = arith_expr__ForwardRef
180arith_expr.Index = arith_expr__Index
181arith_expr.Slice = arith_expr__Slice
182
183class word(runtime.CompoundObj):
184 #ASDL_TYPE = TYPE_LOOKUP['word']
185 __slots__ = ('value', 'spids')
186
187 def __init__(self, value=None, spids=None):
188 self.value = value
189 self.spids = spids or []
190
191class bool_expr_e(object):
192 BoolBinary = 1
193 BoolUnary = 2
194 LogicalNot = 3
195 LogicalAnd = 4
196 LogicalOr = 5
197
198class bool_expr(runtime.CompoundObj):
199 #ASDL_TYPE = TYPE_LOOKUP['bool_expr']
200 pass
201
202class bool_expr__BoolBinary(bool_expr):
203 tag = 1
204 #ASDL_TYPE = TYPE_LOOKUP['bool_expr__BoolBinary']
205 __slots__ = ('left', 'right', 'spids')
206
207 def __init__(self, left=None, right=None, spids=None):
208 self.left = left
209 self.right = right
210 self.spids = spids or []
211
212class bool_expr__BoolUnary(bool_expr):
213 tag = 2
214 #ASDL_TYPE = TYPE_LOOKUP['bool_expr__BoolUnary']
215 __slots__ = ('child', 'spids')
216
217 def __init__(self, child=None, spids=None):
218 self.child = child
219 self.spids = spids or []
220
221class bool_expr__LogicalNot(bool_expr):
222 tag = 3
223 #ASDL_TYPE = TYPE_LOOKUP['bool_expr__LogicalNot']
224 __slots__ = ('b', 'spids')
225
226 def __init__(self, b=None, spids=None):
227 self.b = b
228 self.spids = spids or []
229
230class bool_expr__LogicalAnd(bool_expr):
231 tag = 4
232 #ASDL_TYPE = TYPE_LOOKUP['bool_expr__LogicalAnd']
233 __slots__ = ('left', 'right', 'spids')
234
235 def __init__(self, left=None, right=None, spids=None):
236 self.left = left
237 self.right = right
238 self.spids = spids or []
239
240class bool_expr__LogicalOr(bool_expr):
241 tag = 5
242 #ASDL_TYPE = TYPE_LOOKUP['bool_expr__LogicalOr']
243 __slots__ = ('left', 'right', 'spids')
244
245 def __init__(self, left=None, right=None, spids=None):
246 self.left = left
247 self.right = right
248 self.spids = spids or []
249
250bool_expr.BoolBinary = bool_expr__BoolBinary
251bool_expr.BoolUnary = bool_expr__BoolUnary
252bool_expr.LogicalNot = bool_expr__LogicalNot
253bool_expr.LogicalAnd = bool_expr__LogicalAnd
254bool_expr.LogicalOr = bool_expr__LogicalOr
255