jaclang 0.8.8__py3-none-any.whl → 0.8.10__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.
Potentially problematic release.
This version of jaclang might be problematic. Click here for more details.
- jaclang/cli/cli.py +194 -10
- jaclang/cli/cmdreg.py +144 -8
- jaclang/compiler/__init__.py +6 -1
- jaclang/compiler/codeinfo.py +16 -1
- jaclang/compiler/constant.py +33 -8
- jaclang/compiler/jac.lark +154 -62
- jaclang/compiler/larkparse/jac_parser.py +2 -2
- jaclang/compiler/parser.py +656 -149
- jaclang/compiler/passes/__init__.py +2 -1
- jaclang/compiler/passes/ast_gen/__init__.py +5 -0
- jaclang/compiler/passes/ast_gen/base_ast_gen_pass.py +54 -0
- jaclang/compiler/passes/ast_gen/jsx_processor.py +344 -0
- jaclang/compiler/passes/ecmascript/__init__.py +25 -0
- jaclang/compiler/passes/ecmascript/es_unparse.py +576 -0
- jaclang/compiler/passes/ecmascript/esast_gen_pass.py +2068 -0
- jaclang/compiler/passes/ecmascript/estree.py +972 -0
- jaclang/compiler/passes/ecmascript/tests/__init__.py +1 -0
- jaclang/compiler/passes/ecmascript/tests/fixtures/advanced_language_features.jac +170 -0
- jaclang/compiler/passes/ecmascript/tests/fixtures/class_separate_impl.impl.jac +30 -0
- jaclang/compiler/passes/ecmascript/tests/fixtures/class_separate_impl.jac +14 -0
- jaclang/compiler/passes/ecmascript/tests/fixtures/client_jsx.jac +89 -0
- jaclang/compiler/passes/ecmascript/tests/fixtures/core_language_features.jac +195 -0
- jaclang/compiler/passes/ecmascript/tests/test_esast_gen_pass.py +167 -0
- jaclang/compiler/passes/ecmascript/tests/test_js_generation.py +239 -0
- jaclang/compiler/passes/main/__init__.py +0 -3
- jaclang/compiler/passes/main/annex_pass.py +23 -1
- jaclang/compiler/passes/main/def_use_pass.py +1 -0
- jaclang/compiler/passes/main/pyast_gen_pass.py +413 -255
- jaclang/compiler/passes/main/pyast_load_pass.py +48 -11
- jaclang/compiler/passes/main/pyjac_ast_link_pass.py +2 -0
- jaclang/compiler/passes/main/sym_tab_build_pass.py +18 -1
- jaclang/compiler/passes/main/tests/fixtures/autoimpl.cl.jac +7 -0
- jaclang/compiler/passes/main/tests/fixtures/checker_arity.jac +3 -0
- jaclang/compiler/passes/main/tests/fixtures/checker_class_construct.jac +33 -0
- jaclang/compiler/passes/main/tests/fixtures/defuse_modpath.jac +7 -0
- jaclang/compiler/passes/main/tests/fixtures/member_access_type_resolve.jac +2 -1
- jaclang/compiler/passes/main/tests/test_checker_pass.py +31 -3
- jaclang/compiler/passes/main/tests/test_def_use_pass.py +12 -0
- jaclang/compiler/passes/main/tests/test_import_pass.py +23 -4
- jaclang/compiler/passes/main/tests/test_predynamo_pass.py +13 -14
- jaclang/compiler/passes/main/tests/test_pyast_gen_pass.py +25 -0
- jaclang/compiler/passes/main/type_checker_pass.py +7 -0
- jaclang/compiler/passes/tool/doc_ir_gen_pass.py +219 -20
- jaclang/compiler/passes/tool/fuse_comments_pass.py +1 -10
- jaclang/compiler/passes/tool/jac_formatter_pass.py +2 -2
- jaclang/compiler/passes/tool/tests/fixtures/import_fmt.jac +7 -1
- jaclang/compiler/passes/tool/tests/fixtures/tagbreak.jac +135 -29
- jaclang/compiler/passes/tool/tests/test_jac_format_pass.py +4 -1
- jaclang/compiler/passes/transform.py +9 -1
- jaclang/compiler/passes/uni_pass.py +5 -7
- jaclang/compiler/program.py +27 -26
- jaclang/compiler/tests/test_client_codegen.py +113 -0
- jaclang/compiler/tests/test_importer.py +12 -10
- jaclang/compiler/tests/test_parser.py +249 -3
- jaclang/compiler/type_system/type_evaluator.jac +1078 -0
- jaclang/compiler/type_system/type_utils.py +1 -1
- jaclang/compiler/type_system/types.py +6 -0
- jaclang/compiler/unitree.py +438 -82
- jaclang/langserve/engine.jac +224 -288
- jaclang/langserve/sem_manager.jac +12 -8
- jaclang/langserve/server.jac +48 -48
- jaclang/langserve/tests/fixtures/greet.py +17 -0
- jaclang/langserve/tests/fixtures/md_path.jac +22 -0
- jaclang/langserve/tests/fixtures/user.jac +15 -0
- jaclang/langserve/tests/test_server.py +66 -371
- jaclang/lib.py +17 -0
- jaclang/runtimelib/archetype.py +25 -25
- jaclang/runtimelib/client_bundle.py +169 -0
- jaclang/runtimelib/client_runtime.jac +586 -0
- jaclang/runtimelib/constructs.py +4 -2
- jaclang/runtimelib/machine.py +308 -139
- jaclang/runtimelib/meta_importer.py +111 -22
- jaclang/runtimelib/mtp.py +15 -0
- jaclang/runtimelib/server.py +1089 -0
- jaclang/runtimelib/tests/fixtures/client_app.jac +18 -0
- jaclang/runtimelib/tests/fixtures/custom_access_validation.jac +1 -1
- jaclang/runtimelib/tests/fixtures/savable_object.jac +4 -5
- jaclang/runtimelib/tests/fixtures/serve_api.jac +75 -0
- jaclang/runtimelib/tests/test_client_bundle.py +55 -0
- jaclang/runtimelib/tests/test_client_render.py +63 -0
- jaclang/runtimelib/tests/test_serve.py +1069 -0
- jaclang/settings.py +0 -3
- jaclang/tests/fixtures/attr_pattern_case.jac +18 -0
- jaclang/tests/fixtures/funccall_genexpr.jac +7 -0
- jaclang/tests/fixtures/funccall_genexpr.py +5 -0
- jaclang/tests/fixtures/iife_functions.jac +142 -0
- jaclang/tests/fixtures/iife_functions_client.jac +143 -0
- jaclang/tests/fixtures/multistatement_lambda.jac +116 -0
- jaclang/tests/fixtures/multistatement_lambda_client.jac +113 -0
- jaclang/tests/fixtures/needs_import_dup.jac +6 -4
- jaclang/tests/fixtures/py2jac_empty.py +0 -0
- jaclang/tests/fixtures/py_run.py +7 -5
- jaclang/tests/fixtures/pyfunc_fstr.py +2 -2
- jaclang/tests/fixtures/simple_lambda_test.jac +12 -0
- jaclang/tests/test_cli.py +134 -18
- jaclang/tests/test_language.py +120 -32
- jaclang/tests/test_reference.py +20 -3
- jaclang/utils/NonGPT.py +375 -0
- jaclang/utils/helpers.py +64 -20
- jaclang/utils/lang_tools.py +31 -4
- jaclang/utils/tests/test_lang_tools.py +5 -16
- jaclang/utils/treeprinter.py +8 -3
- {jaclang-0.8.8.dist-info → jaclang-0.8.10.dist-info}/METADATA +3 -3
- {jaclang-0.8.8.dist-info → jaclang-0.8.10.dist-info}/RECORD +106 -71
- jaclang/compiler/passes/main/binder_pass.py +0 -594
- jaclang/compiler/passes/main/tests/fixtures/sym_binder.jac +0 -47
- jaclang/compiler/passes/main/tests/test_binder_pass.py +0 -111
- jaclang/compiler/type_system/type_evaluator.py +0 -844
- jaclang/langserve/tests/session.jac +0 -294
- jaclang/langserve/tests/test_dev_server.py +0 -80
- jaclang/runtimelib/importer.py +0 -351
- jaclang/tests/test_typecheck.py +0 -542
- {jaclang-0.8.8.dist-info → jaclang-0.8.10.dist-info}/WHEEL +0 -0
- {jaclang-0.8.8.dist-info → jaclang-0.8.10.dist-info}/entry_points.txt +0 -0
|
@@ -0,0 +1,972 @@
|
|
|
1
|
+
"""ESTree AST Node Definitions for ECMAScript.
|
|
2
|
+
|
|
3
|
+
This module provides a complete implementation of the ESTree specification,
|
|
4
|
+
which defines the standard AST format for JavaScript and ECMAScript.
|
|
5
|
+
|
|
6
|
+
The ESTree specification represents ECMAScript programs as abstract syntax trees
|
|
7
|
+
that are language-agnostic and can be used for various tools like parsers,
|
|
8
|
+
transpilers, and code analysis tools.
|
|
9
|
+
|
|
10
|
+
Reference: https://github.com/estree/estree
|
|
11
|
+
"""
|
|
12
|
+
|
|
13
|
+
from __future__ import annotations
|
|
14
|
+
|
|
15
|
+
from dataclasses import dataclass, field
|
|
16
|
+
from typing import Any, Literal as TypingLiteral, Optional, TypeAlias, Union
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
# Literal type aliases for repeated enumerations
|
|
20
|
+
SourceType: TypeAlias = TypingLiteral["script", "module"] # noqa: F821
|
|
21
|
+
VariableDeclarationKind: TypeAlias = TypingLiteral["var", "let", "const"] # noqa: F821
|
|
22
|
+
PropertyKind: TypeAlias = TypingLiteral["init", "get", "set"] # noqa: F821
|
|
23
|
+
MethodDefinitionKind: TypeAlias = TypingLiteral[
|
|
24
|
+
"constructor", "method", "get", "set" # noqa: F821
|
|
25
|
+
]
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
# Base Node Types
|
|
29
|
+
# ================
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
@dataclass
|
|
33
|
+
class SourceLocation:
|
|
34
|
+
"""Source location information for a node."""
|
|
35
|
+
|
|
36
|
+
source: Optional[str] = None
|
|
37
|
+
start: Optional["Position"] = None
|
|
38
|
+
end: Optional["Position"] = None
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
@dataclass
|
|
42
|
+
class Position:
|
|
43
|
+
"""Position in source code."""
|
|
44
|
+
|
|
45
|
+
line: int = 0
|
|
46
|
+
column: int = 0
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
@dataclass
|
|
50
|
+
class Node:
|
|
51
|
+
"""Base class for all ESTree nodes."""
|
|
52
|
+
|
|
53
|
+
type: str
|
|
54
|
+
loc: Optional[SourceLocation] = field(default=None)
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
# Identifier and Literals
|
|
58
|
+
# =======================
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
@dataclass
|
|
62
|
+
class Identifier(Node):
|
|
63
|
+
"""Identifier node."""
|
|
64
|
+
|
|
65
|
+
name: str = ""
|
|
66
|
+
type: TypingLiteral["Identifier"] = field(default="Identifier", init=False)
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
@dataclass
|
|
70
|
+
class PrivateIdentifier(Node):
|
|
71
|
+
"""Private identifier for class members (ES2022)."""
|
|
72
|
+
|
|
73
|
+
name: str = ""
|
|
74
|
+
type: TypingLiteral["PrivateIdentifier"] = field(
|
|
75
|
+
default="PrivateIdentifier", init=False
|
|
76
|
+
)
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
@dataclass
|
|
80
|
+
class Literal(Node):
|
|
81
|
+
"""Literal value node (supports BigInt in ES2020)."""
|
|
82
|
+
|
|
83
|
+
value: Union[str, bool, None, int, float] = None
|
|
84
|
+
raw: Optional[str] = None
|
|
85
|
+
bigint: Optional[str] = None # ES2020: BigInt represented as string
|
|
86
|
+
type: TypingLiteral["Literal"] = field(default="Literal", init=False)
|
|
87
|
+
|
|
88
|
+
|
|
89
|
+
@dataclass
|
|
90
|
+
class RegExpLiteral(Literal):
|
|
91
|
+
"""Regular expression literal."""
|
|
92
|
+
|
|
93
|
+
regex: dict[str, str] = field(default_factory=dict) # {pattern: str, flags: str}
|
|
94
|
+
type: TypingLiteral["Literal"] = field(default="Literal", init=False)
|
|
95
|
+
|
|
96
|
+
|
|
97
|
+
# Program and Statements
|
|
98
|
+
# ======================
|
|
99
|
+
|
|
100
|
+
|
|
101
|
+
@dataclass
|
|
102
|
+
class Program(Node):
|
|
103
|
+
"""Root node of an ESTree."""
|
|
104
|
+
|
|
105
|
+
body: list[Union["Statement", "ModuleDeclaration"]] = field(default_factory=list)
|
|
106
|
+
sourceType: SourceType = "script" # noqa: N815
|
|
107
|
+
type: TypingLiteral["Program"] = field(default="Program", init=False)
|
|
108
|
+
|
|
109
|
+
|
|
110
|
+
@dataclass
|
|
111
|
+
class ExpressionStatement(Node):
|
|
112
|
+
"""Expression statement."""
|
|
113
|
+
|
|
114
|
+
expression: Optional["Expression"] = None
|
|
115
|
+
type: TypingLiteral["ExpressionStatement"] = field(
|
|
116
|
+
default="ExpressionStatement", init=False
|
|
117
|
+
)
|
|
118
|
+
|
|
119
|
+
|
|
120
|
+
@dataclass
|
|
121
|
+
class Directive(ExpressionStatement):
|
|
122
|
+
"""Directive (e.g., 'use strict') - ES5."""
|
|
123
|
+
|
|
124
|
+
directive: str = ""
|
|
125
|
+
type: TypingLiteral["ExpressionStatement"] = field(
|
|
126
|
+
default="ExpressionStatement", init=False
|
|
127
|
+
)
|
|
128
|
+
|
|
129
|
+
|
|
130
|
+
@dataclass
|
|
131
|
+
class BlockStatement(Node):
|
|
132
|
+
"""Block statement."""
|
|
133
|
+
|
|
134
|
+
body: list["Statement"] = field(default_factory=list)
|
|
135
|
+
type: TypingLiteral["BlockStatement"] = field(default="BlockStatement", init=False)
|
|
136
|
+
|
|
137
|
+
|
|
138
|
+
@dataclass
|
|
139
|
+
class EmptyStatement(Node):
|
|
140
|
+
"""Empty statement (;)."""
|
|
141
|
+
|
|
142
|
+
type: TypingLiteral["EmptyStatement"] = field(default="EmptyStatement", init=False)
|
|
143
|
+
|
|
144
|
+
|
|
145
|
+
@dataclass
|
|
146
|
+
class DebuggerStatement(Node):
|
|
147
|
+
"""Debugger statement."""
|
|
148
|
+
|
|
149
|
+
type: TypingLiteral["DebuggerStatement"] = field(
|
|
150
|
+
default="DebuggerStatement", init=False
|
|
151
|
+
)
|
|
152
|
+
|
|
153
|
+
|
|
154
|
+
@dataclass
|
|
155
|
+
class WithStatement(Node):
|
|
156
|
+
"""With statement."""
|
|
157
|
+
|
|
158
|
+
object: Optional["Expression"] = None
|
|
159
|
+
body: Optional["Statement"] = None
|
|
160
|
+
type: TypingLiteral["WithStatement"] = field(default="WithStatement", init=False)
|
|
161
|
+
|
|
162
|
+
|
|
163
|
+
@dataclass
|
|
164
|
+
class ReturnStatement(Node):
|
|
165
|
+
"""Return statement."""
|
|
166
|
+
|
|
167
|
+
argument: Optional["Expression"] = None
|
|
168
|
+
type: TypingLiteral["ReturnStatement"] = field(
|
|
169
|
+
default="ReturnStatement", init=False
|
|
170
|
+
)
|
|
171
|
+
|
|
172
|
+
|
|
173
|
+
@dataclass
|
|
174
|
+
class LabeledStatement(Node):
|
|
175
|
+
"""Labeled statement."""
|
|
176
|
+
|
|
177
|
+
label: Optional[Identifier] = None
|
|
178
|
+
body: Optional["Statement"] = None
|
|
179
|
+
type: TypingLiteral["LabeledStatement"] = field(
|
|
180
|
+
default="LabeledStatement", init=False
|
|
181
|
+
)
|
|
182
|
+
|
|
183
|
+
|
|
184
|
+
@dataclass
|
|
185
|
+
class BreakStatement(Node):
|
|
186
|
+
"""Break statement."""
|
|
187
|
+
|
|
188
|
+
label: Optional[Identifier] = None
|
|
189
|
+
type: TypingLiteral["BreakStatement"] = field(default="BreakStatement", init=False)
|
|
190
|
+
|
|
191
|
+
|
|
192
|
+
@dataclass
|
|
193
|
+
class ContinueStatement(Node):
|
|
194
|
+
"""Continue statement."""
|
|
195
|
+
|
|
196
|
+
label: Optional[Identifier] = None
|
|
197
|
+
type: TypingLiteral["ContinueStatement"] = field(
|
|
198
|
+
default="ContinueStatement", init=False
|
|
199
|
+
)
|
|
200
|
+
|
|
201
|
+
|
|
202
|
+
@dataclass
|
|
203
|
+
class IfStatement(Node):
|
|
204
|
+
"""If statement."""
|
|
205
|
+
|
|
206
|
+
test: Optional["Expression"] = None
|
|
207
|
+
consequent: Optional["Statement"] = None
|
|
208
|
+
alternate: Optional["Statement"] = None
|
|
209
|
+
type: TypingLiteral["IfStatement"] = field(default="IfStatement", init=False)
|
|
210
|
+
|
|
211
|
+
|
|
212
|
+
@dataclass
|
|
213
|
+
class SwitchStatement(Node):
|
|
214
|
+
"""Switch statement."""
|
|
215
|
+
|
|
216
|
+
discriminant: Optional["Expression"] = None
|
|
217
|
+
cases: list["SwitchCase"] = field(default_factory=list)
|
|
218
|
+
type: TypingLiteral["SwitchStatement"] = field(
|
|
219
|
+
default="SwitchStatement", init=False
|
|
220
|
+
)
|
|
221
|
+
|
|
222
|
+
|
|
223
|
+
@dataclass
|
|
224
|
+
class SwitchCase(Node):
|
|
225
|
+
"""Switch case clause."""
|
|
226
|
+
|
|
227
|
+
test: Optional["Expression"] = None # null for default case
|
|
228
|
+
consequent: list["Statement"] = field(default_factory=list)
|
|
229
|
+
type: TypingLiteral["SwitchCase"] = field(default="SwitchCase", init=False)
|
|
230
|
+
|
|
231
|
+
|
|
232
|
+
@dataclass
|
|
233
|
+
class ThrowStatement(Node):
|
|
234
|
+
"""Throw statement."""
|
|
235
|
+
|
|
236
|
+
argument: Optional["Expression"] = None
|
|
237
|
+
type: TypingLiteral["ThrowStatement"] = field(default="ThrowStatement", init=False)
|
|
238
|
+
|
|
239
|
+
|
|
240
|
+
@dataclass
|
|
241
|
+
class TryStatement(Node):
|
|
242
|
+
"""Try statement."""
|
|
243
|
+
|
|
244
|
+
block: Optional[BlockStatement] = None
|
|
245
|
+
handler: Optional["CatchClause"] = None
|
|
246
|
+
finalizer: Optional[BlockStatement] = None
|
|
247
|
+
type: TypingLiteral["TryStatement"] = field(default="TryStatement", init=False)
|
|
248
|
+
|
|
249
|
+
|
|
250
|
+
@dataclass
|
|
251
|
+
class CatchClause(Node):
|
|
252
|
+
"""Catch clause."""
|
|
253
|
+
|
|
254
|
+
param: Optional["Pattern"] = None
|
|
255
|
+
body: Optional[BlockStatement] = None
|
|
256
|
+
type: TypingLiteral["CatchClause"] = field(default="CatchClause", init=False)
|
|
257
|
+
|
|
258
|
+
|
|
259
|
+
@dataclass
|
|
260
|
+
class WhileStatement(Node):
|
|
261
|
+
"""While statement."""
|
|
262
|
+
|
|
263
|
+
test: Optional["Expression"] = None
|
|
264
|
+
body: Optional["Statement"] = None
|
|
265
|
+
type: TypingLiteral["WhileStatement"] = field(default="WhileStatement", init=False)
|
|
266
|
+
|
|
267
|
+
|
|
268
|
+
@dataclass
|
|
269
|
+
class DoWhileStatement(Node):
|
|
270
|
+
"""Do-while statement."""
|
|
271
|
+
|
|
272
|
+
body: Optional["Statement"] = None
|
|
273
|
+
test: Optional["Expression"] = None
|
|
274
|
+
type: TypingLiteral["DoWhileStatement"] = field(
|
|
275
|
+
default="DoWhileStatement", init=False
|
|
276
|
+
)
|
|
277
|
+
|
|
278
|
+
|
|
279
|
+
@dataclass
|
|
280
|
+
class ForStatement(Node):
|
|
281
|
+
"""For statement."""
|
|
282
|
+
|
|
283
|
+
init: Optional[Union["VariableDeclaration", "Expression"]] = None
|
|
284
|
+
test: Optional["Expression"] = None
|
|
285
|
+
update: Optional["Expression"] = None
|
|
286
|
+
body: Optional["Statement"] = None
|
|
287
|
+
type: TypingLiteral["ForStatement"] = field(default="ForStatement", init=False)
|
|
288
|
+
|
|
289
|
+
|
|
290
|
+
@dataclass
|
|
291
|
+
class ForInStatement(Node):
|
|
292
|
+
"""For-in statement."""
|
|
293
|
+
|
|
294
|
+
left: Optional[Union["VariableDeclaration", "Pattern"]] = None
|
|
295
|
+
right: Optional["Expression"] = None
|
|
296
|
+
body: Optional["Statement"] = None
|
|
297
|
+
type: TypingLiteral["ForInStatement"] = field(default="ForInStatement", init=False)
|
|
298
|
+
|
|
299
|
+
|
|
300
|
+
@dataclass
|
|
301
|
+
class ForOfStatement(Node):
|
|
302
|
+
"""For-of statement (ES6)."""
|
|
303
|
+
|
|
304
|
+
left: Optional[Union["VariableDeclaration", "Pattern"]] = None
|
|
305
|
+
right: Optional["Expression"] = None
|
|
306
|
+
body: Optional["Statement"] = None
|
|
307
|
+
await_: bool = False
|
|
308
|
+
type: TypingLiteral["ForOfStatement"] = field(default="ForOfStatement", init=False)
|
|
309
|
+
|
|
310
|
+
|
|
311
|
+
# Declarations
|
|
312
|
+
# ============
|
|
313
|
+
|
|
314
|
+
|
|
315
|
+
@dataclass
|
|
316
|
+
class FunctionDeclaration(Node):
|
|
317
|
+
"""Function declaration."""
|
|
318
|
+
|
|
319
|
+
id: Optional[Identifier] = None
|
|
320
|
+
params: list["Pattern"] = field(default_factory=list)
|
|
321
|
+
body: Optional[BlockStatement] = None
|
|
322
|
+
generator: bool = False
|
|
323
|
+
async_: bool = False
|
|
324
|
+
type: TypingLiteral["FunctionDeclaration"] = field(
|
|
325
|
+
default="FunctionDeclaration", init=False
|
|
326
|
+
)
|
|
327
|
+
|
|
328
|
+
|
|
329
|
+
@dataclass
|
|
330
|
+
class VariableDeclaration(Node):
|
|
331
|
+
"""Variable declaration."""
|
|
332
|
+
|
|
333
|
+
declarations: list["VariableDeclarator"] = field(default_factory=list)
|
|
334
|
+
kind: VariableDeclarationKind = "var"
|
|
335
|
+
type: TypingLiteral["VariableDeclaration"] = field(
|
|
336
|
+
default="VariableDeclaration", init=False
|
|
337
|
+
)
|
|
338
|
+
|
|
339
|
+
|
|
340
|
+
@dataclass
|
|
341
|
+
class VariableDeclarator(Node):
|
|
342
|
+
"""Variable declarator."""
|
|
343
|
+
|
|
344
|
+
id: Optional["Pattern"] = None
|
|
345
|
+
init: Optional["Expression"] = None
|
|
346
|
+
type: TypingLiteral["VariableDeclarator"] = field(
|
|
347
|
+
default="VariableDeclarator", init=False
|
|
348
|
+
)
|
|
349
|
+
|
|
350
|
+
|
|
351
|
+
# Expressions
|
|
352
|
+
# ===========
|
|
353
|
+
|
|
354
|
+
|
|
355
|
+
@dataclass
|
|
356
|
+
class ThisExpression(Node):
|
|
357
|
+
"""This expression."""
|
|
358
|
+
|
|
359
|
+
type: TypingLiteral["ThisExpression"] = field(default="ThisExpression", init=False)
|
|
360
|
+
|
|
361
|
+
|
|
362
|
+
@dataclass
|
|
363
|
+
class ArrayExpression(Node):
|
|
364
|
+
"""Array expression."""
|
|
365
|
+
|
|
366
|
+
elements: list[Optional[Union["Expression", "SpreadElement"]]] = field(
|
|
367
|
+
default_factory=list
|
|
368
|
+
)
|
|
369
|
+
type: TypingLiteral["ArrayExpression"] = field(
|
|
370
|
+
default="ArrayExpression", init=False
|
|
371
|
+
)
|
|
372
|
+
|
|
373
|
+
|
|
374
|
+
@dataclass
|
|
375
|
+
class ObjectExpression(Node):
|
|
376
|
+
"""Object expression."""
|
|
377
|
+
|
|
378
|
+
properties: list[Union["Property", "SpreadElement"]] = field(default_factory=list)
|
|
379
|
+
type: TypingLiteral["ObjectExpression"] = field(
|
|
380
|
+
default="ObjectExpression", init=False
|
|
381
|
+
)
|
|
382
|
+
|
|
383
|
+
|
|
384
|
+
@dataclass
|
|
385
|
+
class Property(Node):
|
|
386
|
+
"""Object property."""
|
|
387
|
+
|
|
388
|
+
key: Optional[Union["Expression", Identifier, Literal]] = None
|
|
389
|
+
value: Optional["Expression"] = None
|
|
390
|
+
kind: PropertyKind = "init"
|
|
391
|
+
method: bool = False
|
|
392
|
+
shorthand: bool = False
|
|
393
|
+
computed: bool = False
|
|
394
|
+
type: TypingLiteral["Property"] = field(default="Property", init=False)
|
|
395
|
+
|
|
396
|
+
|
|
397
|
+
@dataclass
|
|
398
|
+
class FunctionExpression(Node):
|
|
399
|
+
"""Function expression."""
|
|
400
|
+
|
|
401
|
+
id: Optional[Identifier] = None
|
|
402
|
+
params: list["Pattern"] = field(default_factory=list)
|
|
403
|
+
body: Optional[BlockStatement] = None
|
|
404
|
+
generator: bool = False
|
|
405
|
+
async_: bool = False
|
|
406
|
+
type: TypingLiteral["FunctionExpression"] = field(
|
|
407
|
+
default="FunctionExpression", init=False
|
|
408
|
+
)
|
|
409
|
+
|
|
410
|
+
|
|
411
|
+
@dataclass
|
|
412
|
+
class ArrowFunctionExpression(Node):
|
|
413
|
+
"""Arrow function expression (ES6)."""
|
|
414
|
+
|
|
415
|
+
params: list["Pattern"] = field(default_factory=list)
|
|
416
|
+
body: Optional[Union[BlockStatement, "Expression"]] = None
|
|
417
|
+
expression: bool = False
|
|
418
|
+
async_: bool = False
|
|
419
|
+
type: TypingLiteral["ArrowFunctionExpression"] = field(
|
|
420
|
+
default="ArrowFunctionExpression", init=False
|
|
421
|
+
)
|
|
422
|
+
|
|
423
|
+
|
|
424
|
+
@dataclass
|
|
425
|
+
class UnaryExpression(Node):
|
|
426
|
+
"""Unary expression."""
|
|
427
|
+
|
|
428
|
+
operator: str = "" # "-", "+", "!", "~", "typeof", "void", "delete"
|
|
429
|
+
prefix: bool = True
|
|
430
|
+
argument: Optional["Expression"] = None
|
|
431
|
+
type: TypingLiteral["UnaryExpression"] = field(
|
|
432
|
+
default="UnaryExpression", init=False
|
|
433
|
+
)
|
|
434
|
+
|
|
435
|
+
|
|
436
|
+
@dataclass
|
|
437
|
+
class UpdateExpression(Node):
|
|
438
|
+
"""Update expression."""
|
|
439
|
+
|
|
440
|
+
# Allowed operators: ++, --
|
|
441
|
+
operator: str = "++"
|
|
442
|
+
argument: Optional["Expression"] = None
|
|
443
|
+
prefix: bool = True
|
|
444
|
+
type: TypingLiteral["UpdateExpression"] = field(
|
|
445
|
+
default="UpdateExpression", init=False
|
|
446
|
+
)
|
|
447
|
+
|
|
448
|
+
|
|
449
|
+
@dataclass
|
|
450
|
+
class BinaryExpression(Node):
|
|
451
|
+
"""Binary expression."""
|
|
452
|
+
|
|
453
|
+
# Supported operators align with ESTree spec:
|
|
454
|
+
# == != === !== < <= > >= << >> >>> + - * / % | ^ & in instanceof
|
|
455
|
+
operator: str = ""
|
|
456
|
+
left: Optional["Expression"] = None
|
|
457
|
+
right: Optional["Expression"] = None
|
|
458
|
+
type: TypingLiteral["BinaryExpression"] = field(
|
|
459
|
+
default="BinaryExpression", init=False
|
|
460
|
+
)
|
|
461
|
+
|
|
462
|
+
|
|
463
|
+
@dataclass
|
|
464
|
+
class AssignmentExpression(Node):
|
|
465
|
+
"""Assignment expression."""
|
|
466
|
+
|
|
467
|
+
# Supported operators: =, +=, -=, *=, /=, %=, <<=, >>=, >>>=, |=, ^=, &=
|
|
468
|
+
operator: str = "="
|
|
469
|
+
left: Optional[Union["Pattern", "Expression"]] = None
|
|
470
|
+
right: Optional["Expression"] = None
|
|
471
|
+
type: TypingLiteral["AssignmentExpression"] = field(
|
|
472
|
+
default="AssignmentExpression", init=False
|
|
473
|
+
)
|
|
474
|
+
|
|
475
|
+
|
|
476
|
+
@dataclass
|
|
477
|
+
class LogicalExpression(Node):
|
|
478
|
+
"""Logical expression."""
|
|
479
|
+
|
|
480
|
+
# Supported operators: ||, &&, ??
|
|
481
|
+
operator: str = "&&"
|
|
482
|
+
left: Optional["Expression"] = None
|
|
483
|
+
right: Optional["Expression"] = None
|
|
484
|
+
type: TypingLiteral["LogicalExpression"] = field(
|
|
485
|
+
default="LogicalExpression", init=False
|
|
486
|
+
)
|
|
487
|
+
|
|
488
|
+
|
|
489
|
+
@dataclass
|
|
490
|
+
class MemberExpression(Node):
|
|
491
|
+
"""Member expression."""
|
|
492
|
+
|
|
493
|
+
object: Optional[Union["Expression", "Super"]] = None
|
|
494
|
+
property: Optional["Expression"] = None
|
|
495
|
+
computed: bool = False
|
|
496
|
+
optional: bool = False
|
|
497
|
+
type: TypingLiteral["MemberExpression"] = field(
|
|
498
|
+
default="MemberExpression", init=False
|
|
499
|
+
)
|
|
500
|
+
|
|
501
|
+
|
|
502
|
+
@dataclass
|
|
503
|
+
class ConditionalExpression(Node):
|
|
504
|
+
"""Conditional (ternary) expression."""
|
|
505
|
+
|
|
506
|
+
test: Optional["Expression"] = None
|
|
507
|
+
consequent: Optional["Expression"] = None
|
|
508
|
+
alternate: Optional["Expression"] = None
|
|
509
|
+
type: TypingLiteral["ConditionalExpression"] = field(
|
|
510
|
+
default="ConditionalExpression", init=False
|
|
511
|
+
)
|
|
512
|
+
|
|
513
|
+
|
|
514
|
+
@dataclass
|
|
515
|
+
class CallExpression(Node):
|
|
516
|
+
"""Call expression."""
|
|
517
|
+
|
|
518
|
+
callee: Optional[Union["Expression", "Super"]] = None
|
|
519
|
+
arguments: list[Union["Expression", "SpreadElement"]] = field(default_factory=list)
|
|
520
|
+
optional: bool = False
|
|
521
|
+
type: TypingLiteral["CallExpression"] = field(default="CallExpression", init=False)
|
|
522
|
+
|
|
523
|
+
|
|
524
|
+
@dataclass
|
|
525
|
+
class ChainExpression(Node):
|
|
526
|
+
"""Optional chaining expression (ES2020)."""
|
|
527
|
+
|
|
528
|
+
expression: Optional[Union[CallExpression, MemberExpression]] = None
|
|
529
|
+
type: TypingLiteral["ChainExpression"] = field(
|
|
530
|
+
default="ChainExpression", init=False
|
|
531
|
+
)
|
|
532
|
+
|
|
533
|
+
|
|
534
|
+
@dataclass
|
|
535
|
+
class NewExpression(Node):
|
|
536
|
+
"""New expression."""
|
|
537
|
+
|
|
538
|
+
callee: Optional["Expression"] = None
|
|
539
|
+
arguments: list[Union["Expression", "SpreadElement"]] = field(default_factory=list)
|
|
540
|
+
type: TypingLiteral["NewExpression"] = field(default="NewExpression", init=False)
|
|
541
|
+
|
|
542
|
+
|
|
543
|
+
@dataclass
|
|
544
|
+
class SequenceExpression(Node):
|
|
545
|
+
"""Sequence expression."""
|
|
546
|
+
|
|
547
|
+
expressions: list["Expression"] = field(default_factory=list)
|
|
548
|
+
type: TypingLiteral["SequenceExpression"] = field(
|
|
549
|
+
default="SequenceExpression", init=False
|
|
550
|
+
)
|
|
551
|
+
|
|
552
|
+
|
|
553
|
+
@dataclass
|
|
554
|
+
class YieldExpression(Node):
|
|
555
|
+
"""Yield expression."""
|
|
556
|
+
|
|
557
|
+
argument: Optional["Expression"] = None
|
|
558
|
+
delegate: bool = False
|
|
559
|
+
type: TypingLiteral["YieldExpression"] = field(
|
|
560
|
+
default="YieldExpression", init=False
|
|
561
|
+
)
|
|
562
|
+
|
|
563
|
+
|
|
564
|
+
@dataclass
|
|
565
|
+
class AwaitExpression(Node):
|
|
566
|
+
"""Await expression (ES2017)."""
|
|
567
|
+
|
|
568
|
+
argument: Optional["Expression"] = None
|
|
569
|
+
type: TypingLiteral["AwaitExpression"] = field(
|
|
570
|
+
default="AwaitExpression", init=False
|
|
571
|
+
)
|
|
572
|
+
|
|
573
|
+
|
|
574
|
+
@dataclass
|
|
575
|
+
class TemplateLiteral(Node):
|
|
576
|
+
"""Template literal (ES6)."""
|
|
577
|
+
|
|
578
|
+
quasis: list["TemplateElement"] = field(default_factory=list)
|
|
579
|
+
expressions: list["Expression"] = field(default_factory=list)
|
|
580
|
+
type: TypingLiteral["TemplateLiteral"] = field(
|
|
581
|
+
default="TemplateLiteral", init=False
|
|
582
|
+
)
|
|
583
|
+
|
|
584
|
+
|
|
585
|
+
@dataclass
|
|
586
|
+
class TemplateElement(Node):
|
|
587
|
+
"""Template element."""
|
|
588
|
+
|
|
589
|
+
tail: bool = False
|
|
590
|
+
value: dict[str, str] = field(default_factory=dict) # {cooked: str, raw: str}
|
|
591
|
+
type: TypingLiteral["TemplateElement"] = field(
|
|
592
|
+
default="TemplateElement", init=False
|
|
593
|
+
)
|
|
594
|
+
|
|
595
|
+
|
|
596
|
+
@dataclass
|
|
597
|
+
class TaggedTemplateExpression(Node):
|
|
598
|
+
"""Tagged template expression (ES6)."""
|
|
599
|
+
|
|
600
|
+
tag: Optional["Expression"] = None
|
|
601
|
+
quasi: Optional[TemplateLiteral] = None
|
|
602
|
+
type: TypingLiteral["TaggedTemplateExpression"] = field(
|
|
603
|
+
default="TaggedTemplateExpression", init=False
|
|
604
|
+
)
|
|
605
|
+
|
|
606
|
+
|
|
607
|
+
@dataclass
|
|
608
|
+
class SpreadElement(Node):
|
|
609
|
+
"""Spread element (ES6)."""
|
|
610
|
+
|
|
611
|
+
argument: Optional["Expression"] = None
|
|
612
|
+
type: TypingLiteral["SpreadElement"] = field(default="SpreadElement", init=False)
|
|
613
|
+
|
|
614
|
+
|
|
615
|
+
@dataclass
|
|
616
|
+
class Super(Node):
|
|
617
|
+
"""Super keyword."""
|
|
618
|
+
|
|
619
|
+
type: TypingLiteral["Super"] = field(default="Super", init=False)
|
|
620
|
+
|
|
621
|
+
|
|
622
|
+
@dataclass
|
|
623
|
+
class MetaProperty(Node):
|
|
624
|
+
"""Meta property (e.g., new.target)."""
|
|
625
|
+
|
|
626
|
+
meta: Optional[Identifier] = None
|
|
627
|
+
property: Optional[Identifier] = None
|
|
628
|
+
type: TypingLiteral["MetaProperty"] = field(default="MetaProperty", init=False)
|
|
629
|
+
|
|
630
|
+
|
|
631
|
+
# Patterns (ES6)
|
|
632
|
+
# ==============
|
|
633
|
+
|
|
634
|
+
|
|
635
|
+
@dataclass
|
|
636
|
+
class AssignmentPattern(Node):
|
|
637
|
+
"""Assignment pattern (default parameters)."""
|
|
638
|
+
|
|
639
|
+
left: Optional["Pattern"] = None
|
|
640
|
+
right: Optional["Expression"] = None
|
|
641
|
+
type: TypingLiteral["AssignmentPattern"] = field(
|
|
642
|
+
default="AssignmentPattern", init=False
|
|
643
|
+
)
|
|
644
|
+
|
|
645
|
+
|
|
646
|
+
@dataclass
|
|
647
|
+
class ArrayPattern(Node):
|
|
648
|
+
"""Array destructuring pattern."""
|
|
649
|
+
|
|
650
|
+
elements: list[Optional["Pattern"]] = field(default_factory=list)
|
|
651
|
+
type: TypingLiteral["ArrayPattern"] = field(default="ArrayPattern", init=False)
|
|
652
|
+
|
|
653
|
+
|
|
654
|
+
@dataclass
|
|
655
|
+
class ObjectPattern(Node):
|
|
656
|
+
"""Object destructuring pattern."""
|
|
657
|
+
|
|
658
|
+
properties: list[Union["AssignmentProperty", "RestElement"]] = field(
|
|
659
|
+
default_factory=list
|
|
660
|
+
)
|
|
661
|
+
type: TypingLiteral["ObjectPattern"] = field(default="ObjectPattern", init=False)
|
|
662
|
+
|
|
663
|
+
|
|
664
|
+
@dataclass
|
|
665
|
+
class AssignmentProperty(Node):
|
|
666
|
+
"""Assignment property in object pattern."""
|
|
667
|
+
|
|
668
|
+
key: Optional[Union["Expression", Identifier, Literal]] = None
|
|
669
|
+
value: Optional["Pattern"] = None
|
|
670
|
+
kind: PropertyKind = "init"
|
|
671
|
+
method: bool = False
|
|
672
|
+
shorthand: bool = False
|
|
673
|
+
computed: bool = False
|
|
674
|
+
type: TypingLiteral["Property"] = field(default="Property", init=False)
|
|
675
|
+
|
|
676
|
+
|
|
677
|
+
@dataclass
|
|
678
|
+
class RestElement(Node):
|
|
679
|
+
"""Rest element."""
|
|
680
|
+
|
|
681
|
+
argument: Optional["Pattern"] = None
|
|
682
|
+
type: TypingLiteral["RestElement"] = field(default="RestElement", init=False)
|
|
683
|
+
|
|
684
|
+
|
|
685
|
+
# Classes (ES6)
|
|
686
|
+
# =============
|
|
687
|
+
|
|
688
|
+
|
|
689
|
+
@dataclass
|
|
690
|
+
class ClassDeclaration(Node):
|
|
691
|
+
"""Class declaration."""
|
|
692
|
+
|
|
693
|
+
id: Optional[Identifier] = None
|
|
694
|
+
superClass: Optional["Expression"] = None # noqa: N815
|
|
695
|
+
body: Optional["ClassBody"] = None
|
|
696
|
+
type: TypingLiteral["ClassDeclaration"] = field(
|
|
697
|
+
default="ClassDeclaration", init=False
|
|
698
|
+
)
|
|
699
|
+
|
|
700
|
+
|
|
701
|
+
@dataclass
|
|
702
|
+
class ClassExpression(Node):
|
|
703
|
+
"""Class expression."""
|
|
704
|
+
|
|
705
|
+
id: Optional[Identifier] = None
|
|
706
|
+
superClass: Optional["Expression"] = None # noqa: N815
|
|
707
|
+
body: Optional["ClassBody"] = None
|
|
708
|
+
type: TypingLiteral["ClassExpression"] = field(
|
|
709
|
+
default="ClassExpression", init=False
|
|
710
|
+
)
|
|
711
|
+
|
|
712
|
+
|
|
713
|
+
@dataclass
|
|
714
|
+
class ClassBody(Node):
|
|
715
|
+
"""Class body (ES2022: supports methods, properties, and static blocks)."""
|
|
716
|
+
|
|
717
|
+
body: list[Union["MethodDefinition", "PropertyDefinition", "StaticBlock"]] = field(
|
|
718
|
+
default_factory=list
|
|
719
|
+
)
|
|
720
|
+
type: TypingLiteral["ClassBody"] = field(default="ClassBody", init=False)
|
|
721
|
+
|
|
722
|
+
|
|
723
|
+
@dataclass
|
|
724
|
+
class MethodDefinition(Node):
|
|
725
|
+
"""Method definition (ES2022: supports private identifiers)."""
|
|
726
|
+
|
|
727
|
+
key: Optional[Union["Expression", Identifier, "PrivateIdentifier"]] = None
|
|
728
|
+
value: Optional[FunctionExpression] = None
|
|
729
|
+
kind: MethodDefinitionKind = "method"
|
|
730
|
+
computed: bool = False
|
|
731
|
+
static: bool = False
|
|
732
|
+
type: TypingLiteral["MethodDefinition"] = field(
|
|
733
|
+
default="MethodDefinition", init=False
|
|
734
|
+
)
|
|
735
|
+
|
|
736
|
+
|
|
737
|
+
@dataclass
|
|
738
|
+
class PropertyDefinition(Node):
|
|
739
|
+
"""Class field definition (ES2022)."""
|
|
740
|
+
|
|
741
|
+
key: Optional[Union["Expression", Identifier, "PrivateIdentifier"]] = None
|
|
742
|
+
value: Optional["Expression"] = None
|
|
743
|
+
computed: bool = False
|
|
744
|
+
static: bool = False
|
|
745
|
+
type: TypingLiteral["PropertyDefinition"] = field(
|
|
746
|
+
default="PropertyDefinition", init=False
|
|
747
|
+
)
|
|
748
|
+
|
|
749
|
+
|
|
750
|
+
@dataclass
|
|
751
|
+
class StaticBlock(Node):
|
|
752
|
+
"""Static initialization block (ES2022)."""
|
|
753
|
+
|
|
754
|
+
body: list["Statement"] = field(default_factory=list)
|
|
755
|
+
type: TypingLiteral["StaticBlock"] = field(default="StaticBlock", init=False)
|
|
756
|
+
|
|
757
|
+
|
|
758
|
+
# Modules (ES6)
|
|
759
|
+
# =============
|
|
760
|
+
|
|
761
|
+
|
|
762
|
+
@dataclass
|
|
763
|
+
class ImportDeclaration(Node):
|
|
764
|
+
"""Import declaration."""
|
|
765
|
+
|
|
766
|
+
specifiers: list[
|
|
767
|
+
Union["ImportSpecifier", "ImportDefaultSpecifier", "ImportNamespaceSpecifier"]
|
|
768
|
+
] = field(default_factory=list)
|
|
769
|
+
source: Optional[Literal] = None
|
|
770
|
+
type: TypingLiteral["ImportDeclaration"] = field(
|
|
771
|
+
default="ImportDeclaration", init=False
|
|
772
|
+
)
|
|
773
|
+
|
|
774
|
+
|
|
775
|
+
@dataclass
|
|
776
|
+
class ImportExpression(Node):
|
|
777
|
+
"""Dynamic import expression (ES2020)."""
|
|
778
|
+
|
|
779
|
+
source: Optional["Expression"] = None
|
|
780
|
+
type: TypingLiteral["ImportExpression"] = field(
|
|
781
|
+
default="ImportExpression", init=False
|
|
782
|
+
)
|
|
783
|
+
|
|
784
|
+
|
|
785
|
+
@dataclass
|
|
786
|
+
class ImportSpecifier(Node):
|
|
787
|
+
"""Import specifier."""
|
|
788
|
+
|
|
789
|
+
imported: Optional[Identifier] = None
|
|
790
|
+
local: Optional[Identifier] = None
|
|
791
|
+
type: TypingLiteral["ImportSpecifier"] = field(
|
|
792
|
+
default="ImportSpecifier", init=False
|
|
793
|
+
)
|
|
794
|
+
|
|
795
|
+
|
|
796
|
+
@dataclass
|
|
797
|
+
class ImportDefaultSpecifier(Node):
|
|
798
|
+
"""Import default specifier."""
|
|
799
|
+
|
|
800
|
+
local: Optional[Identifier] = None
|
|
801
|
+
type: TypingLiteral["ImportDefaultSpecifier"] = field(
|
|
802
|
+
default="ImportDefaultSpecifier", init=False
|
|
803
|
+
)
|
|
804
|
+
|
|
805
|
+
|
|
806
|
+
@dataclass
|
|
807
|
+
class ImportNamespaceSpecifier(Node):
|
|
808
|
+
"""Import namespace specifier."""
|
|
809
|
+
|
|
810
|
+
local: Optional[Identifier] = None
|
|
811
|
+
type: TypingLiteral["ImportNamespaceSpecifier"] = field(
|
|
812
|
+
default="ImportNamespaceSpecifier", init=False
|
|
813
|
+
)
|
|
814
|
+
|
|
815
|
+
|
|
816
|
+
@dataclass
|
|
817
|
+
class ExportNamedDeclaration(Node):
|
|
818
|
+
"""Export named declaration."""
|
|
819
|
+
|
|
820
|
+
declaration: Optional[Union["Declaration", "Expression"]] = None
|
|
821
|
+
specifiers: list["ExportSpecifier"] = field(default_factory=list)
|
|
822
|
+
source: Optional[Literal] = None
|
|
823
|
+
type: TypingLiteral["ExportNamedDeclaration"] = field(
|
|
824
|
+
default="ExportNamedDeclaration", init=False
|
|
825
|
+
)
|
|
826
|
+
|
|
827
|
+
|
|
828
|
+
@dataclass
|
|
829
|
+
class ExportSpecifier(Node):
|
|
830
|
+
"""Export specifier."""
|
|
831
|
+
|
|
832
|
+
exported: Optional[Identifier] = None
|
|
833
|
+
local: Optional[Identifier] = None
|
|
834
|
+
type: TypingLiteral["ExportSpecifier"] = field(
|
|
835
|
+
default="ExportSpecifier", init=False
|
|
836
|
+
)
|
|
837
|
+
|
|
838
|
+
|
|
839
|
+
@dataclass
|
|
840
|
+
class ExportDefaultDeclaration(Node):
|
|
841
|
+
"""Export default declaration."""
|
|
842
|
+
|
|
843
|
+
declaration: Optional[Union["Declaration", "Expression"]] = None
|
|
844
|
+
type: TypingLiteral["ExportDefaultDeclaration"] = field(
|
|
845
|
+
default="ExportDefaultDeclaration", init=False
|
|
846
|
+
)
|
|
847
|
+
|
|
848
|
+
|
|
849
|
+
@dataclass
|
|
850
|
+
class ExportAllDeclaration(Node):
|
|
851
|
+
"""Export all declaration."""
|
|
852
|
+
|
|
853
|
+
source: Optional[Literal] = None
|
|
854
|
+
exported: Optional[Identifier] = None
|
|
855
|
+
type: TypingLiteral["ExportAllDeclaration"] = field(
|
|
856
|
+
default="ExportAllDeclaration", init=False
|
|
857
|
+
)
|
|
858
|
+
|
|
859
|
+
|
|
860
|
+
# Type Aliases for Union Types
|
|
861
|
+
# ============================
|
|
862
|
+
|
|
863
|
+
Statement = Union[
|
|
864
|
+
ExpressionStatement,
|
|
865
|
+
BlockStatement,
|
|
866
|
+
EmptyStatement,
|
|
867
|
+
DebuggerStatement,
|
|
868
|
+
WithStatement,
|
|
869
|
+
ReturnStatement,
|
|
870
|
+
LabeledStatement,
|
|
871
|
+
BreakStatement,
|
|
872
|
+
ContinueStatement,
|
|
873
|
+
IfStatement,
|
|
874
|
+
SwitchStatement,
|
|
875
|
+
ThrowStatement,
|
|
876
|
+
TryStatement,
|
|
877
|
+
WhileStatement,
|
|
878
|
+
DoWhileStatement,
|
|
879
|
+
ForStatement,
|
|
880
|
+
ForInStatement,
|
|
881
|
+
ForOfStatement,
|
|
882
|
+
FunctionDeclaration,
|
|
883
|
+
VariableDeclaration,
|
|
884
|
+
ClassDeclaration,
|
|
885
|
+
]
|
|
886
|
+
|
|
887
|
+
Expression = Union[
|
|
888
|
+
Identifier,
|
|
889
|
+
Literal,
|
|
890
|
+
ThisExpression,
|
|
891
|
+
ArrayExpression,
|
|
892
|
+
ObjectExpression,
|
|
893
|
+
FunctionExpression,
|
|
894
|
+
ArrowFunctionExpression,
|
|
895
|
+
UnaryExpression,
|
|
896
|
+
UpdateExpression,
|
|
897
|
+
BinaryExpression,
|
|
898
|
+
AssignmentExpression,
|
|
899
|
+
LogicalExpression,
|
|
900
|
+
MemberExpression,
|
|
901
|
+
ConditionalExpression,
|
|
902
|
+
CallExpression,
|
|
903
|
+
ChainExpression, # ES2020
|
|
904
|
+
NewExpression,
|
|
905
|
+
SequenceExpression,
|
|
906
|
+
YieldExpression,
|
|
907
|
+
AwaitExpression,
|
|
908
|
+
TemplateLiteral,
|
|
909
|
+
TaggedTemplateExpression,
|
|
910
|
+
ClassExpression,
|
|
911
|
+
ImportExpression, # ES2020
|
|
912
|
+
]
|
|
913
|
+
|
|
914
|
+
Pattern = Union[
|
|
915
|
+
Identifier,
|
|
916
|
+
ArrayPattern,
|
|
917
|
+
ObjectPattern,
|
|
918
|
+
AssignmentPattern,
|
|
919
|
+
RestElement,
|
|
920
|
+
]
|
|
921
|
+
|
|
922
|
+
Declaration = Union[
|
|
923
|
+
FunctionDeclaration,
|
|
924
|
+
VariableDeclaration,
|
|
925
|
+
ClassDeclaration,
|
|
926
|
+
]
|
|
927
|
+
|
|
928
|
+
ModuleDeclaration = Union[
|
|
929
|
+
ImportDeclaration,
|
|
930
|
+
ExportNamedDeclaration,
|
|
931
|
+
ExportDefaultDeclaration,
|
|
932
|
+
ExportAllDeclaration,
|
|
933
|
+
]
|
|
934
|
+
|
|
935
|
+
|
|
936
|
+
# Utility Functions
|
|
937
|
+
# =================
|
|
938
|
+
|
|
939
|
+
|
|
940
|
+
def es_node_to_dict(node: Node) -> dict[str, Any]:
|
|
941
|
+
"""Convert an ESTree node to a dictionary representation."""
|
|
942
|
+
result: dict[str, Any] = {"type": node.type}
|
|
943
|
+
|
|
944
|
+
for key, value in node.__dict__.items():
|
|
945
|
+
if key in ("type", "loc") or value is None:
|
|
946
|
+
continue
|
|
947
|
+
if isinstance(value, Node):
|
|
948
|
+
result[key] = es_node_to_dict(value)
|
|
949
|
+
elif isinstance(value, list):
|
|
950
|
+
result[key] = [
|
|
951
|
+
es_node_to_dict(item) if isinstance(item, Node) else item
|
|
952
|
+
for item in value
|
|
953
|
+
]
|
|
954
|
+
else:
|
|
955
|
+
result[key] = value
|
|
956
|
+
|
|
957
|
+
if node.loc:
|
|
958
|
+
result["loc"] = {
|
|
959
|
+
"source": node.loc.source,
|
|
960
|
+
"start": (
|
|
961
|
+
{"line": node.loc.start.line, "column": node.loc.start.column}
|
|
962
|
+
if node.loc.start
|
|
963
|
+
else None
|
|
964
|
+
),
|
|
965
|
+
"end": (
|
|
966
|
+
{"line": node.loc.end.line, "column": node.loc.end.column}
|
|
967
|
+
if node.loc.end
|
|
968
|
+
else None
|
|
969
|
+
),
|
|
970
|
+
}
|
|
971
|
+
|
|
972
|
+
return result
|