@velarscript/compiler 0.10.1
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.
- package/LICENSE +201 -0
- package/README.md +70 -0
- package/dist/analyzer.d.ts +1175 -0
- package/dist/analyzer.d.ts.map +1 -0
- package/dist/analyzer.js +12130 -0
- package/dist/analyzer.js.map +1 -0
- package/dist/application-package-host.d.ts +28 -0
- package/dist/application-package-host.d.ts.map +1 -0
- package/dist/application-package-host.js +2 -0
- package/dist/application-package-host.js.map +1 -0
- package/dist/ast.d.ts +853 -0
- package/dist/ast.d.ts.map +1 -0
- package/dist/ast.js +245 -0
- package/dist/ast.js.map +1 -0
- package/dist/class-runtime.d.ts +6 -0
- package/dist/class-runtime.d.ts.map +1 -0
- package/dist/class-runtime.js +45 -0
- package/dist/class-runtime.js.map +1 -0
- package/dist/collection-lowering-runtime.d.ts +7 -0
- package/dist/collection-lowering-runtime.d.ts.map +1 -0
- package/dist/collection-lowering-runtime.js +952 -0
- package/dist/collection-lowering-runtime.js.map +1 -0
- package/dist/collection-runtime.d.ts +16 -0
- package/dist/collection-runtime.d.ts.map +1 -0
- package/dist/collection-runtime.js +231 -0
- package/dist/collection-runtime.js.map +1 -0
- package/dist/core-vocabulary.d.ts +141 -0
- package/dist/core-vocabulary.d.ts.map +1 -0
- package/dist/core-vocabulary.js +88 -0
- package/dist/core-vocabulary.js.map +1 -0
- package/dist/diagnostic.d.ts +42 -0
- package/dist/diagnostic.d.ts.map +1 -0
- package/dist/diagnostic.js +66 -0
- package/dist/diagnostic.js.map +1 -0
- package/dist/embedded-javascript.d.ts +74 -0
- package/dist/embedded-javascript.d.ts.map +1 -0
- package/dist/embedded-javascript.js +341 -0
- package/dist/embedded-javascript.js.map +1 -0
- package/dist/embedded-module.d.ts +11 -0
- package/dist/embedded-module.d.ts.map +1 -0
- package/dist/embedded-module.js +67 -0
- package/dist/embedded-module.js.map +1 -0
- package/dist/embedded-source.d.ts +19 -0
- package/dist/embedded-source.d.ts.map +1 -0
- package/dist/embedded-source.js +61 -0
- package/dist/embedded-source.js.map +1 -0
- package/dist/emitter.d.ts +188 -0
- package/dist/emitter.d.ts.map +1 -0
- package/dist/emitter.js +3254 -0
- package/dist/emitter.js.map +1 -0
- package/dist/error-runtime.d.ts +17 -0
- package/dist/error-runtime.d.ts.map +1 -0
- package/dist/error-runtime.js +109 -0
- package/dist/error-runtime.js.map +1 -0
- package/dist/extension.d.ts +373 -0
- package/dist/extension.d.ts.map +1 -0
- package/dist/extension.js +25 -0
- package/dist/extension.js.map +1 -0
- package/dist/formatter.d.ts +13 -0
- package/dist/formatter.d.ts.map +1 -0
- package/dist/formatter.js +1440 -0
- package/dist/formatter.js.map +1 -0
- package/dist/framework-host.d.ts +87 -0
- package/dist/framework-host.d.ts.map +1 -0
- package/dist/framework-host.js +2 -0
- package/dist/framework-host.js.map +1 -0
- package/dist/index.d.ts +75 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +932 -0
- package/dist/index.js.map +1 -0
- package/dist/interpolated-string.d.ts +47 -0
- package/dist/interpolated-string.d.ts.map +1 -0
- package/dist/interpolated-string.js +344 -0
- package/dist/interpolated-string.js.map +1 -0
- package/dist/json-runtime.d.ts +2 -0
- package/dist/json-runtime.d.ts.map +1 -0
- package/dist/json-runtime.js +193 -0
- package/dist/json-runtime.js.map +1 -0
- package/dist/language-guidance.d.ts +31 -0
- package/dist/language-guidance.d.ts.map +1 -0
- package/dist/language-guidance.js +187 -0
- package/dist/language-guidance.js.map +1 -0
- package/dist/lexer.d.ts +85 -0
- package/dist/lexer.d.ts.map +1 -0
- package/dist/lexer.js +1004 -0
- package/dist/lexer.js.map +1 -0
- package/dist/limits.d.ts +2 -0
- package/dist/limits.d.ts.map +1 -0
- package/dist/limits.js +2 -0
- package/dist/limits.js.map +1 -0
- package/dist/mechanical-fix.d.ts +26 -0
- package/dist/mechanical-fix.d.ts.map +1 -0
- package/dist/mechanical-fix.js +61 -0
- package/dist/mechanical-fix.js.map +1 -0
- package/dist/narrowing-runtime.d.ts +5 -0
- package/dist/narrowing-runtime.d.ts.map +1 -0
- package/dist/narrowing-runtime.js +27 -0
- package/dist/narrowing-runtime.js.map +1 -0
- package/dist/number-runtime.d.ts +3 -0
- package/dist/number-runtime.d.ts.map +1 -0
- package/dist/number-runtime.js +37 -0
- package/dist/number-runtime.js.map +1 -0
- package/dist/parser.d.ts +245 -0
- package/dist/parser.d.ts.map +1 -0
- package/dist/parser.js +3582 -0
- package/dist/parser.js.map +1 -0
- package/dist/primitive-runtime.d.ts +4 -0
- package/dist/primitive-runtime.d.ts.map +1 -0
- package/dist/primitive-runtime.js +39 -0
- package/dist/primitive-runtime.js.map +1 -0
- package/dist/promise-runtime.d.ts +6 -0
- package/dist/promise-runtime.d.ts.map +1 -0
- package/dist/promise-runtime.js +86 -0
- package/dist/promise-runtime.js.map +1 -0
- package/dist/reactive-bridge-runtime.d.ts +7 -0
- package/dist/reactive-bridge-runtime.d.ts.map +1 -0
- package/dist/reactive-bridge-runtime.js +112 -0
- package/dist/reactive-bridge-runtime.js.map +1 -0
- package/dist/runtime-abi.d.ts +24 -0
- package/dist/runtime-abi.d.ts.map +1 -0
- package/dist/runtime-abi.js +24 -0
- package/dist/runtime-abi.js.map +1 -0
- package/dist/semantic.d.ts +142 -0
- package/dist/semantic.d.ts.map +1 -0
- package/dist/semantic.js +845 -0
- package/dist/semantic.js.map +1 -0
- package/dist/source-names.d.ts +32 -0
- package/dist/source-names.d.ts.map +1 -0
- package/dist/source-names.js +101 -0
- package/dist/source-names.js.map +1 -0
- package/dist/source.d.ts +19 -0
- package/dist/source.d.ts.map +1 -0
- package/dist/source.js +64 -0
- package/dist/source.js.map +1 -0
- package/dist/text-runtime.d.ts +2 -0
- package/dist/text-runtime.d.ts.map +1 -0
- package/dist/text-runtime.js +285 -0
- package/dist/text-runtime.js.map +1 -0
- package/dist/token.d.ts +19 -0
- package/dist/token.d.ts.map +1 -0
- package/dist/token.js +51 -0
- package/dist/token.js.map +1 -0
- package/dist/type-registry-runtime.d.ts +7 -0
- package/dist/type-registry-runtime.d.ts.map +1 -0
- package/dist/type-registry-runtime.js +51 -0
- package/dist/type-registry-runtime.js.map +1 -0
- package/dist/type-validation-runtime.d.ts +17 -0
- package/dist/type-validation-runtime.d.ts.map +1 -0
- package/dist/type-validation-runtime.js +150 -0
- package/dist/type-validation-runtime.js.map +1 -0
- package/dist/types.d.ts +356 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +1170 -0
- package/dist/types.js.map +1 -0
- package/dist/utf8-runtime.d.ts +7 -0
- package/dist/utf8-runtime.d.ts.map +1 -0
- package/dist/utf8-runtime.js +43 -0
- package/dist/utf8-runtime.js.map +1 -0
- package/package.json +48 -0
package/dist/ast.d.ts
ADDED
|
@@ -0,0 +1,853 @@
|
|
|
1
|
+
import type { Span } from "./source.ts";
|
|
2
|
+
export interface Program {
|
|
3
|
+
readonly kind: "Program";
|
|
4
|
+
readonly body: readonly Statement[];
|
|
5
|
+
readonly span: Span;
|
|
6
|
+
}
|
|
7
|
+
export type CoreStatement = ImportDeclaration | ReExportDeclaration | ExternModuleDeclaration | EmbeddedJavaScriptDeclaration | TypeDeclaration | TypeAliasDeclaration | EnumDeclaration | ClassDeclaration | VariableDeclaration | UsingDeclaration | TestDeclaration | FunctionDeclaration | ReturnStatement | ThrowStatement | AssertStatement | IfStatement | MatchStatement | ForStatement | WhileStatement | BreakStatement | ContinueStatement | TryStatement | PassStatement | AssignmentStatement | ExpressionStatement | AsyncStatement;
|
|
8
|
+
export type Statement = CoreStatement | ExtensionStatement;
|
|
9
|
+
/**
|
|
10
|
+
* D56 rule 129 — every statement form Core's grammar produces, keyed by the
|
|
11
|
+
* node kind the parser returns for it. The string is prose for a failure
|
|
12
|
+
* message; the *keys* are the data.
|
|
13
|
+
*
|
|
14
|
+
* The mapped type is both the derivation and the enforcement: a member added
|
|
15
|
+
* to `CoreStatement` above makes this object stop typechecking until its
|
|
16
|
+
* spelling is written here, so the roster cannot fall behind the union the
|
|
17
|
+
* parser returns. That is the whole reason it lives beside the union instead
|
|
18
|
+
* of in a gate script — D57 rule 134's failure family is the hand-kept copy,
|
|
19
|
+
* and a copy that `tsc` refuses to accept as incomplete is not one.
|
|
20
|
+
*
|
|
21
|
+
* The tour-coverage gate requires every key to be parsed out of
|
|
22
|
+
* `examples/tour/`, and this is the one category of that gate that names a
|
|
23
|
+
* *construct* rather than a *name*. It exists because names were not enough:
|
|
24
|
+
* `extern`, `js`, and `unsafe` were already covered as keywords by chapter 13's
|
|
25
|
+
* `extern module` and `import js unsafe`, so D53 rule 117's two inline blocks —
|
|
26
|
+
* spelled entirely out of keywords the tour already exercised — landed with no
|
|
27
|
+
* tour example at all and the gate stayed green.
|
|
28
|
+
*
|
|
29
|
+
* A node kind that deliberately carries multiple grammar forms contributes a
|
|
30
|
+
* projected key for each form. The AST keeps its semantic fields instead of
|
|
31
|
+
* acquiring redundant tags solely for coverage; this function is the one
|
|
32
|
+
* compiler-owned projection the tour gate reads.
|
|
33
|
+
*/
|
|
34
|
+
export type CoreStatementConstructKey = Exclude<CoreStatement, EmbeddedJavaScriptDeclaration | VariableDeclaration | FunctionDeclaration | ClassDeclaration | ForStatement>["kind"] | "EmbeddedJavaScriptDeclaration:checked" | "EmbeddedJavaScriptDeclaration:unsafe" | `VariableDeclaration:${VariableDeclaration["binding"]}` | `FunctionDeclaration:${"def" | "async-def"}` | `ClassDeclaration:${"class" | "abstract-class"}` | `ForStatement:${"for" | "async-for"}`;
|
|
35
|
+
export declare const CORE_STATEMENT_CONSTRUCTS: Readonly<{
|
|
36
|
+
ImportDeclaration: string;
|
|
37
|
+
ReExportDeclaration: string;
|
|
38
|
+
ExternModuleDeclaration: string;
|
|
39
|
+
"EmbeddedJavaScriptDeclaration:checked": string;
|
|
40
|
+
"EmbeddedJavaScriptDeclaration:unsafe": string;
|
|
41
|
+
TypeDeclaration: string;
|
|
42
|
+
TypeAliasDeclaration: string;
|
|
43
|
+
EnumDeclaration: string;
|
|
44
|
+
"ClassDeclaration:class": string;
|
|
45
|
+
"ClassDeclaration:abstract-class": string;
|
|
46
|
+
"VariableDeclaration:const": string;
|
|
47
|
+
"VariableDeclaration:let": string;
|
|
48
|
+
UsingDeclaration: string;
|
|
49
|
+
TestDeclaration: string;
|
|
50
|
+
"FunctionDeclaration:def": string;
|
|
51
|
+
"FunctionDeclaration:async-def": string;
|
|
52
|
+
ReturnStatement: string;
|
|
53
|
+
ThrowStatement: string;
|
|
54
|
+
AssertStatement: string;
|
|
55
|
+
IfStatement: string;
|
|
56
|
+
MatchStatement: string;
|
|
57
|
+
"ForStatement:for": string;
|
|
58
|
+
"ForStatement:async-for": string;
|
|
59
|
+
WhileStatement: string;
|
|
60
|
+
BreakStatement: string;
|
|
61
|
+
ContinueStatement: string;
|
|
62
|
+
TryStatement: string;
|
|
63
|
+
PassStatement: string;
|
|
64
|
+
AssignmentStatement: string;
|
|
65
|
+
ExpressionStatement: string;
|
|
66
|
+
AsyncStatement: string;
|
|
67
|
+
}>;
|
|
68
|
+
/** The tour key for one Core statement, including every multi-form projection. */
|
|
69
|
+
export declare function coreStatementConstructKey(statement: CoreStatement): CoreStatementConstructKey;
|
|
70
|
+
/**
|
|
71
|
+
* Target and framework syntax travels through one opaque Core AST slot. The
|
|
72
|
+
* template-literal discriminator keeps extension nodes disjoint from Core
|
|
73
|
+
* node names while allowing an extension package to publish its own strongly
|
|
74
|
+
* typed node interfaces without changing this union.
|
|
75
|
+
*/
|
|
76
|
+
export interface ExtensionStatement {
|
|
77
|
+
readonly kind: `ExtensionStatement:${string}`;
|
|
78
|
+
readonly span: Span;
|
|
79
|
+
}
|
|
80
|
+
export interface ImportDeclaration {
|
|
81
|
+
readonly kind: "ImportDeclaration";
|
|
82
|
+
readonly source: string;
|
|
83
|
+
readonly sourceSpan: Span;
|
|
84
|
+
readonly javascript: boolean;
|
|
85
|
+
readonly unsafe: boolean;
|
|
86
|
+
readonly specifiers: readonly ImportSpecifier[];
|
|
87
|
+
readonly span: Span;
|
|
88
|
+
}
|
|
89
|
+
export interface ImportSpecifier {
|
|
90
|
+
readonly imported: string;
|
|
91
|
+
readonly local: string;
|
|
92
|
+
readonly namespace: boolean;
|
|
93
|
+
readonly span: Span;
|
|
94
|
+
}
|
|
95
|
+
export interface ReExportDeclaration {
|
|
96
|
+
readonly kind: "ReExportDeclaration";
|
|
97
|
+
readonly source: string;
|
|
98
|
+
readonly sourceSpan: Span;
|
|
99
|
+
readonly specifiers: readonly ReExportSpecifier[];
|
|
100
|
+
readonly span: Span;
|
|
101
|
+
}
|
|
102
|
+
export interface ReExportSpecifier {
|
|
103
|
+
readonly imported: string;
|
|
104
|
+
readonly exported: string;
|
|
105
|
+
readonly span: Span;
|
|
106
|
+
}
|
|
107
|
+
export interface ExternModuleDeclaration {
|
|
108
|
+
readonly kind: "ExternModuleDeclaration";
|
|
109
|
+
readonly source: string;
|
|
110
|
+
readonly functions: readonly ExternFunctionDeclaration[];
|
|
111
|
+
readonly constants: readonly ExternConstantDeclaration[];
|
|
112
|
+
readonly classes: readonly ExternClassDeclaration[];
|
|
113
|
+
readonly span: Span;
|
|
114
|
+
}
|
|
115
|
+
/** The declaration-shaped half shared by external-module and embedded-JS contracts. */
|
|
116
|
+
export interface ExternModuleContract {
|
|
117
|
+
readonly functions: readonly ExternFunctionDeclaration[];
|
|
118
|
+
readonly constants: readonly ExternConstantDeclaration[];
|
|
119
|
+
readonly classes: readonly ExternClassDeclaration[];
|
|
120
|
+
readonly span: Span;
|
|
121
|
+
}
|
|
122
|
+
/** D53 rule 117: one Core-owned raw JavaScript module embedded in a `.vel` module. */
|
|
123
|
+
interface EmbeddedJavaScriptDeclarationBase {
|
|
124
|
+
readonly kind: "EmbeddedJavaScriptDeclaration";
|
|
125
|
+
/** Checked blocks receive these values as real synchronous factory parameters. */
|
|
126
|
+
readonly captures: readonly EmbeddedJavaScriptCapture[];
|
|
127
|
+
/** Exact, contiguous source slice: `source[i] === moduleText[sourceSpan.start + i]`. */
|
|
128
|
+
readonly source: string;
|
|
129
|
+
readonly sourceSpan: Span;
|
|
130
|
+
/** Every statically named ESM export and the local binding that supplies it. */
|
|
131
|
+
readonly exports: readonly EmbeddedJavaScriptExport[];
|
|
132
|
+
/** Imports stay at sibling-module top level when a checked block becomes a factory. */
|
|
133
|
+
readonly imports: readonly EmbeddedJavaScriptImport[];
|
|
134
|
+
/** Literal ESM sources the project resolver must validate before emission. */
|
|
135
|
+
readonly dependencies: readonly EmbeddedJavaScriptDependency[];
|
|
136
|
+
/** All module-level JS bindings; capture parameters may not shadow them. */
|
|
137
|
+
readonly bindings: readonly EmbeddedJavaScriptBinding[];
|
|
138
|
+
/** Acorn-derived source edits; no JavaScript is rediscovered with text matching. */
|
|
139
|
+
readonly factoryEdits: readonly EmbeddedJavaScriptFactoryEdit[];
|
|
140
|
+
readonly span: Span;
|
|
141
|
+
}
|
|
142
|
+
export interface CheckedEmbeddedJavaScriptDeclaration extends EmbeddedJavaScriptDeclarationBase {
|
|
143
|
+
readonly form: "checked";
|
|
144
|
+
readonly unsafe: false;
|
|
145
|
+
readonly contract: ExternModuleContract;
|
|
146
|
+
}
|
|
147
|
+
export interface UnsafeEmbeddedJavaScriptDeclaration extends EmbeddedJavaScriptDeclarationBase {
|
|
148
|
+
readonly form: "unsafe";
|
|
149
|
+
readonly unsafe: true;
|
|
150
|
+
readonly contract: null;
|
|
151
|
+
}
|
|
152
|
+
export type EmbeddedJavaScriptDeclaration = CheckedEmbeddedJavaScriptDeclaration | UnsafeEmbeddedJavaScriptDeclaration;
|
|
153
|
+
export interface EmbeddedJavaScriptCapture {
|
|
154
|
+
readonly name: string;
|
|
155
|
+
readonly nameSpan: Span;
|
|
156
|
+
readonly type: TypeReference;
|
|
157
|
+
readonly span: Span;
|
|
158
|
+
}
|
|
159
|
+
export interface EmbeddedJavaScriptExport {
|
|
160
|
+
readonly name: string;
|
|
161
|
+
readonly nameSpan: Span;
|
|
162
|
+
readonly local: string;
|
|
163
|
+
readonly localSpan: Span;
|
|
164
|
+
}
|
|
165
|
+
export interface EmbeddedJavaScriptImport {
|
|
166
|
+
readonly span: Span;
|
|
167
|
+
}
|
|
168
|
+
export interface EmbeddedJavaScriptDependency {
|
|
169
|
+
readonly source: string;
|
|
170
|
+
readonly span: Span;
|
|
171
|
+
readonly dynamic: boolean;
|
|
172
|
+
}
|
|
173
|
+
export interface EmbeddedJavaScriptBinding {
|
|
174
|
+
readonly name: string;
|
|
175
|
+
readonly nameSpan: Span;
|
|
176
|
+
}
|
|
177
|
+
export interface EmbeddedJavaScriptFactoryEdit {
|
|
178
|
+
readonly span: Span;
|
|
179
|
+
readonly replacement: string;
|
|
180
|
+
}
|
|
181
|
+
export interface ExternFunctionDeclaration {
|
|
182
|
+
readonly asynchronous: boolean;
|
|
183
|
+
readonly name: string;
|
|
184
|
+
readonly typeParameters?: readonly TypeParameterDeclaration[];
|
|
185
|
+
readonly parameters: readonly Parameter[];
|
|
186
|
+
readonly returnType: TypeReference | null;
|
|
187
|
+
readonly signatureSpan: Span;
|
|
188
|
+
readonly span: Span;
|
|
189
|
+
}
|
|
190
|
+
export interface ExternConstantDeclaration {
|
|
191
|
+
readonly name: string;
|
|
192
|
+
readonly type: TypeReference;
|
|
193
|
+
readonly span: Span;
|
|
194
|
+
}
|
|
195
|
+
export interface ExternClassDeclaration {
|
|
196
|
+
readonly name: string;
|
|
197
|
+
readonly parameters: readonly ClassParameter[];
|
|
198
|
+
readonly base: string | null;
|
|
199
|
+
readonly fields: readonly ExternClassFieldDeclaration[];
|
|
200
|
+
readonly getters: readonly ExternClassGetterDeclaration[];
|
|
201
|
+
readonly methods: readonly ExternClassMethodDeclaration[];
|
|
202
|
+
readonly span: Span;
|
|
203
|
+
}
|
|
204
|
+
export interface ExternClassFieldDeclaration {
|
|
205
|
+
readonly static: boolean;
|
|
206
|
+
readonly mutable: boolean;
|
|
207
|
+
readonly name: string;
|
|
208
|
+
readonly type: TypeReference;
|
|
209
|
+
readonly span: Span;
|
|
210
|
+
}
|
|
211
|
+
export interface ExternClassMethodDeclaration extends ExternFunctionDeclaration {
|
|
212
|
+
readonly static: boolean;
|
|
213
|
+
}
|
|
214
|
+
export interface ExternClassGetterDeclaration {
|
|
215
|
+
readonly static: boolean;
|
|
216
|
+
readonly name: string;
|
|
217
|
+
readonly type: TypeReference;
|
|
218
|
+
readonly span: Span;
|
|
219
|
+
}
|
|
220
|
+
export interface AssertStatement {
|
|
221
|
+
readonly kind: "AssertStatement";
|
|
222
|
+
readonly condition: Expression;
|
|
223
|
+
readonly message: Expression | null;
|
|
224
|
+
readonly span: Span;
|
|
225
|
+
}
|
|
226
|
+
export interface TypeDeclaration {
|
|
227
|
+
readonly kind: "TypeDeclaration";
|
|
228
|
+
readonly exported: boolean;
|
|
229
|
+
readonly name: string;
|
|
230
|
+
/** D55 rule 120: `type Box<T>` / `type Box<T: Data>`, the same list `def` takes. */
|
|
231
|
+
readonly typeParameters?: readonly TypeParameterDeclaration[];
|
|
232
|
+
readonly fields: readonly TypeField[];
|
|
233
|
+
readonly span: Span;
|
|
234
|
+
}
|
|
235
|
+
export interface TypeAliasDeclaration {
|
|
236
|
+
readonly kind: "TypeAliasDeclaration";
|
|
237
|
+
readonly exported: boolean;
|
|
238
|
+
readonly name: string;
|
|
239
|
+
readonly target: TypeReference;
|
|
240
|
+
readonly span: Span;
|
|
241
|
+
}
|
|
242
|
+
export interface TypeField {
|
|
243
|
+
readonly readonly: boolean;
|
|
244
|
+
readonly name: string;
|
|
245
|
+
readonly type: TypeReference;
|
|
246
|
+
readonly span: Span;
|
|
247
|
+
}
|
|
248
|
+
export interface EnumDeclaration {
|
|
249
|
+
readonly kind: "EnumDeclaration";
|
|
250
|
+
readonly exported: boolean;
|
|
251
|
+
readonly name: string;
|
|
252
|
+
readonly members: readonly EnumMember[];
|
|
253
|
+
readonly span: Span;
|
|
254
|
+
}
|
|
255
|
+
export interface EnumMember {
|
|
256
|
+
readonly name: string;
|
|
257
|
+
/** Runtime string value. Defaults to `name` when no explicit value is written. */
|
|
258
|
+
readonly value: string;
|
|
259
|
+
readonly valueSpan?: Span;
|
|
260
|
+
readonly span: Span;
|
|
261
|
+
}
|
|
262
|
+
export interface ClassDeclaration {
|
|
263
|
+
readonly kind: "ClassDeclaration";
|
|
264
|
+
readonly exported: boolean;
|
|
265
|
+
readonly abstract: boolean;
|
|
266
|
+
readonly name: string;
|
|
267
|
+
readonly parameters: readonly ClassParameter[];
|
|
268
|
+
readonly base: ClassBase | null;
|
|
269
|
+
readonly fields: readonly ClassFieldDeclaration[];
|
|
270
|
+
readonly initialization: ClassInitBlock | null;
|
|
271
|
+
readonly getters: readonly ClassGetterDeclaration[];
|
|
272
|
+
readonly methods: readonly ClassMethodDeclaration[];
|
|
273
|
+
/** D43 item 69: the compiler-known `@dispose:` release contract, if declared. */
|
|
274
|
+
readonly dispose: ClassDisposeBlock | null;
|
|
275
|
+
/** D68 rule 177: the compiler-known `@iterate:` iteration contract, if declared. */
|
|
276
|
+
readonly iterate: ClassIterateBlock | null;
|
|
277
|
+
readonly span: Span;
|
|
278
|
+
}
|
|
279
|
+
/**
|
|
280
|
+
* D43 item 69: `@dispose:` is a compiler-known class member, not a method. It
|
|
281
|
+
* cannot be called from source — it is the ownership contract `using` runs, and
|
|
282
|
+
* a second spelling of `close()` is exactly what it exists to avoid.
|
|
283
|
+
*/
|
|
284
|
+
export interface ClassDisposeBlock {
|
|
285
|
+
readonly kind: "ClassDisposeBlock";
|
|
286
|
+
readonly body: readonly Statement[];
|
|
287
|
+
readonly keywordSpan: Span;
|
|
288
|
+
readonly span: Span;
|
|
289
|
+
}
|
|
290
|
+
/**
|
|
291
|
+
* D68 rule 177: `@iterate:` is the second compiler-known class member, and it
|
|
292
|
+
* carries `@dispose:`'s shape for the same reason — it is a question the
|
|
293
|
+
* language asks the type ("what does iterating you mean?"), not a method the
|
|
294
|
+
* author publishes, so it cannot be called from source either. It answers with
|
|
295
|
+
* a List, Set, Map, or Record the language already knows how to iterate; no
|
|
296
|
+
* iterator protocol enters the language (charter section 19 stands).
|
|
297
|
+
*/
|
|
298
|
+
export interface ClassIterateBlock {
|
|
299
|
+
readonly kind: "ClassIterateBlock";
|
|
300
|
+
readonly body: readonly Statement[];
|
|
301
|
+
readonly keywordSpan: Span;
|
|
302
|
+
readonly span: Span;
|
|
303
|
+
}
|
|
304
|
+
export interface ClassInitBlock {
|
|
305
|
+
readonly kind: "ClassInitBlock";
|
|
306
|
+
readonly body: readonly Statement[];
|
|
307
|
+
readonly span: Span;
|
|
308
|
+
}
|
|
309
|
+
export interface ClassBase {
|
|
310
|
+
readonly name: string;
|
|
311
|
+
readonly arguments: readonly Expression[];
|
|
312
|
+
readonly span: Span;
|
|
313
|
+
}
|
|
314
|
+
export interface ClassMethodDeclaration extends FunctionDeclaration {
|
|
315
|
+
readonly abstract: boolean;
|
|
316
|
+
readonly override: boolean;
|
|
317
|
+
readonly static: boolean;
|
|
318
|
+
readonly private: boolean;
|
|
319
|
+
}
|
|
320
|
+
export interface ClassGetterDeclaration extends FunctionDeclaration {
|
|
321
|
+
readonly accessor: true;
|
|
322
|
+
readonly abstract: boolean;
|
|
323
|
+
readonly override: boolean;
|
|
324
|
+
readonly static: boolean;
|
|
325
|
+
readonly private: boolean;
|
|
326
|
+
}
|
|
327
|
+
export interface ClassFieldDeclaration {
|
|
328
|
+
readonly binding: "const" | "let";
|
|
329
|
+
readonly static: boolean;
|
|
330
|
+
readonly private: boolean;
|
|
331
|
+
readonly name: string;
|
|
332
|
+
readonly type: TypeReference;
|
|
333
|
+
readonly initializer: Expression | null;
|
|
334
|
+
readonly span: Span;
|
|
335
|
+
}
|
|
336
|
+
export interface ClassParameter extends Parameter {
|
|
337
|
+
readonly binding: "const" | "let" | null;
|
|
338
|
+
readonly private: boolean;
|
|
339
|
+
}
|
|
340
|
+
export interface VariableDeclaration {
|
|
341
|
+
readonly kind: "VariableDeclaration";
|
|
342
|
+
readonly binding: "const" | "let";
|
|
343
|
+
readonly exported: boolean;
|
|
344
|
+
readonly pattern: BindingPattern;
|
|
345
|
+
readonly type: TypeReference | null;
|
|
346
|
+
readonly initializer: Expression;
|
|
347
|
+
readonly span: Span;
|
|
348
|
+
}
|
|
349
|
+
/**
|
|
350
|
+
* D43 item 69: `using name = expression` takes ownership of a resource for the
|
|
351
|
+
* enclosing scope. The binding is const, and every exit from the scope —
|
|
352
|
+
* normal, `return`, `break`, `continue`, or a throw — releases it through its
|
|
353
|
+
* type's `@dispose` contract, in reverse declaration order.
|
|
354
|
+
*/
|
|
355
|
+
export interface UsingDeclaration {
|
|
356
|
+
readonly kind: "UsingDeclaration";
|
|
357
|
+
readonly name: string;
|
|
358
|
+
readonly nameSpan: Span;
|
|
359
|
+
readonly initializer: Expression;
|
|
360
|
+
readonly span: Span;
|
|
361
|
+
}
|
|
362
|
+
/**
|
|
363
|
+
* D39 item 53: `test "name":` declares one test. The name is a string literal
|
|
364
|
+
* the reporter quotes verbatim, because a test is the product specification a
|
|
365
|
+
* human reads, not a machine-shaped function name.
|
|
366
|
+
*/
|
|
367
|
+
export interface TestDeclaration {
|
|
368
|
+
readonly kind: "TestDeclaration";
|
|
369
|
+
readonly title: string;
|
|
370
|
+
readonly titleSpan: Span;
|
|
371
|
+
readonly body: readonly Statement[];
|
|
372
|
+
readonly span: Span;
|
|
373
|
+
}
|
|
374
|
+
/** The generated function name a `test "name":` block emits and the runner calls. */
|
|
375
|
+
export declare function testFunctionName(statement: TestDeclaration): string;
|
|
376
|
+
export type BindingPattern = NameBindingPattern | ObjectBindingPattern | ListBindingPattern;
|
|
377
|
+
export interface NameBindingPattern {
|
|
378
|
+
readonly kind: "NameBindingPattern";
|
|
379
|
+
readonly name: string;
|
|
380
|
+
readonly span: Span;
|
|
381
|
+
}
|
|
382
|
+
export interface ObjectBindingPattern {
|
|
383
|
+
readonly kind: "ObjectBindingPattern";
|
|
384
|
+
readonly entries: readonly ObjectBindingEntry[];
|
|
385
|
+
readonly rest: NameBindingPattern | null;
|
|
386
|
+
readonly span: Span;
|
|
387
|
+
}
|
|
388
|
+
export interface ObjectBindingEntry {
|
|
389
|
+
readonly property: string;
|
|
390
|
+
readonly pattern: BindingPattern;
|
|
391
|
+
readonly span: Span;
|
|
392
|
+
}
|
|
393
|
+
export interface ListBindingPattern {
|
|
394
|
+
readonly kind: "ListBindingPattern";
|
|
395
|
+
readonly elements: readonly (BindingPattern | null)[];
|
|
396
|
+
readonly rest: NameBindingPattern | null;
|
|
397
|
+
readonly span: Span;
|
|
398
|
+
}
|
|
399
|
+
export interface FunctionDeclaration {
|
|
400
|
+
readonly kind: "FunctionDeclaration";
|
|
401
|
+
readonly exported: boolean;
|
|
402
|
+
readonly asynchronous: boolean;
|
|
403
|
+
readonly name: string;
|
|
404
|
+
readonly typeParameters?: readonly TypeParameterDeclaration[];
|
|
405
|
+
readonly parameters: readonly Parameter[];
|
|
406
|
+
readonly returnType: TypeReference | null;
|
|
407
|
+
/**
|
|
408
|
+
* The written result annotation together with the `->` and the space before
|
|
409
|
+
* it — exactly the text a deletion removes, running from the end of the
|
|
410
|
+
* parameter list to the end of the annotation. Present only where a result
|
|
411
|
+
* was written after a parameter list, which is what makes the D58 rule 139
|
|
412
|
+
* removal of an inferred `-> null` a mechanical fix.
|
|
413
|
+
*/
|
|
414
|
+
readonly resultAnnotationSpan?: Span;
|
|
415
|
+
readonly signatureSpan: Span;
|
|
416
|
+
readonly body: readonly Statement[];
|
|
417
|
+
readonly span: Span;
|
|
418
|
+
}
|
|
419
|
+
export interface TypeParameterDeclaration {
|
|
420
|
+
readonly name: string;
|
|
421
|
+
/** The bound written as `<T: Text>`; always a name from the closed vocabulary. */
|
|
422
|
+
readonly bound?: string;
|
|
423
|
+
readonly boundSpan?: Span;
|
|
424
|
+
readonly span: Span;
|
|
425
|
+
}
|
|
426
|
+
export interface Parameter {
|
|
427
|
+
readonly name: string;
|
|
428
|
+
readonly type: TypeReference | null;
|
|
429
|
+
readonly defaultValue: Expression | null;
|
|
430
|
+
readonly rest: boolean;
|
|
431
|
+
readonly span: Span;
|
|
432
|
+
}
|
|
433
|
+
export interface TypeReference {
|
|
434
|
+
readonly syntax: TypeSyntax;
|
|
435
|
+
readonly span: Span;
|
|
436
|
+
}
|
|
437
|
+
export type TypeSyntax = NamedTypeSyntax | EnumMemberTypeSyntax | GenericTypeSyntax | ReadonlyTypeSyntax | OptionalTypeSyntax | UnionTypeSyntax | FunctionTypeSyntax;
|
|
438
|
+
export interface NamedTypeSyntax {
|
|
439
|
+
readonly kind: "NamedTypeSyntax";
|
|
440
|
+
readonly name: string;
|
|
441
|
+
readonly span: Span;
|
|
442
|
+
}
|
|
443
|
+
export interface EnumMemberTypeSyntax {
|
|
444
|
+
readonly kind: "EnumMemberTypeSyntax";
|
|
445
|
+
readonly enumName: string;
|
|
446
|
+
readonly enumNameSpan: Span;
|
|
447
|
+
readonly member: string;
|
|
448
|
+
readonly memberSpan: Span;
|
|
449
|
+
readonly span: Span;
|
|
450
|
+
}
|
|
451
|
+
export interface GenericTypeSyntax {
|
|
452
|
+
readonly kind: "GenericTypeSyntax";
|
|
453
|
+
readonly name: string;
|
|
454
|
+
readonly nameSpan: Span;
|
|
455
|
+
readonly arguments: readonly TypeSyntax[];
|
|
456
|
+
readonly span: Span;
|
|
457
|
+
}
|
|
458
|
+
export interface ReadonlyTypeSyntax {
|
|
459
|
+
readonly kind: "ReadonlyTypeSyntax";
|
|
460
|
+
readonly inner: TypeSyntax;
|
|
461
|
+
readonly span: Span;
|
|
462
|
+
}
|
|
463
|
+
export interface OptionalTypeSyntax {
|
|
464
|
+
readonly kind: "OptionalTypeSyntax";
|
|
465
|
+
readonly inner: TypeSyntax;
|
|
466
|
+
readonly span: Span;
|
|
467
|
+
}
|
|
468
|
+
export interface UnionTypeSyntax {
|
|
469
|
+
readonly kind: "UnionTypeSyntax";
|
|
470
|
+
readonly members: readonly TypeSyntax[];
|
|
471
|
+
readonly span: Span;
|
|
472
|
+
}
|
|
473
|
+
export interface FunctionTypeSyntax {
|
|
474
|
+
readonly kind: "FunctionTypeSyntax";
|
|
475
|
+
readonly parameters: readonly FunctionTypeParameterSyntax[];
|
|
476
|
+
readonly result: TypeSyntax;
|
|
477
|
+
readonly span: Span;
|
|
478
|
+
}
|
|
479
|
+
export interface FunctionTypeParameterSyntax {
|
|
480
|
+
readonly name: string | null;
|
|
481
|
+
readonly type: TypeSyntax;
|
|
482
|
+
readonly rest: boolean;
|
|
483
|
+
readonly optional: boolean;
|
|
484
|
+
readonly span: Span;
|
|
485
|
+
}
|
|
486
|
+
export interface ReturnStatement {
|
|
487
|
+
readonly kind: "ReturnStatement";
|
|
488
|
+
readonly value: Expression | null;
|
|
489
|
+
readonly span: Span;
|
|
490
|
+
}
|
|
491
|
+
export interface ThrowStatement {
|
|
492
|
+
readonly kind: "ThrowStatement";
|
|
493
|
+
readonly value: Expression;
|
|
494
|
+
readonly span: Span;
|
|
495
|
+
}
|
|
496
|
+
export interface IfStatement {
|
|
497
|
+
readonly kind: "IfStatement";
|
|
498
|
+
readonly condition: Expression;
|
|
499
|
+
readonly thenBody: readonly Statement[];
|
|
500
|
+
readonly elseBody: readonly Statement[] | null;
|
|
501
|
+
readonly span: Span;
|
|
502
|
+
}
|
|
503
|
+
export interface MatchStatement {
|
|
504
|
+
readonly kind: "MatchStatement";
|
|
505
|
+
readonly value: Expression;
|
|
506
|
+
readonly cases: readonly MatchCase[];
|
|
507
|
+
readonly span: Span;
|
|
508
|
+
}
|
|
509
|
+
export interface MatchCase {
|
|
510
|
+
readonly pattern: MatchPattern;
|
|
511
|
+
readonly guard: Expression | null;
|
|
512
|
+
readonly body: readonly Statement[];
|
|
513
|
+
readonly span: Span;
|
|
514
|
+
}
|
|
515
|
+
export type MatchPattern = MatchValuePattern | MatchTypePattern | MatchObjectPattern | MatchListPattern | MatchWildcardPattern | MatchCapturePattern | MatchAsPattern;
|
|
516
|
+
export interface MatchValuePattern {
|
|
517
|
+
readonly kind: "MatchValuePattern";
|
|
518
|
+
readonly values: readonly MatchValue[];
|
|
519
|
+
readonly span: Span;
|
|
520
|
+
}
|
|
521
|
+
export interface MatchTypePattern {
|
|
522
|
+
readonly kind: "MatchTypePattern";
|
|
523
|
+
readonly type: TypeReference;
|
|
524
|
+
readonly span: Span;
|
|
525
|
+
}
|
|
526
|
+
export interface MatchObjectPattern {
|
|
527
|
+
readonly kind: "MatchObjectPattern";
|
|
528
|
+
readonly entries: readonly MatchObjectEntry[];
|
|
529
|
+
readonly rest: MatchBinding | null;
|
|
530
|
+
readonly span: Span;
|
|
531
|
+
}
|
|
532
|
+
export interface MatchObjectEntry {
|
|
533
|
+
readonly property: string;
|
|
534
|
+
readonly pattern: MatchPattern;
|
|
535
|
+
readonly span: Span;
|
|
536
|
+
}
|
|
537
|
+
export interface MatchListPattern {
|
|
538
|
+
readonly kind: "MatchListPattern";
|
|
539
|
+
readonly elements: readonly MatchPattern[];
|
|
540
|
+
readonly rest: MatchBinding | null;
|
|
541
|
+
readonly span: Span;
|
|
542
|
+
}
|
|
543
|
+
export interface MatchWildcardPattern {
|
|
544
|
+
readonly kind: "MatchWildcardPattern";
|
|
545
|
+
readonly span: Span;
|
|
546
|
+
}
|
|
547
|
+
export interface MatchCapturePattern {
|
|
548
|
+
readonly kind: "MatchCapturePattern";
|
|
549
|
+
readonly binding: MatchBinding;
|
|
550
|
+
readonly span: Span;
|
|
551
|
+
}
|
|
552
|
+
export interface MatchAsPattern {
|
|
553
|
+
readonly kind: "MatchAsPattern";
|
|
554
|
+
readonly pattern: MatchPattern;
|
|
555
|
+
readonly binding: MatchBinding;
|
|
556
|
+
readonly span: Span;
|
|
557
|
+
}
|
|
558
|
+
export interface MatchBinding {
|
|
559
|
+
readonly name: string;
|
|
560
|
+
readonly span: Span;
|
|
561
|
+
}
|
|
562
|
+
export type MatchValue = LiteralExpression | MemberExpression;
|
|
563
|
+
export interface ForStatement {
|
|
564
|
+
readonly kind: "ForStatement";
|
|
565
|
+
readonly asynchronous: boolean;
|
|
566
|
+
readonly pattern: BindingPattern;
|
|
567
|
+
readonly secondPattern: BindingPattern | null;
|
|
568
|
+
readonly iterable: Expression;
|
|
569
|
+
readonly body: readonly Statement[];
|
|
570
|
+
readonly span: Span;
|
|
571
|
+
}
|
|
572
|
+
export interface WhileStatement {
|
|
573
|
+
readonly kind: "WhileStatement";
|
|
574
|
+
readonly condition: Expression;
|
|
575
|
+
readonly body: readonly Statement[];
|
|
576
|
+
readonly span: Span;
|
|
577
|
+
}
|
|
578
|
+
export interface BreakStatement {
|
|
579
|
+
readonly kind: "BreakStatement";
|
|
580
|
+
readonly span: Span;
|
|
581
|
+
}
|
|
582
|
+
export interface ContinueStatement {
|
|
583
|
+
readonly kind: "ContinueStatement";
|
|
584
|
+
readonly span: Span;
|
|
585
|
+
}
|
|
586
|
+
export interface TryStatement {
|
|
587
|
+
readonly kind: "TryStatement";
|
|
588
|
+
readonly tryBody: readonly Statement[];
|
|
589
|
+
readonly catchName: string | null;
|
|
590
|
+
readonly catchBody: readonly Statement[] | null;
|
|
591
|
+
readonly finallyBody: readonly Statement[] | null;
|
|
592
|
+
readonly span: Span;
|
|
593
|
+
}
|
|
594
|
+
export interface PassStatement {
|
|
595
|
+
readonly kind: "PassStatement";
|
|
596
|
+
readonly span: Span;
|
|
597
|
+
}
|
|
598
|
+
export interface AssignmentStatement {
|
|
599
|
+
readonly kind: "AssignmentStatement";
|
|
600
|
+
readonly target: AssignmentTarget;
|
|
601
|
+
readonly operator: "=" | "+=" | "-=" | "*=" | "/=" | "%=" | "|=" | "&=" | "^=" | "<<=" | ">>=" | ">>>=";
|
|
602
|
+
readonly value: Expression;
|
|
603
|
+
readonly span: Span;
|
|
604
|
+
}
|
|
605
|
+
export type AssignmentTarget = IdentifierExpression | MemberExpression | IndexExpression;
|
|
606
|
+
export interface ExpressionStatement {
|
|
607
|
+
readonly kind: "ExpressionStatement";
|
|
608
|
+
readonly expression: Expression;
|
|
609
|
+
readonly span: Span;
|
|
610
|
+
}
|
|
611
|
+
/**
|
|
612
|
+
* `async <expression>` runs a `Promise<null>` expression detached: the
|
|
613
|
+
* statement does not wait, and the emitter hands the Promise to a
|
|
614
|
+
* compiler-owned observer that reports rejection through the host error
|
|
615
|
+
* channel instead of letting it float.
|
|
616
|
+
*/
|
|
617
|
+
export interface AsyncStatement {
|
|
618
|
+
readonly kind: "AsyncStatement";
|
|
619
|
+
readonly expression: Expression;
|
|
620
|
+
readonly span: Span;
|
|
621
|
+
}
|
|
622
|
+
export type CoreExpression = LiteralExpression | FStringExpression | IdentifierExpression | SuperExpression | DynamicImportExpression | ListExpression | ObjectExpression | SpreadExpression | UnaryExpression | TryExpression | BinaryExpression | AssignmentExpression | ComparisonChainExpression | ConditionalExpression | IsExpression | ArrowFunctionExpression | CallExpression | MemberExpression | IndexExpression | CoreDurationExpression;
|
|
623
|
+
/** D79 rule 199: Core's duration literal is a declared AST node, not a cast. */
|
|
624
|
+
export interface CoreDurationExpression {
|
|
625
|
+
readonly kind: "ExtensionExpression:core:duration";
|
|
626
|
+
readonly value: number;
|
|
627
|
+
readonly unit: "ms" | "s";
|
|
628
|
+
readonly raw: string;
|
|
629
|
+
readonly span: Span;
|
|
630
|
+
}
|
|
631
|
+
/** D82 rule 203: a mapped roster makes every Core expression kind explicit. */
|
|
632
|
+
export declare const CORE_EXPRESSION_CONSTRUCTS: Readonly<{
|
|
633
|
+
LiteralExpression: string;
|
|
634
|
+
FStringExpression: string;
|
|
635
|
+
IdentifierExpression: string;
|
|
636
|
+
SuperExpression: string;
|
|
637
|
+
DynamicImportExpression: string;
|
|
638
|
+
ListExpression: string;
|
|
639
|
+
ObjectExpression: string;
|
|
640
|
+
SpreadExpression: string;
|
|
641
|
+
UnaryExpression: string;
|
|
642
|
+
TryExpression: string;
|
|
643
|
+
BinaryExpression: string;
|
|
644
|
+
AssignmentExpression: string;
|
|
645
|
+
ComparisonChainExpression: string;
|
|
646
|
+
ConditionalExpression: string;
|
|
647
|
+
IsExpression: string;
|
|
648
|
+
ArrowFunctionExpression: string;
|
|
649
|
+
CallExpression: string;
|
|
650
|
+
MemberExpression: string;
|
|
651
|
+
IndexExpression: string;
|
|
652
|
+
"ExtensionExpression:core:duration": string;
|
|
653
|
+
}>;
|
|
654
|
+
export type Expression = CoreExpression | ExtensionExpression;
|
|
655
|
+
/** See ExtensionStatement. */
|
|
656
|
+
export interface ExtensionExpression {
|
|
657
|
+
readonly kind: `ExtensionExpression:${string}`;
|
|
658
|
+
readonly span: Span;
|
|
659
|
+
}
|
|
660
|
+
export interface LiteralExpression {
|
|
661
|
+
readonly kind: "LiteralExpression";
|
|
662
|
+
readonly value: string | number | boolean | null;
|
|
663
|
+
readonly raw: string;
|
|
664
|
+
readonly span: Span;
|
|
665
|
+
}
|
|
666
|
+
export interface FStringExpression {
|
|
667
|
+
readonly kind: "FStringExpression";
|
|
668
|
+
readonly parts: readonly FStringPart[];
|
|
669
|
+
readonly span: Span;
|
|
670
|
+
}
|
|
671
|
+
export type FStringPart = {
|
|
672
|
+
readonly kind: "text";
|
|
673
|
+
readonly value: string;
|
|
674
|
+
} | {
|
|
675
|
+
readonly kind: "expression";
|
|
676
|
+
readonly value: Expression;
|
|
677
|
+
};
|
|
678
|
+
export interface IdentifierExpression {
|
|
679
|
+
readonly kind: "IdentifierExpression";
|
|
680
|
+
readonly name: string;
|
|
681
|
+
readonly span: Span;
|
|
682
|
+
}
|
|
683
|
+
export interface SuperExpression {
|
|
684
|
+
readonly kind: "SuperExpression";
|
|
685
|
+
readonly span: Span;
|
|
686
|
+
}
|
|
687
|
+
export interface DynamicImportExpression {
|
|
688
|
+
readonly kind: "DynamicImportExpression";
|
|
689
|
+
readonly source: string;
|
|
690
|
+
readonly sourceSpan: Span;
|
|
691
|
+
readonly span: Span;
|
|
692
|
+
}
|
|
693
|
+
export interface ListExpression {
|
|
694
|
+
readonly kind: "ListExpression";
|
|
695
|
+
readonly elements: readonly Expression[];
|
|
696
|
+
readonly span: Span;
|
|
697
|
+
}
|
|
698
|
+
export interface ObjectExpression {
|
|
699
|
+
readonly kind: "ObjectExpression";
|
|
700
|
+
readonly properties: readonly ObjectEntry[];
|
|
701
|
+
readonly span: Span;
|
|
702
|
+
}
|
|
703
|
+
export type ObjectEntry = ObjectProperty | ObjectSpread;
|
|
704
|
+
export interface ObjectProperty {
|
|
705
|
+
readonly kind: "ObjectProperty";
|
|
706
|
+
readonly name: string;
|
|
707
|
+
readonly value: Expression;
|
|
708
|
+
/** Written as `{name}`: the field name and the binding it reads are one word. */
|
|
709
|
+
readonly shorthand?: boolean;
|
|
710
|
+
readonly span: Span;
|
|
711
|
+
}
|
|
712
|
+
export interface ObjectSpread {
|
|
713
|
+
readonly kind: "ObjectSpread";
|
|
714
|
+
readonly value: Expression;
|
|
715
|
+
readonly span: Span;
|
|
716
|
+
}
|
|
717
|
+
export interface SpreadExpression {
|
|
718
|
+
readonly kind: "SpreadExpression";
|
|
719
|
+
readonly value: Expression;
|
|
720
|
+
readonly span: Span;
|
|
721
|
+
}
|
|
722
|
+
export interface UnaryExpression {
|
|
723
|
+
readonly kind: "UnaryExpression";
|
|
724
|
+
readonly operator: "not" | "+" | "-" | "~" | "await";
|
|
725
|
+
readonly operand: Expression;
|
|
726
|
+
readonly span: Span;
|
|
727
|
+
}
|
|
728
|
+
/**
|
|
729
|
+
* D39 item 51: `try <postfix-expression>` turns an expected failure into
|
|
730
|
+
* `null`. It carries the same reach as `await` — the whole postfix chain — and
|
|
731
|
+
* its result must be consumed, so a swallowed failure is always visible where
|
|
732
|
+
* it is handled.
|
|
733
|
+
*/
|
|
734
|
+
export interface TryExpression {
|
|
735
|
+
readonly kind: "TryExpression";
|
|
736
|
+
readonly value: Expression;
|
|
737
|
+
readonly span: Span;
|
|
738
|
+
}
|
|
739
|
+
export interface BinaryExpression {
|
|
740
|
+
readonly kind: "BinaryExpression";
|
|
741
|
+
readonly left: Expression;
|
|
742
|
+
readonly operator: "??" | "or" | "and" | "in" | "not in" | "==" | "!=" | "<" | "<=" | ">" | ">=" | "|" | "^" | "&" | "<<" | ">>" | ">>>" | "+" | "-" | "*" | "**" | "/" | "%";
|
|
743
|
+
readonly right: Expression;
|
|
744
|
+
/**
|
|
745
|
+
* Present when the author wrote explicit parentheses around this binary
|
|
746
|
+
* expression. The parser uses it to tell a deliberate grouping from a bare
|
|
747
|
+
* chain when `??` mixes with `and`/`or`; emission is unaffected.
|
|
748
|
+
*/
|
|
749
|
+
readonly parenthesized?: true;
|
|
750
|
+
readonly span: Span;
|
|
751
|
+
}
|
|
752
|
+
/**
|
|
753
|
+
* A parse recovery for an assignment written where an expression is required
|
|
754
|
+
* (an interpolated fragment or an arrow body). The parser reports directive
|
|
755
|
+
* guidance and keeps the assignment shape so later stages can add their own
|
|
756
|
+
* guidance; it never reaches code generation.
|
|
757
|
+
*/
|
|
758
|
+
export interface AssignmentExpression {
|
|
759
|
+
readonly kind: "AssignmentExpression";
|
|
760
|
+
readonly target: Expression;
|
|
761
|
+
readonly operator: AssignmentStatement["operator"];
|
|
762
|
+
readonly value: Expression;
|
|
763
|
+
readonly span: Span;
|
|
764
|
+
}
|
|
765
|
+
export interface ComparisonChainExpression {
|
|
766
|
+
readonly kind: "ComparisonChainExpression";
|
|
767
|
+
readonly operands: readonly Expression[];
|
|
768
|
+
readonly operators: readonly ("==" | "!=" | "<" | "<=" | ">" | ">=")[];
|
|
769
|
+
readonly parenthesized?: true;
|
|
770
|
+
readonly span: Span;
|
|
771
|
+
}
|
|
772
|
+
export interface ConditionalExpression {
|
|
773
|
+
readonly kind: "ConditionalExpression";
|
|
774
|
+
readonly condition: Expression;
|
|
775
|
+
readonly thenValue: Expression;
|
|
776
|
+
readonly elseValue: Expression;
|
|
777
|
+
readonly span: Span;
|
|
778
|
+
}
|
|
779
|
+
export interface IsExpression {
|
|
780
|
+
readonly kind: "IsExpression";
|
|
781
|
+
readonly value: Expression;
|
|
782
|
+
readonly operator: "is" | "is not";
|
|
783
|
+
readonly type: TypeReference;
|
|
784
|
+
readonly parenthesized?: true;
|
|
785
|
+
readonly span: Span;
|
|
786
|
+
}
|
|
787
|
+
export interface ArrowFunctionExpression {
|
|
788
|
+
readonly kind: "ArrowFunctionExpression";
|
|
789
|
+
readonly asynchronous: boolean;
|
|
790
|
+
readonly parameters: readonly Parameter[];
|
|
791
|
+
readonly body: Expression;
|
|
792
|
+
readonly span: Span;
|
|
793
|
+
}
|
|
794
|
+
export interface CallExpression {
|
|
795
|
+
readonly kind: "CallExpression";
|
|
796
|
+
readonly callee: Expression;
|
|
797
|
+
readonly arguments: readonly Expression[];
|
|
798
|
+
readonly argumentNames?: readonly (string | null)[];
|
|
799
|
+
readonly optional: boolean;
|
|
800
|
+
readonly span: Span;
|
|
801
|
+
}
|
|
802
|
+
export interface MemberExpression {
|
|
803
|
+
readonly kind: "MemberExpression";
|
|
804
|
+
readonly object: Expression;
|
|
805
|
+
readonly property: string;
|
|
806
|
+
readonly optional: boolean;
|
|
807
|
+
readonly span: Span;
|
|
808
|
+
}
|
|
809
|
+
export interface IndexExpression {
|
|
810
|
+
readonly kind: "IndexExpression";
|
|
811
|
+
readonly object: Expression;
|
|
812
|
+
readonly index: Expression;
|
|
813
|
+
readonly optional: boolean;
|
|
814
|
+
readonly span: Span;
|
|
815
|
+
}
|
|
816
|
+
/** Anything the AST puts a `kind` on: a node, a pattern, an f-string part. */
|
|
817
|
+
export interface AstNode {
|
|
818
|
+
readonly kind: string;
|
|
819
|
+
}
|
|
820
|
+
/**
|
|
821
|
+
* Every node under `root`, in source order, whatever shape it has.
|
|
822
|
+
*
|
|
823
|
+
* The walk is structural: it descends through arrays and objects without
|
|
824
|
+
* asking what they are, so it reaches a container the day the parser produces
|
|
825
|
+
* one — a new class member, a new statement form, an extension node this
|
|
826
|
+
* package has never heard of — with nothing here to update. Only nodes are
|
|
827
|
+
* reported, but the descent is unconditional, so an expression parked on a
|
|
828
|
+
* shape that carries no `kind` of its own (a `Parameter`, a `MatchCase`) is
|
|
829
|
+
* still reached through it.
|
|
830
|
+
*
|
|
831
|
+
* A pass that must not *miss* something walks with this instead of writing a
|
|
832
|
+
* second switch over the node kinds it happens to remember. A-010: dependency
|
|
833
|
+
* discovery kept such a switch, and `try`, `using`, `test "…":`, class
|
|
834
|
+
* getters, `@dispose:` and `@iterate:` were all outside the module graph —
|
|
835
|
+
* `@iterate:` from the day D68 added it, because a hand-kept copy of the AST
|
|
836
|
+
* starts drifting the moment the AST grows. That copy compiled, exited 0, and
|
|
837
|
+
* turned a module that exists and loads into `null`.
|
|
838
|
+
*/
|
|
839
|
+
export declare function astNodes(root: unknown): Generator<AstNode>;
|
|
840
|
+
/** `astNodes` narrowed to one node kind, so a caller keeps the node's type. */
|
|
841
|
+
export declare function astNodesOfKind<Node extends AstNode>(root: unknown, kind: Node["kind"]): Generator<Node>;
|
|
842
|
+
export type DirectAwaitExpressionExtension = (expression: Expression, contains: (expression: Expression) => boolean) => boolean | undefined;
|
|
843
|
+
export type DirectAwaitStatementExtension = (statement: Statement, containsExpression: (expression: Expression) => boolean, containsBlock: (statements: readonly Statement[]) => boolean) => boolean | undefined;
|
|
844
|
+
/**
|
|
845
|
+
* Whether a block awaits in its own frame. A nested function or arrow owns its
|
|
846
|
+
* awaits, so the walk stops at every declaration boundary. D43 item 69 uses
|
|
847
|
+
* this to decide whether releasing a `@dispose` value needs an async scope.
|
|
848
|
+
*/
|
|
849
|
+
export declare function blockContainsDirectAwait(statements: readonly Statement[], expressionExtension?: DirectAwaitExpressionExtension, statementExtension?: DirectAwaitStatementExtension): boolean;
|
|
850
|
+
export declare function statementContainsDirectAwait(statement: Statement, expressionExtension?: DirectAwaitExpressionExtension, statementExtension?: DirectAwaitStatementExtension): boolean;
|
|
851
|
+
export declare function expressionContainsDirectAwait(expression: Expression, extension?: DirectAwaitExpressionExtension): boolean;
|
|
852
|
+
export {};
|
|
853
|
+
//# sourceMappingURL=ast.d.ts.map
|