vtlengine 1.4.0rc2__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- vtlengine/API/_InternalApi.py +791 -0
- vtlengine/API/__init__.py +612 -0
- vtlengine/API/data/schema/external_routines_schema.json +34 -0
- vtlengine/API/data/schema/json_schema_2.1.json +116 -0
- vtlengine/API/data/schema/value_domain_schema.json +97 -0
- vtlengine/AST/ASTComment.py +57 -0
- vtlengine/AST/ASTConstructor.py +598 -0
- vtlengine/AST/ASTConstructorModules/Expr.py +1928 -0
- vtlengine/AST/ASTConstructorModules/ExprComponents.py +995 -0
- vtlengine/AST/ASTConstructorModules/Terminals.py +790 -0
- vtlengine/AST/ASTConstructorModules/__init__.py +50 -0
- vtlengine/AST/ASTDataExchange.py +10 -0
- vtlengine/AST/ASTEncoders.py +32 -0
- vtlengine/AST/ASTString.py +675 -0
- vtlengine/AST/ASTTemplate.py +558 -0
- vtlengine/AST/ASTVisitor.py +25 -0
- vtlengine/AST/DAG/__init__.py +479 -0
- vtlengine/AST/DAG/_words.py +10 -0
- vtlengine/AST/Grammar/Vtl.g4 +705 -0
- vtlengine/AST/Grammar/VtlTokens.g4 +409 -0
- vtlengine/AST/Grammar/__init__.py +0 -0
- vtlengine/AST/Grammar/lexer.py +2139 -0
- vtlengine/AST/Grammar/parser.py +16597 -0
- vtlengine/AST/Grammar/tokens.py +169 -0
- vtlengine/AST/VtlVisitor.py +824 -0
- vtlengine/AST/__init__.py +674 -0
- vtlengine/DataTypes/TimeHandling.py +562 -0
- vtlengine/DataTypes/__init__.py +863 -0
- vtlengine/DataTypes/_time_checking.py +135 -0
- vtlengine/Exceptions/__exception_file_generator.py +96 -0
- vtlengine/Exceptions/__init__.py +159 -0
- vtlengine/Exceptions/messages.py +1004 -0
- vtlengine/Interpreter/__init__.py +2048 -0
- vtlengine/Model/__init__.py +501 -0
- vtlengine/Operators/Aggregation.py +357 -0
- vtlengine/Operators/Analytic.py +455 -0
- vtlengine/Operators/Assignment.py +23 -0
- vtlengine/Operators/Boolean.py +106 -0
- vtlengine/Operators/CastOperator.py +451 -0
- vtlengine/Operators/Clause.py +366 -0
- vtlengine/Operators/Comparison.py +488 -0
- vtlengine/Operators/Conditional.py +495 -0
- vtlengine/Operators/General.py +191 -0
- vtlengine/Operators/HROperators.py +254 -0
- vtlengine/Operators/Join.py +447 -0
- vtlengine/Operators/Numeric.py +422 -0
- vtlengine/Operators/RoleSetter.py +77 -0
- vtlengine/Operators/Set.py +176 -0
- vtlengine/Operators/String.py +578 -0
- vtlengine/Operators/Time.py +1144 -0
- vtlengine/Operators/Validation.py +275 -0
- vtlengine/Operators/__init__.py +900 -0
- vtlengine/Utils/__Virtual_Assets.py +34 -0
- vtlengine/Utils/__init__.py +479 -0
- vtlengine/__extras_check.py +17 -0
- vtlengine/__init__.py +27 -0
- vtlengine/files/__init__.py +0 -0
- vtlengine/files/output/__init__.py +35 -0
- vtlengine/files/output/_time_period_representation.py +55 -0
- vtlengine/files/parser/__init__.py +240 -0
- vtlengine/files/parser/_rfc_dialect.py +22 -0
- vtlengine/py.typed +0 -0
- vtlengine-1.4.0rc2.dist-info/METADATA +89 -0
- vtlengine-1.4.0rc2.dist-info/RECORD +66 -0
- vtlengine-1.4.0rc2.dist-info/WHEEL +4 -0
- vtlengine-1.4.0rc2.dist-info/licenses/LICENSE.md +661 -0
|
@@ -0,0 +1,558 @@
|
|
|
1
|
+
"""
|
|
2
|
+
AST.ASTTemplate.py
|
|
3
|
+
==================
|
|
4
|
+
|
|
5
|
+
Description
|
|
6
|
+
-----------
|
|
7
|
+
Template to start a new visitor for the AST.
|
|
8
|
+
"""
|
|
9
|
+
|
|
10
|
+
from typing import Any
|
|
11
|
+
|
|
12
|
+
import vtlengine.AST as AST
|
|
13
|
+
from vtlengine.AST.ASTVisitor import NodeVisitor
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
class ASTTemplate(NodeVisitor):
|
|
17
|
+
"""
|
|
18
|
+
Template to start a new visitor for the AST.
|
|
19
|
+
"""
|
|
20
|
+
|
|
21
|
+
def __init__(self):
|
|
22
|
+
pass
|
|
23
|
+
|
|
24
|
+
"""______________________________________________________________________________________
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
Start of visiting nodes.
|
|
28
|
+
|
|
29
|
+
_______________________________________________________________________________________"""
|
|
30
|
+
|
|
31
|
+
def visit_Start(self, node: AST.Start) -> Any:
|
|
32
|
+
"""
|
|
33
|
+
Start: (children)
|
|
34
|
+
|
|
35
|
+
Basic usage:
|
|
36
|
+
|
|
37
|
+
for child in node.children:
|
|
38
|
+
self.visit(child)
|
|
39
|
+
"""
|
|
40
|
+
for child in node.children:
|
|
41
|
+
self.visit(child)
|
|
42
|
+
|
|
43
|
+
def visit_Assignment(self, node: AST.Assignment) -> Any:
|
|
44
|
+
"""
|
|
45
|
+
Assignment: (left, op, right)
|
|
46
|
+
|
|
47
|
+
op: :=
|
|
48
|
+
|
|
49
|
+
Basic usage:
|
|
50
|
+
|
|
51
|
+
self.visit(node.left)
|
|
52
|
+
self.visit(node.right)
|
|
53
|
+
"""
|
|
54
|
+
self.visit(node.left)
|
|
55
|
+
self.visit(node.right)
|
|
56
|
+
|
|
57
|
+
def visit_PersistentAssignment(self, node: AST.PersistentAssignment) -> Any:
|
|
58
|
+
"""
|
|
59
|
+
PersistentAssignment: (left, op, right)
|
|
60
|
+
|
|
61
|
+
op: <-
|
|
62
|
+
|
|
63
|
+
Basic usage:
|
|
64
|
+
|
|
65
|
+
self.visit(node.left)
|
|
66
|
+
self.visit(node.right)
|
|
67
|
+
"""
|
|
68
|
+
self.visit(node.left)
|
|
69
|
+
self.visit(node.right)
|
|
70
|
+
|
|
71
|
+
def visit_VarID(self, node: AST.VarID) -> Any:
|
|
72
|
+
"""
|
|
73
|
+
VarID: (token, value)
|
|
74
|
+
|
|
75
|
+
Basic usage:
|
|
76
|
+
|
|
77
|
+
return node.value
|
|
78
|
+
"""
|
|
79
|
+
return node.value
|
|
80
|
+
|
|
81
|
+
def visit_UnaryOp(self, node: AST.UnaryOp) -> Any:
|
|
82
|
+
"""
|
|
83
|
+
UnaryOp: (op, operand)
|
|
84
|
+
|
|
85
|
+
op:
|
|
86
|
+
|
|
87
|
+
Basic usage:
|
|
88
|
+
|
|
89
|
+
self.visit(node.operand)
|
|
90
|
+
"""
|
|
91
|
+
self.visit(node.operand)
|
|
92
|
+
|
|
93
|
+
def visit_BinOp(self, node: AST.BinOp) -> None:
|
|
94
|
+
"""
|
|
95
|
+
BinOp: (left, op, right)
|
|
96
|
+
|
|
97
|
+
op:
|
|
98
|
+
|
|
99
|
+
Basic usage:
|
|
100
|
+
|
|
101
|
+
self.visit(node.left)
|
|
102
|
+
self.visit(node.right)
|
|
103
|
+
"""
|
|
104
|
+
self.visit(node.left)
|
|
105
|
+
self.visit(node.right)
|
|
106
|
+
|
|
107
|
+
def visit_MulOp(self, node: AST.MulOp) -> None:
|
|
108
|
+
"""
|
|
109
|
+
MulOp: (op, children)
|
|
110
|
+
|
|
111
|
+
op:
|
|
112
|
+
|
|
113
|
+
Basic usage:
|
|
114
|
+
|
|
115
|
+
for child in node.children:
|
|
116
|
+
self.visit(child)
|
|
117
|
+
"""
|
|
118
|
+
for child in node.children:
|
|
119
|
+
self.visit(child)
|
|
120
|
+
|
|
121
|
+
def visit_ParamOp(self, node: AST.ParamOp) -> None:
|
|
122
|
+
"""
|
|
123
|
+
ParamOp: (op, children, params)
|
|
124
|
+
|
|
125
|
+
op:
|
|
126
|
+
|
|
127
|
+
Basic usage:
|
|
128
|
+
|
|
129
|
+
for child in node.children:
|
|
130
|
+
self.visit(child)
|
|
131
|
+
for param in node.params:
|
|
132
|
+
self.visit(param)
|
|
133
|
+
"""
|
|
134
|
+
for child in node.children:
|
|
135
|
+
if isinstance(child, AST.AST):
|
|
136
|
+
self.visit(child)
|
|
137
|
+
for param in node.params:
|
|
138
|
+
if isinstance(param, AST.AST):
|
|
139
|
+
self.visit(param)
|
|
140
|
+
|
|
141
|
+
def visit_JoinOp(self, node: AST.JoinOp) -> None:
|
|
142
|
+
"""
|
|
143
|
+
JoinOp: (op, clauses, using)
|
|
144
|
+
|
|
145
|
+
op:
|
|
146
|
+
|
|
147
|
+
Basic usage:
|
|
148
|
+
|
|
149
|
+
for clause in node.clauses:
|
|
150
|
+
self.visit(clause)
|
|
151
|
+
|
|
152
|
+
if node.using != None:
|
|
153
|
+
self.visit(node.body)
|
|
154
|
+
"""
|
|
155
|
+
for clause in node.clauses:
|
|
156
|
+
self.visit(clause)
|
|
157
|
+
|
|
158
|
+
if node.using is not None:
|
|
159
|
+
self.visit(node.using)
|
|
160
|
+
|
|
161
|
+
def visit_Constant(self, node: AST.Constant) -> AST.AST:
|
|
162
|
+
"""
|
|
163
|
+
Constant: (type, value)
|
|
164
|
+
|
|
165
|
+
Basic usage:
|
|
166
|
+
|
|
167
|
+
return node.value
|
|
168
|
+
"""
|
|
169
|
+
return node.value
|
|
170
|
+
|
|
171
|
+
def visit_ParamConstant(self, node: AST.ParamConstant) -> Any:
|
|
172
|
+
"""
|
|
173
|
+
Constant: (type, value)
|
|
174
|
+
|
|
175
|
+
Basic usage:
|
|
176
|
+
|
|
177
|
+
return node.value
|
|
178
|
+
"""
|
|
179
|
+
return node.value
|
|
180
|
+
|
|
181
|
+
def visit_Identifier(self, node: AST.Identifier) -> Any:
|
|
182
|
+
"""
|
|
183
|
+
Identifier: (value)
|
|
184
|
+
|
|
185
|
+
Basic usage:
|
|
186
|
+
|
|
187
|
+
return node.value
|
|
188
|
+
"""
|
|
189
|
+
return node.value
|
|
190
|
+
|
|
191
|
+
def visit_Optional(self, node: AST.Optional) -> AST.AST:
|
|
192
|
+
"""
|
|
193
|
+
Optional: (value)
|
|
194
|
+
|
|
195
|
+
Basic usage:
|
|
196
|
+
|
|
197
|
+
return node.value
|
|
198
|
+
"""
|
|
199
|
+
return node.value
|
|
200
|
+
|
|
201
|
+
def visit_ID(self, node: AST.ID) -> AST.AST:
|
|
202
|
+
"""
|
|
203
|
+
ID: (type, value)
|
|
204
|
+
|
|
205
|
+
Basic usage:
|
|
206
|
+
|
|
207
|
+
return node.value
|
|
208
|
+
"""
|
|
209
|
+
if node.value == "_":
|
|
210
|
+
return
|
|
211
|
+
return node.value
|
|
212
|
+
|
|
213
|
+
def visit_Role(self, node: AST.Role) -> AST.AST:
|
|
214
|
+
"""
|
|
215
|
+
Role: (role)
|
|
216
|
+
|
|
217
|
+
Basic usage:
|
|
218
|
+
|
|
219
|
+
return node.role
|
|
220
|
+
"""
|
|
221
|
+
return node.role
|
|
222
|
+
|
|
223
|
+
def visit_Collection(self, node: AST.Collection) -> None:
|
|
224
|
+
"""
|
|
225
|
+
Collection: (name, type, children)
|
|
226
|
+
|
|
227
|
+
Basic usage:
|
|
228
|
+
|
|
229
|
+
for child in node.children:
|
|
230
|
+
self.visit(child)
|
|
231
|
+
"""
|
|
232
|
+
for child in node.children:
|
|
233
|
+
self.visit(child)
|
|
234
|
+
|
|
235
|
+
def visit_RegularAggregation(self, node: AST.RegularAggregation) -> None:
|
|
236
|
+
"""
|
|
237
|
+
RegularAggregation: (dataset, op, children)
|
|
238
|
+
|
|
239
|
+
op:
|
|
240
|
+
|
|
241
|
+
Basic usage:
|
|
242
|
+
|
|
243
|
+
self.visit(node.dataset)
|
|
244
|
+
for child in node.children:
|
|
245
|
+
self.visit(child)
|
|
246
|
+
"""
|
|
247
|
+
self.visit(node.dataset)
|
|
248
|
+
for child in node.children:
|
|
249
|
+
self.visit(child)
|
|
250
|
+
|
|
251
|
+
def visit_Aggregation(self, node: AST.Aggregation) -> None:
|
|
252
|
+
"""
|
|
253
|
+
Aggregation: (op, operand, grouping_op, grouping)
|
|
254
|
+
|
|
255
|
+
op: SUM, AVG , COUNT, MEDIAN, MIN, MAX, STDDEV_POP, STDDEV_SAMP,
|
|
256
|
+
VAR_POP, VAR_SAMP
|
|
257
|
+
|
|
258
|
+
grouping types: 'group by', 'group except', 'group all'.
|
|
259
|
+
|
|
260
|
+
Basic usage:
|
|
261
|
+
|
|
262
|
+
self.visit(node.operand)
|
|
263
|
+
|
|
264
|
+
if node.params != None:
|
|
265
|
+
for param in node.params:
|
|
266
|
+
self.visit(param)
|
|
267
|
+
if node.grouping != None:
|
|
268
|
+
for group in node.grouping:
|
|
269
|
+
self.visit(group)
|
|
270
|
+
"""
|
|
271
|
+
self.visit(node.operand)
|
|
272
|
+
|
|
273
|
+
if node.grouping is not None:
|
|
274
|
+
for group in node.grouping:
|
|
275
|
+
self.visit(group)
|
|
276
|
+
|
|
277
|
+
def visit_Analytic(self, node: AST.Analytic) -> None:
|
|
278
|
+
""" """
|
|
279
|
+
if node.operand is not None:
|
|
280
|
+
self.visit(node.operand)
|
|
281
|
+
|
|
282
|
+
def visit_TimeAggregation(self, node: AST.TimeAggregation) -> None:
|
|
283
|
+
"""
|
|
284
|
+
TimeAggregation: (op, operand, params, conf)
|
|
285
|
+
|
|
286
|
+
op types: TIME_AGG
|
|
287
|
+
|
|
288
|
+
Basic usage:
|
|
289
|
+
|
|
290
|
+
if node.operand != None:
|
|
291
|
+
self.visit(node.operand)
|
|
292
|
+
|
|
293
|
+
if node.params != None:
|
|
294
|
+
for param in node.params:
|
|
295
|
+
self.visit(param)
|
|
296
|
+
"""
|
|
297
|
+
if node.operand is not None:
|
|
298
|
+
self.visit(node.operand)
|
|
299
|
+
|
|
300
|
+
def visit_If(self, node: AST.If) -> Any:
|
|
301
|
+
"""
|
|
302
|
+
If: (condition, thenOp, elseOp)
|
|
303
|
+
|
|
304
|
+
Basic usage:
|
|
305
|
+
|
|
306
|
+
self.visit(node.condition)
|
|
307
|
+
self.visit(node.thenOp)
|
|
308
|
+
self.visit(node.elseOp)
|
|
309
|
+
"""
|
|
310
|
+
self.visit(node.condition)
|
|
311
|
+
self.visit(node.thenOp)
|
|
312
|
+
self.visit(node.elseOp)
|
|
313
|
+
|
|
314
|
+
def visit_Case(self, node: AST.Case) -> Any:
|
|
315
|
+
"""
|
|
316
|
+
Case: (conditions, thenOp, elseOp)
|
|
317
|
+
|
|
318
|
+
Basic usage:
|
|
319
|
+
|
|
320
|
+
for condition in node.conditions:
|
|
321
|
+
self.visit(condition)
|
|
322
|
+
self.visit(node.thenOp)
|
|
323
|
+
self.visit(node.elseOp)
|
|
324
|
+
"""
|
|
325
|
+
for case in node.cases:
|
|
326
|
+
self.visit(case.condition)
|
|
327
|
+
self.visit(case.thenOp)
|
|
328
|
+
self.visit(node.elseOp)
|
|
329
|
+
|
|
330
|
+
def visit_CaseObj(self, node: AST.CaseObj) -> Any:
|
|
331
|
+
"""
|
|
332
|
+
CaseObj: (condition, thenOp)
|
|
333
|
+
|
|
334
|
+
Basic usage:
|
|
335
|
+
|
|
336
|
+
self.visit(node.condition)
|
|
337
|
+
self.visit(node.thenOp)
|
|
338
|
+
"""
|
|
339
|
+
self.visit(node.condition)
|
|
340
|
+
self.visit(node.thenOp)
|
|
341
|
+
|
|
342
|
+
def visit_Validation(self, node: AST.Validation) -> Any:
|
|
343
|
+
"""
|
|
344
|
+
Validation: (op, validation, params, inbalance, invalid)
|
|
345
|
+
|
|
346
|
+
Basic usage:
|
|
347
|
+
|
|
348
|
+
self.visit(node.validation)
|
|
349
|
+
for param in node.params:
|
|
350
|
+
self.visit(param)
|
|
351
|
+
|
|
352
|
+
if node.inbalance!=None:
|
|
353
|
+
self.visit(node.inbalance)
|
|
354
|
+
|
|
355
|
+
"""
|
|
356
|
+
self.visit(node.validation)
|
|
357
|
+
|
|
358
|
+
if node.imbalance is not None:
|
|
359
|
+
self.visit(node.imbalance)
|
|
360
|
+
|
|
361
|
+
def visit_Operator(self, node: AST.Operator) -> None:
|
|
362
|
+
"""
|
|
363
|
+
Operator: (operator, parameters, outputType, expresion)
|
|
364
|
+
|
|
365
|
+
Basic usage:
|
|
366
|
+
|
|
367
|
+
for parameter in node.parameters:
|
|
368
|
+
self.visit(parameter)
|
|
369
|
+
|
|
370
|
+
self.visit(node.expresion)
|
|
371
|
+
"""
|
|
372
|
+
for parameter in node.parameters:
|
|
373
|
+
self.visit(parameter)
|
|
374
|
+
|
|
375
|
+
self.visit(node.expression)
|
|
376
|
+
|
|
377
|
+
def visit_Types(self, node: AST.Types) -> None:
|
|
378
|
+
"""
|
|
379
|
+
Types: (kind, type_, constraints, nullable)
|
|
380
|
+
|
|
381
|
+
Basic usage:
|
|
382
|
+
|
|
383
|
+
for constraint in node.constraints:
|
|
384
|
+
self.visit(constraint)
|
|
385
|
+
"""
|
|
386
|
+
if node.constraints is not None:
|
|
387
|
+
for constraint in node.constraints:
|
|
388
|
+
self.visit(constraint)
|
|
389
|
+
|
|
390
|
+
def visit_Argument(self, node: AST.Argument) -> None:
|
|
391
|
+
"""
|
|
392
|
+
Argument: (name, type_, default)
|
|
393
|
+
|
|
394
|
+
Basic usage:
|
|
395
|
+
|
|
396
|
+
self.visit(node.type_)
|
|
397
|
+
if default != None:
|
|
398
|
+
self.visit(node.default)
|
|
399
|
+
"""
|
|
400
|
+
self.visit(node.type_)
|
|
401
|
+
if node.default is not None:
|
|
402
|
+
self.visit(node.default)
|
|
403
|
+
|
|
404
|
+
def visit_HRuleset(self, node: AST.HRuleset) -> None:
|
|
405
|
+
"""
|
|
406
|
+
HRuleset: (name, element, rules)
|
|
407
|
+
|
|
408
|
+
Basic usage:
|
|
409
|
+
|
|
410
|
+
self.visit(node.element)
|
|
411
|
+
for rule in node.rules:
|
|
412
|
+
self.visit(rule)
|
|
413
|
+
"""
|
|
414
|
+
if isinstance(node.element, list):
|
|
415
|
+
for element in node.element:
|
|
416
|
+
self.visit(element)
|
|
417
|
+
else:
|
|
418
|
+
self.visit(node.element)
|
|
419
|
+
for rule in node.rules:
|
|
420
|
+
self.visit(rule)
|
|
421
|
+
|
|
422
|
+
def visit_DPRuleset(self, node: AST.DPRuleset) -> None:
|
|
423
|
+
"""
|
|
424
|
+
DPRuleset: (name, element, rules)
|
|
425
|
+
|
|
426
|
+
Basic usage:
|
|
427
|
+
|
|
428
|
+
self.visit(node.element)
|
|
429
|
+
for rule in node.rules:
|
|
430
|
+
self.visit(rule)
|
|
431
|
+
"""
|
|
432
|
+
for element in node.params:
|
|
433
|
+
self.visit(element)
|
|
434
|
+
for rule in node.rules:
|
|
435
|
+
self.visit(rule)
|
|
436
|
+
|
|
437
|
+
def visit_HRule(self, node: AST.HRule) -> None:
|
|
438
|
+
"""
|
|
439
|
+
HRule: (name, rule, erCode, erLevel)
|
|
440
|
+
|
|
441
|
+
Basic usage:
|
|
442
|
+
|
|
443
|
+
self.visit(node.rule)
|
|
444
|
+
if node.erCode != None:
|
|
445
|
+
self.visit(node.erCode)
|
|
446
|
+
if node.erLevel != None:
|
|
447
|
+
self.visit(node.erLevel)
|
|
448
|
+
"""
|
|
449
|
+
self.visit(node.rule)
|
|
450
|
+
|
|
451
|
+
def visit_DPRule(self, node: AST.DPRule) -> None:
|
|
452
|
+
"""
|
|
453
|
+
DPRule: (name, rule, erCode, erLevel)
|
|
454
|
+
|
|
455
|
+
Basic usage:
|
|
456
|
+
|
|
457
|
+
self.visit(node.rule)
|
|
458
|
+
if node.erCode != None:
|
|
459
|
+
self.visit(node.erCode)
|
|
460
|
+
if node.erLevel != None:
|
|
461
|
+
self.visit(node.erLevel)
|
|
462
|
+
"""
|
|
463
|
+
self.visit(node.rule)
|
|
464
|
+
|
|
465
|
+
def visit_HRBinOp(self, node: AST.HRBinOp) -> None:
|
|
466
|
+
"""
|
|
467
|
+
HRBinOp: (left, op, right)
|
|
468
|
+
|
|
469
|
+
Basic usage:
|
|
470
|
+
|
|
471
|
+
self.visit(node.left)
|
|
472
|
+
self.visit(node.right)
|
|
473
|
+
"""
|
|
474
|
+
self.visit(node.left)
|
|
475
|
+
self.visit(node.right)
|
|
476
|
+
|
|
477
|
+
def visit_HRUnOp(self, node: AST.HRUnOp) -> None:
|
|
478
|
+
"""
|
|
479
|
+
HRUnOp: (op, operand)
|
|
480
|
+
|
|
481
|
+
Basic usage:
|
|
482
|
+
|
|
483
|
+
self.visit(node.operand)
|
|
484
|
+
"""
|
|
485
|
+
self.visit(node.operand)
|
|
486
|
+
|
|
487
|
+
def visit_DefIdentifier(self, node: AST.DefIdentifier) -> AST.AST:
|
|
488
|
+
"""
|
|
489
|
+
DefIdentifier: (value, kind)
|
|
490
|
+
|
|
491
|
+
Basic usage:
|
|
492
|
+
|
|
493
|
+
return node.value
|
|
494
|
+
"""
|
|
495
|
+
return node.value
|
|
496
|
+
|
|
497
|
+
def visit_DPRIdentifier(self, node: AST.DPRIdentifier) -> str:
|
|
498
|
+
"""
|
|
499
|
+
DefIdentifier: (value, kind)
|
|
500
|
+
|
|
501
|
+
Basic usage:
|
|
502
|
+
|
|
503
|
+
return node.value
|
|
504
|
+
"""
|
|
505
|
+
return node.value
|
|
506
|
+
|
|
507
|
+
def visit_EvalOp(self, node: AST.EvalOp) -> Any:
|
|
508
|
+
"""
|
|
509
|
+
EvalOp: (name, children, output, language)
|
|
510
|
+
|
|
511
|
+
Basic usage:
|
|
512
|
+
|
|
513
|
+
for child in node.children:
|
|
514
|
+
self.visit(child)
|
|
515
|
+
if node.output != None:
|
|
516
|
+
self.visit(node.output)
|
|
517
|
+
|
|
518
|
+
"""
|
|
519
|
+
for child in node.operands:
|
|
520
|
+
self.visit(child)
|
|
521
|
+
|
|
522
|
+
def visit_ParFunction(self, node: AST.ParFunction) -> None:
|
|
523
|
+
"""
|
|
524
|
+
ParFunction: (operand)
|
|
525
|
+
"""
|
|
526
|
+
self.visit(node.operand)
|
|
527
|
+
|
|
528
|
+
def visit_NoOp(self, node: AST.NoOp) -> None: # pylint: disable=unused-argument
|
|
529
|
+
"""
|
|
530
|
+
NoOp: ()
|
|
531
|
+
|
|
532
|
+
Basic usage:
|
|
533
|
+
|
|
534
|
+
pass
|
|
535
|
+
"""
|
|
536
|
+
...
|
|
537
|
+
|
|
538
|
+
def visit_RenameNode(self, node: AST.RenameNode) -> None:
|
|
539
|
+
"""
|
|
540
|
+
RenameNode: (name, to)
|
|
541
|
+
"""
|
|
542
|
+
|
|
543
|
+
def visit_UDOCall(self, node: AST.UDOCall) -> None:
|
|
544
|
+
"""
|
|
545
|
+
UDOCall: (name, children, params)
|
|
546
|
+
"""
|
|
547
|
+
for param in node.params:
|
|
548
|
+
self.visit(param)
|
|
549
|
+
|
|
550
|
+
def visit_Windowing(self, node: AST.Windowing) -> None:
|
|
551
|
+
"""
|
|
552
|
+
Windowing: (type_, start, start_mode, stop, stop_mode)
|
|
553
|
+
"""
|
|
554
|
+
|
|
555
|
+
def visit_Comment(self, node: AST.Comment) -> None:
|
|
556
|
+
"""
|
|
557
|
+
Comment: (value)
|
|
558
|
+
"""
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"""
|
|
2
|
+
AST.ASTVisitor.py
|
|
3
|
+
=================
|
|
4
|
+
|
|
5
|
+
Description
|
|
6
|
+
-----------
|
|
7
|
+
Node Dispatcher.
|
|
8
|
+
"""
|
|
9
|
+
|
|
10
|
+
from typing import Any
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
class NodeVisitor(object):
|
|
14
|
+
""" """
|
|
15
|
+
|
|
16
|
+
def visit(self, node: Any):
|
|
17
|
+
""" """
|
|
18
|
+
method_name = "visit_" + type(node).__name__
|
|
19
|
+
visitor = getattr(self, method_name, self.generic_visit)
|
|
20
|
+
return visitor(node)
|
|
21
|
+
|
|
22
|
+
def generic_visit(self, node):
|
|
23
|
+
""" """
|
|
24
|
+
# AST_ASTVISITOR.1
|
|
25
|
+
raise Exception("No visit_{} method".format(type(node).__name__))
|