xbintsc 0.1.6 → 0.1.8
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/README.md +7 -4
- package/dist/src/ast/common.d.ts +33 -0
- package/dist/src/ast/common.js +7 -0
- package/dist/src/ast/common.js.map +1 -0
- package/dist/src/ast/declarations.d.ts +110 -0
- package/dist/src/ast/declarations.js +5 -0
- package/dist/src/ast/declarations.js.map +1 -0
- package/dist/src/ast/expressions.d.ts +219 -0
- package/dist/src/ast/expressions.js +6 -0
- package/dist/src/ast/expressions.js.map +1 -0
- package/dist/src/ast/kinds.d.ts +160 -0
- package/dist/src/ast/kinds.js +171 -0
- package/dist/src/ast/kinds.js.map +1 -0
- package/dist/src/ast/modules.d.ts +61 -0
- package/dist/src/ast/modules.js +5 -0
- package/dist/src/ast/modules.js.map +1 -0
- package/dist/src/ast/nodes.d.ts +11 -839
- package/dist/src/ast/nodes.js +11 -237
- package/dist/src/ast/nodes.js.map +1 -1
- package/dist/src/ast/operators.d.ts +71 -0
- package/dist/src/ast/operators.js +77 -0
- package/dist/src/ast/operators.js.map +1 -0
- package/dist/src/ast/statements.d.ts +120 -0
- package/dist/src/ast/statements.js +5 -0
- package/dist/src/ast/statements.js.map +1 -0
- package/dist/src/ast/types.d.ts +123 -0
- package/dist/src/ast/types.js +6 -0
- package/dist/src/ast/types.js.map +1 -0
- package/dist/src/codegen/generator/calls.d.ts +22 -0
- package/dist/src/codegen/generator/calls.js +301 -0
- package/dist/src/codegen/generator/calls.js.map +1 -0
- package/dist/src/codegen/generator/context.d.ts +45 -0
- package/dist/src/codegen/generator/context.js +128 -0
- package/dist/src/codegen/generator/context.js.map +1 -0
- package/dist/src/codegen/generator/expressions.d.ts +22 -0
- package/dist/src/codegen/generator/expressions.js +383 -0
- package/dist/src/codegen/generator/expressions.js.map +1 -0
- package/dist/src/codegen/generator/generator.d.ts +22 -0
- package/dist/src/codegen/generator/generator.js +21 -0
- package/dist/src/codegen/generator/generator.js.map +1 -0
- package/dist/src/codegen/generator/module.d.ts +15 -0
- package/dist/src/codegen/generator/module.js +114 -0
- package/dist/src/codegen/generator/module.js.map +1 -0
- package/dist/src/codegen/generator/state.d.ts +40 -0
- package/dist/src/codegen/generator/state.js +84 -0
- package/dist/src/codegen/generator/state.js.map +1 -0
- package/dist/src/codegen/generator/statements.d.ts +22 -0
- package/dist/src/codegen/generator/statements.js +425 -0
- package/dist/src/codegen/generator/statements.js.map +1 -0
- package/dist/src/codegen/generator/tables.d.ts +19 -0
- package/dist/src/codegen/generator/tables.js +153 -0
- package/dist/src/codegen/generator/tables.js.map +1 -0
- package/dist/src/codegen/llvm.d.ts +4 -13
- package/dist/src/codegen/llvm.js +4 -1537
- package/dist/src/codegen/llvm.js.map +1 -1
- package/dist/src/driver/compiler.js +13 -4
- package/dist/src/driver/compiler.js.map +1 -1
- package/dist/src/lexer/char.d.ts +78 -0
- package/dist/src/lexer/char.js +106 -0
- package/dist/src/lexer/char.js.map +1 -0
- package/dist/src/lexer/scanner.js +1 -98
- package/dist/src/lexer/scanner.js.map +1 -1
- package/dist/src/parser/context.d.ts +58 -0
- package/dist/src/parser/context.js +174 -0
- package/dist/src/parser/context.js.map +1 -0
- package/dist/src/parser/declarations.d.ts +26 -0
- package/dist/src/parser/declarations.js +461 -0
- package/dist/src/parser/declarations.js.map +1 -0
- package/dist/src/parser/expressions.d.ts +27 -0
- package/dist/src/parser/expressions.js +437 -0
- package/dist/src/parser/expressions.js.map +1 -0
- package/dist/src/parser/helpers.d.ts +7 -0
- package/dist/src/parser/helpers.js +36 -0
- package/dist/src/parser/helpers.js.map +1 -0
- package/dist/src/parser/literals.d.ts +16 -0
- package/dist/src/parser/literals.js +193 -0
- package/dist/src/parser/literals.js.map +1 -0
- package/dist/src/parser/modules.d.ts +12 -0
- package/dist/src/parser/modules.js +175 -0
- package/dist/src/parser/modules.js.map +1 -0
- package/dist/src/parser/operators.d.ts +12 -0
- package/dist/src/parser/operators.js +172 -0
- package/dist/src/parser/operators.js.map +1 -0
- package/dist/src/parser/parser.d.ts +17 -122
- package/dist/src/parser/parser.js +18 -2311
- package/dist/src/parser/parser.js.map +1 -1
- package/dist/src/parser/speculation.d.ts +6 -0
- package/dist/src/parser/speculation.js +10 -0
- package/dist/src/parser/speculation.js.map +1 -0
- package/dist/src/parser/statements.d.ts +28 -0
- package/dist/src/parser/statements.js +402 -0
- package/dist/src/parser/statements.js.map +1 -0
- package/dist/src/parser/types.d.ts +21 -0
- package/dist/src/parser/types.js +338 -0
- package/dist/src/parser/types.js.map +1 -0
- package/package.json +1 -1
- package/runtime/rt_internal.h +106 -0
- package/runtime/xt_alloc.c +38 -0
- package/runtime/xt_builtins.c +192 -0
- package/runtime/xt_containers.c +225 -0
- package/runtime/xt_io.c +133 -0
- package/runtime/xt_stdlib.c +502 -0
- package/runtime/xt_values.c +291 -0
- package/scripts/build-runtime.mjs +8 -1
- package/src/ast/common.ts +210 -0
- package/src/ast/declarations.ts +130 -0
- package/src/ast/expressions.ts +275 -0
- package/src/ast/kinds.ts +176 -0
- package/src/ast/modules.ts +73 -0
- package/src/ast/nodes.ts +11 -1101
- package/src/ast/operators.ts +76 -0
- package/src/ast/statements.ts +148 -0
- package/src/ast/types.ts +173 -0
- package/src/codegen/generator/calls.ts +355 -0
- package/src/codegen/generator/context.ts +156 -0
- package/src/codegen/generator/expressions.ts +431 -0
- package/src/codegen/generator/generator.ts +35 -0
- package/src/codegen/generator/module.ts +139 -0
- package/src/codegen/generator/state.ts +126 -0
- package/src/codegen/generator/statements.ts +474 -0
- package/src/codegen/generator/tables.ts +171 -0
- package/src/codegen/llvm.ts +4 -1720
- package/src/driver/compiler.ts +17 -5
- package/src/lexer/char.ts +116 -0
- package/src/lexer/scanner.ts +9 -109
- package/src/parser/context.ts +196 -0
- package/src/parser/declarations.ts +502 -0
- package/src/parser/expressions.ts +465 -0
- package/src/parser/helpers.ts +42 -0
- package/src/parser/literals.ts +207 -0
- package/src/parser/modules.ts +194 -0
- package/src/parser/operators.ts +181 -0
- package/src/parser/parser.ts +35 -2373
- package/src/parser/speculation.ts +9 -0
- package/src/parser/statements.ts +457 -0
- package/src/parser/types.ts +365 -0
- package/runtime/xt_runtime.c +0 -1372
package/README.md
CHANGED
|
@@ -56,10 +56,13 @@ delegated to `@xt_*` runtime calls.
|
|
|
56
56
|
|
|
57
57
|
### Runtime
|
|
58
58
|
|
|
59
|
-
`runtime
|
|
60
|
-
comparison, exceptions and Node-like `console.log` inspection.
|
|
61
|
-
|
|
62
|
-
|
|
59
|
+
`runtime/` implements strings, objects, arrays, closures, arithmetic,
|
|
60
|
+
comparison, exceptions and Node-like `console.log` inspection. The C code is
|
|
61
|
+
split by function across translation units (`xt_alloc.c`, `xt_values.c`,
|
|
62
|
+
`xt_containers.c`, `xt_stdlib.c`, `xt_builtins.c`, `xt_io.c`) sharing the
|
|
63
|
+
private `runtime/rt_internal.h`. It uses a bump arena and never frees — garbage
|
|
64
|
+
collection is deliberately deferred and isolated behind `xt_alloc`, so it can
|
|
65
|
+
be replaced without touching the compiler.
|
|
63
66
|
|
|
64
67
|
## Usage
|
|
65
68
|
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Core AST shapes shared by every node category: source ranges, the base
|
|
3
|
+
* `Node` interface, the `Modifier` node and the `Expression`/`Statement`/
|
|
4
|
+
* `TypeNode` discriminated unions.
|
|
5
|
+
*/
|
|
6
|
+
import { SyntaxKind, type ModifierKind } from "./kinds.js";
|
|
7
|
+
import type { ArrayLiteralExpression, ArrowFunction, AsExpression, AwaitExpression, BigIntLiteral, BinaryExpression, BooleanLiteral, CallExpression, ClassExpression, ConditionalExpression, DeleteExpression, ElementAccessExpression, FunctionExpression, Identifier, NewExpression, NoSubstitutionTemplateLiteral, NonNullExpression, NullLiteral, NumericLiteral, ObjectLiteralExpression, ParenthesizedExpression, PostfixUnaryExpression, PrefixUnaryExpression, PrivateIdentifier, PropertyAccessExpression, RegularExpressionLiteral, SatisfiesExpression, SpreadElement, StringLiteral, TaggedTemplateExpression, TemplateLiteral, ThisExpression, TypeOfExpression, UndefinedLiteral, VoidExpression, YieldExpression } from "./expressions.js";
|
|
8
|
+
import type { Block, BreakStatement, ContinueStatement, DebuggerStatement, DoStatement, EmptyStatement, ExpressionStatement, ForInStatement, ForOfStatement, ForStatement, IfStatement, LabeledStatement, ReturnStatement, SwitchStatement, ThrowStatement, TryStatement, VariableStatement, WhileStatement } from "./statements.js";
|
|
9
|
+
import type { ClassDeclaration, EnumDeclaration, FunctionDeclaration, InterfaceDeclaration, ModuleDeclaration, TypeAliasDeclaration } from "./declarations.js";
|
|
10
|
+
import type { ExportAssignment, ExportDeclaration, ImportDeclaration } from "./modules.js";
|
|
11
|
+
import type { ArrayTypeNode, ConditionalTypeNode, FunctionTypeNode, IndexedAccessTypeNode, InferTypeNode, IntersectionTypeNode, KeywordTypeNode, LiteralTypeNode, MappedTypeNode, OptionalTypeNode, ParenthesizedTypeNode, RestTypeNode, TupleTypeNode, TypeLiteralNode, TypeOperatorNode, TypePredicate, TypeQueryNode, TypeReference, UnionTypeNode } from "./types.js";
|
|
12
|
+
export interface Range {
|
|
13
|
+
/** Inclusive start offset (UTF-16 code units). */
|
|
14
|
+
readonly start: number;
|
|
15
|
+
/** Exclusive end offset. */
|
|
16
|
+
readonly end: number;
|
|
17
|
+
}
|
|
18
|
+
export interface Node extends Range {
|
|
19
|
+
readonly kind: SyntaxKind;
|
|
20
|
+
}
|
|
21
|
+
export interface Modifier extends Node {
|
|
22
|
+
readonly kind: SyntaxKind.Unknown;
|
|
23
|
+
readonly modifierKind: ModifierKind;
|
|
24
|
+
}
|
|
25
|
+
export type Expression = Identifier | PrivateIdentifier | NumericLiteral | BigIntLiteral | StringLiteral | NoSubstitutionTemplateLiteral | TemplateLiteral | RegularExpressionLiteral | BooleanLiteral | NullLiteral | UndefinedLiteral | ThisExpression | ArrayLiteralExpression | ObjectLiteralExpression | FunctionExpression | ArrowFunction | ClassExpression | CallExpression | NewExpression | PropertyAccessExpression | ElementAccessExpression | ParenthesizedExpression | PrefixUnaryExpression | PostfixUnaryExpression | BinaryExpression | ConditionalExpression | AsExpression | SatisfiesExpression | NonNullExpression | TypeOfExpression | VoidExpression | DeleteExpression | AwaitExpression | YieldExpression | TaggedTemplateExpression | SpreadElement;
|
|
26
|
+
export type Statement = ExpressionStatement | Block | EmptyStatement | DebuggerStatement | VariableStatement | IfStatement | WhileStatement | DoStatement | ForStatement | ForOfStatement | ForInStatement | ReturnStatement | BreakStatement | ContinueStatement | ThrowStatement | TryStatement | SwitchStatement | LabeledStatement | FunctionDeclaration | ClassDeclaration | InterfaceDeclaration | TypeAliasDeclaration | EnumDeclaration | ModuleDeclaration | ImportDeclaration | ExportDeclaration | ExportAssignment;
|
|
27
|
+
export type TypeNode = TypeReference | TypePredicate | KeywordTypeNode | LiteralTypeNode | ArrayTypeNode | TupleTypeNode | UnionTypeNode | IntersectionTypeNode | FunctionTypeNode | TypeLiteralNode | ParenthesizedTypeNode | TypeQueryNode | IndexedAccessTypeNode | TypeOperatorNode | MappedTypeNode | ConditionalTypeNode | InferTypeNode | OptionalTypeNode | RestTypeNode;
|
|
28
|
+
export interface SourceFileNode extends Node {
|
|
29
|
+
readonly kind: SyntaxKind.SourceFile;
|
|
30
|
+
readonly statements: Statement[];
|
|
31
|
+
readonly fileName: string;
|
|
32
|
+
readonly text: string;
|
|
33
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"common.js","sourceRoot":"","sources":["../../../src/ast/common.ts"],"names":[],"mappings":"AAAA;;;;GAIG"}
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Declaration nodes of the xbintsc AST (functions, classes, interfaces, ...).
|
|
3
|
+
*/
|
|
4
|
+
import { NodeFlags, SyntaxKind } from "./kinds.js";
|
|
5
|
+
import type { Expression, Modifier, Node, TypeNode } from "./common.js";
|
|
6
|
+
import type { Identifier, PropertyName, StringLiteral } from "./expressions.js";
|
|
7
|
+
import type { Block } from "./statements.js";
|
|
8
|
+
import type { TypeElement } from "./types.js";
|
|
9
|
+
export interface Parameter extends Node {
|
|
10
|
+
readonly kind: SyntaxKind.Parameter;
|
|
11
|
+
readonly name: Identifier;
|
|
12
|
+
readonly modifiers: Modifier[];
|
|
13
|
+
readonly dotDotDotToken: boolean;
|
|
14
|
+
readonly questionToken: boolean;
|
|
15
|
+
readonly type?: TypeNode;
|
|
16
|
+
readonly initializer?: Expression;
|
|
17
|
+
}
|
|
18
|
+
export interface TypeParameterDeclaration extends Node {
|
|
19
|
+
readonly kind: SyntaxKind.TypeParameterDeclaration;
|
|
20
|
+
readonly name: Identifier;
|
|
21
|
+
readonly constraint?: TypeNode;
|
|
22
|
+
readonly default?: TypeNode;
|
|
23
|
+
}
|
|
24
|
+
export interface FunctionDeclaration extends Node {
|
|
25
|
+
readonly kind: SyntaxKind.FunctionDeclaration;
|
|
26
|
+
readonly name?: Identifier;
|
|
27
|
+
readonly modifiers: Modifier[];
|
|
28
|
+
readonly typeParameters: TypeParameterDeclaration[];
|
|
29
|
+
readonly parameters: Parameter[];
|
|
30
|
+
readonly returnType?: TypeNode;
|
|
31
|
+
readonly body?: Block;
|
|
32
|
+
readonly flags: NodeFlags;
|
|
33
|
+
}
|
|
34
|
+
export interface HeritageClause extends Node {
|
|
35
|
+
readonly kind: SyntaxKind.HeritageClause;
|
|
36
|
+
readonly token: "extends" | "implements";
|
|
37
|
+
readonly types: ExpressionWithTypeArguments[];
|
|
38
|
+
}
|
|
39
|
+
export interface ExpressionWithTypeArguments extends Node {
|
|
40
|
+
readonly kind: SyntaxKind.ExpressionWithTypeArguments;
|
|
41
|
+
readonly expression: Expression;
|
|
42
|
+
readonly typeArguments: TypeNode[];
|
|
43
|
+
}
|
|
44
|
+
export type ClassElement = PropertyDeclaration | MethodDeclaration | ConstructorDeclaration;
|
|
45
|
+
export interface PropertyDeclaration extends Node {
|
|
46
|
+
readonly kind: SyntaxKind.PropertyDeclaration;
|
|
47
|
+
readonly name: PropertyName;
|
|
48
|
+
readonly modifiers: Modifier[];
|
|
49
|
+
readonly questionToken: boolean;
|
|
50
|
+
readonly exclamationToken: boolean;
|
|
51
|
+
readonly type?: TypeNode;
|
|
52
|
+
readonly initializer?: Expression;
|
|
53
|
+
}
|
|
54
|
+
export interface MethodDeclaration extends Node {
|
|
55
|
+
readonly kind: SyntaxKind.MethodDeclaration;
|
|
56
|
+
readonly name: PropertyName;
|
|
57
|
+
readonly modifiers: Modifier[];
|
|
58
|
+
readonly typeParameters: TypeParameterDeclaration[];
|
|
59
|
+
readonly parameters: Parameter[];
|
|
60
|
+
readonly returnType?: TypeNode;
|
|
61
|
+
readonly body?: Block;
|
|
62
|
+
readonly flags: NodeFlags;
|
|
63
|
+
readonly optional: boolean;
|
|
64
|
+
}
|
|
65
|
+
export interface ConstructorDeclaration extends Node {
|
|
66
|
+
readonly kind: SyntaxKind.ConstructorDeclaration;
|
|
67
|
+
readonly modifiers: Modifier[];
|
|
68
|
+
readonly parameters: Parameter[];
|
|
69
|
+
readonly body?: Block;
|
|
70
|
+
}
|
|
71
|
+
export interface ClassDeclaration extends Node {
|
|
72
|
+
readonly kind: SyntaxKind.ClassDeclaration;
|
|
73
|
+
readonly name?: Identifier;
|
|
74
|
+
readonly modifiers: Modifier[];
|
|
75
|
+
readonly typeParameters: TypeParameterDeclaration[];
|
|
76
|
+
readonly heritage: HeritageClause[];
|
|
77
|
+
readonly members: ClassElement[];
|
|
78
|
+
}
|
|
79
|
+
export interface InterfaceDeclaration extends Node {
|
|
80
|
+
readonly kind: SyntaxKind.InterfaceDeclaration;
|
|
81
|
+
readonly name: Identifier;
|
|
82
|
+
readonly modifiers: Modifier[];
|
|
83
|
+
readonly typeParameters: TypeParameterDeclaration[];
|
|
84
|
+
readonly heritage: HeritageClause[];
|
|
85
|
+
readonly members: TypeElement[];
|
|
86
|
+
}
|
|
87
|
+
export interface TypeAliasDeclaration extends Node {
|
|
88
|
+
readonly kind: SyntaxKind.TypeAliasDeclaration;
|
|
89
|
+
readonly name: Identifier;
|
|
90
|
+
readonly modifiers: Modifier[];
|
|
91
|
+
readonly typeParameters: TypeParameterDeclaration[];
|
|
92
|
+
readonly type: TypeNode;
|
|
93
|
+
}
|
|
94
|
+
export interface EnumMember extends Node {
|
|
95
|
+
readonly kind: SyntaxKind.EnumMember;
|
|
96
|
+
readonly name: PropertyName;
|
|
97
|
+
readonly initializer?: Expression;
|
|
98
|
+
}
|
|
99
|
+
export interface EnumDeclaration extends Node {
|
|
100
|
+
readonly kind: SyntaxKind.EnumDeclaration;
|
|
101
|
+
readonly name: Identifier;
|
|
102
|
+
readonly modifiers: Modifier[];
|
|
103
|
+
readonly members: EnumMember[];
|
|
104
|
+
}
|
|
105
|
+
export interface ModuleDeclaration extends Node {
|
|
106
|
+
readonly kind: SyntaxKind.ModuleDeclaration;
|
|
107
|
+
readonly name: Identifier | StringLiteral;
|
|
108
|
+
readonly modifiers: Modifier[];
|
|
109
|
+
readonly body?: Block;
|
|
110
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"declarations.js","sourceRoot":"","sources":["../../../src/ast/declarations.ts"],"names":[],"mappings":"AAAA;;GAEG"}
|
|
@@ -0,0 +1,219 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Expression nodes of the xbintsc AST, plus the literal and identifier nodes
|
|
3
|
+
* they are built from.
|
|
4
|
+
*/
|
|
5
|
+
import type { Token } from "../lexer/token.js";
|
|
6
|
+
import { NodeFlags, SyntaxKind } from "./kinds.js";
|
|
7
|
+
import { AssignmentOperator, BinaryOperator, PostfixUnaryOperator, PrefixUnaryOperator } from "./operators.js";
|
|
8
|
+
import type { Expression, Node, TypeNode } from "./common.js";
|
|
9
|
+
import type { Block } from "./statements.js";
|
|
10
|
+
import type { ClassElement, HeritageClause, Parameter, TypeParameterDeclaration } from "./declarations.js";
|
|
11
|
+
export interface Identifier extends Node {
|
|
12
|
+
readonly kind: SyntaxKind.Identifier;
|
|
13
|
+
readonly text: string;
|
|
14
|
+
/** True when the identifier was written with a `#` prefix. */
|
|
15
|
+
readonly escaped?: boolean;
|
|
16
|
+
}
|
|
17
|
+
export interface PrivateIdentifier extends Node {
|
|
18
|
+
readonly kind: SyntaxKind.PrivateIdentifier;
|
|
19
|
+
readonly text: string;
|
|
20
|
+
}
|
|
21
|
+
export interface NumericLiteral extends Node {
|
|
22
|
+
readonly kind: SyntaxKind.NumericLiteral;
|
|
23
|
+
readonly text: string;
|
|
24
|
+
readonly value: number;
|
|
25
|
+
}
|
|
26
|
+
export interface BigIntLiteral extends Node {
|
|
27
|
+
readonly kind: SyntaxKind.BigIntLiteral;
|
|
28
|
+
readonly text: string;
|
|
29
|
+
readonly value: bigint;
|
|
30
|
+
}
|
|
31
|
+
export interface StringLiteral extends Node {
|
|
32
|
+
readonly kind: SyntaxKind.StringLiteral;
|
|
33
|
+
readonly text: string;
|
|
34
|
+
readonly value: string;
|
|
35
|
+
/** Raw source text, including quotes. */
|
|
36
|
+
readonly raw: string;
|
|
37
|
+
}
|
|
38
|
+
export interface NoSubstitutionTemplateLiteral extends Node {
|
|
39
|
+
readonly kind: SyntaxKind.NoSubstitutionTemplateLiteral;
|
|
40
|
+
readonly text: string;
|
|
41
|
+
readonly value: string;
|
|
42
|
+
}
|
|
43
|
+
export interface TemplateLiteral extends Node {
|
|
44
|
+
readonly kind: SyntaxKind.TemplateLiteral;
|
|
45
|
+
readonly head: string;
|
|
46
|
+
readonly spans: TemplateSpan[];
|
|
47
|
+
}
|
|
48
|
+
export interface TemplateSpan extends Node {
|
|
49
|
+
readonly kind: SyntaxKind.TemplateSpan;
|
|
50
|
+
readonly expression: Expression;
|
|
51
|
+
readonly literal: string;
|
|
52
|
+
/** True when this span terminates the template (tail) rather than continues it. */
|
|
53
|
+
readonly isTail: boolean;
|
|
54
|
+
}
|
|
55
|
+
export interface RegularExpressionLiteral extends Node {
|
|
56
|
+
readonly kind: SyntaxKind.RegularExpressionLiteral;
|
|
57
|
+
readonly text: string;
|
|
58
|
+
readonly pattern: string;
|
|
59
|
+
readonly flags: string;
|
|
60
|
+
}
|
|
61
|
+
export interface BooleanLiteral extends Node {
|
|
62
|
+
readonly kind: SyntaxKind.TrueKeyword | SyntaxKind.FalseKeyword;
|
|
63
|
+
readonly value: boolean;
|
|
64
|
+
}
|
|
65
|
+
export interface NullLiteral extends Node {
|
|
66
|
+
readonly kind: SyntaxKind.NullKeyword;
|
|
67
|
+
}
|
|
68
|
+
export interface UndefinedLiteral extends Node {
|
|
69
|
+
readonly kind: SyntaxKind.UndefinedKeyword;
|
|
70
|
+
}
|
|
71
|
+
export interface ThisExpression extends Node {
|
|
72
|
+
readonly kind: SyntaxKind.ThisKeyword;
|
|
73
|
+
}
|
|
74
|
+
export interface ArrayLiteralExpression extends Node {
|
|
75
|
+
readonly kind: SyntaxKind.ArrayLiteralExpression;
|
|
76
|
+
readonly elements: Expression[];
|
|
77
|
+
}
|
|
78
|
+
export interface PropertyAssignment extends Node {
|
|
79
|
+
readonly kind: SyntaxKind.PropertyAssignment;
|
|
80
|
+
readonly name: PropertyName;
|
|
81
|
+
readonly initializer: Expression;
|
|
82
|
+
}
|
|
83
|
+
export interface ShorthandPropertyAssignment extends Node {
|
|
84
|
+
readonly kind: SyntaxKind.ShorthandPropertyAssignment;
|
|
85
|
+
readonly name: Identifier;
|
|
86
|
+
}
|
|
87
|
+
export interface SpreadElement extends Node {
|
|
88
|
+
readonly kind: SyntaxKind.SpreadElement;
|
|
89
|
+
readonly expression: Expression;
|
|
90
|
+
}
|
|
91
|
+
export type ObjectLiteralElementLike = PropertyAssignment | ShorthandPropertyAssignment | SpreadElement;
|
|
92
|
+
export interface ObjectLiteralExpression extends Node {
|
|
93
|
+
readonly kind: SyntaxKind.ObjectLiteralExpression;
|
|
94
|
+
readonly properties: ObjectLiteralElementLike[];
|
|
95
|
+
}
|
|
96
|
+
export type PropertyName = Identifier | StringLiteral | NumericLiteral | PrivateIdentifier;
|
|
97
|
+
export interface FunctionExpression extends Node {
|
|
98
|
+
readonly kind: SyntaxKind.FunctionExpression;
|
|
99
|
+
readonly name?: Identifier;
|
|
100
|
+
readonly typeParameters: TypeParameterDeclaration[];
|
|
101
|
+
readonly parameters: Parameter[];
|
|
102
|
+
readonly returnType?: TypeNode;
|
|
103
|
+
readonly body: Block;
|
|
104
|
+
readonly flags: NodeFlags;
|
|
105
|
+
}
|
|
106
|
+
export interface ArrowFunction extends Node {
|
|
107
|
+
readonly kind: SyntaxKind.ArrowFunction;
|
|
108
|
+
readonly typeParameters: TypeParameterDeclaration[];
|
|
109
|
+
readonly parameters: Parameter[];
|
|
110
|
+
readonly returnType?: TypeNode;
|
|
111
|
+
readonly body: Block | Expression;
|
|
112
|
+
readonly flags: NodeFlags;
|
|
113
|
+
}
|
|
114
|
+
export interface ClassExpression extends Node {
|
|
115
|
+
readonly kind: SyntaxKind.ClassExpression;
|
|
116
|
+
readonly name?: Identifier;
|
|
117
|
+
readonly typeParameters: TypeParameterDeclaration[];
|
|
118
|
+
readonly heritage: HeritageClause[];
|
|
119
|
+
readonly members: ClassElement[];
|
|
120
|
+
}
|
|
121
|
+
export interface CallExpression extends Node {
|
|
122
|
+
readonly kind: SyntaxKind.CallExpression;
|
|
123
|
+
readonly expression: Expression;
|
|
124
|
+
readonly typeArguments: TypeNode[];
|
|
125
|
+
readonly arguments: Expression[];
|
|
126
|
+
readonly optional: boolean;
|
|
127
|
+
}
|
|
128
|
+
export interface NewExpression extends Node {
|
|
129
|
+
readonly kind: SyntaxKind.NewExpression;
|
|
130
|
+
readonly expression: Expression;
|
|
131
|
+
readonly typeArguments: TypeNode[];
|
|
132
|
+
readonly arguments: Expression[];
|
|
133
|
+
}
|
|
134
|
+
export interface PropertyAccessExpression extends Node {
|
|
135
|
+
readonly kind: SyntaxKind.PropertyAccessExpression;
|
|
136
|
+
readonly expression: Expression;
|
|
137
|
+
readonly name: Identifier;
|
|
138
|
+
readonly optional: boolean;
|
|
139
|
+
}
|
|
140
|
+
export interface ElementAccessExpression extends Node {
|
|
141
|
+
readonly kind: SyntaxKind.ElementAccessExpression;
|
|
142
|
+
readonly expression: Expression;
|
|
143
|
+
readonly argumentExpression: Expression;
|
|
144
|
+
readonly optional: boolean;
|
|
145
|
+
}
|
|
146
|
+
export interface ParenthesizedExpression extends Node {
|
|
147
|
+
readonly kind: SyntaxKind.ParenthesizedExpression;
|
|
148
|
+
readonly expression: Expression;
|
|
149
|
+
}
|
|
150
|
+
export interface PrefixUnaryExpression extends Node {
|
|
151
|
+
readonly kind: SyntaxKind.PrefixUnaryExpression;
|
|
152
|
+
readonly operator: PrefixUnaryOperator;
|
|
153
|
+
readonly operand: Expression;
|
|
154
|
+
}
|
|
155
|
+
export interface PostfixUnaryExpression extends Node {
|
|
156
|
+
readonly kind: SyntaxKind.PostfixUnaryExpression;
|
|
157
|
+
readonly operator: PostfixUnaryOperator;
|
|
158
|
+
readonly operand: Expression;
|
|
159
|
+
}
|
|
160
|
+
export interface BinaryExpression extends Node {
|
|
161
|
+
readonly kind: SyntaxKind.BinaryExpression;
|
|
162
|
+
readonly left: Expression;
|
|
163
|
+
readonly operator: BinaryOperator;
|
|
164
|
+
readonly right: Expression;
|
|
165
|
+
readonly operatorToken: Token;
|
|
166
|
+
}
|
|
167
|
+
export interface AssignmentExpression extends Node {
|
|
168
|
+
readonly kind: SyntaxKind.BinaryExpression;
|
|
169
|
+
readonly left: Expression;
|
|
170
|
+
readonly operator: AssignmentOperator;
|
|
171
|
+
readonly right: Expression;
|
|
172
|
+
readonly operatorToken: Token;
|
|
173
|
+
}
|
|
174
|
+
export interface ConditionalExpression extends Node {
|
|
175
|
+
readonly kind: SyntaxKind.ConditionalExpression;
|
|
176
|
+
readonly condition: Expression;
|
|
177
|
+
readonly whenTrue: Expression;
|
|
178
|
+
readonly whenFalse: Expression;
|
|
179
|
+
}
|
|
180
|
+
export interface AsExpression extends Node {
|
|
181
|
+
readonly kind: SyntaxKind.AsExpression;
|
|
182
|
+
readonly expression: Expression;
|
|
183
|
+
readonly type: TypeNode;
|
|
184
|
+
}
|
|
185
|
+
export interface SatisfiesExpression extends Node {
|
|
186
|
+
readonly kind: SyntaxKind.SatisfiesExpression;
|
|
187
|
+
readonly expression: Expression;
|
|
188
|
+
readonly type: TypeNode;
|
|
189
|
+
}
|
|
190
|
+
export interface NonNullExpression extends Node {
|
|
191
|
+
readonly kind: SyntaxKind.NonNullExpression;
|
|
192
|
+
readonly expression: Expression;
|
|
193
|
+
}
|
|
194
|
+
export interface TypeOfExpression extends Node {
|
|
195
|
+
readonly kind: SyntaxKind.TypeOfExpression;
|
|
196
|
+
readonly expression: Expression;
|
|
197
|
+
}
|
|
198
|
+
export interface VoidExpression extends Node {
|
|
199
|
+
readonly kind: SyntaxKind.VoidExpression;
|
|
200
|
+
readonly expression?: Expression;
|
|
201
|
+
}
|
|
202
|
+
export interface DeleteExpression extends Node {
|
|
203
|
+
readonly kind: SyntaxKind.DeleteExpression;
|
|
204
|
+
readonly expression: Expression;
|
|
205
|
+
}
|
|
206
|
+
export interface AwaitExpression extends Node {
|
|
207
|
+
readonly kind: SyntaxKind.AwaitExpression;
|
|
208
|
+
readonly expression: Expression;
|
|
209
|
+
}
|
|
210
|
+
export interface YieldExpression extends Node {
|
|
211
|
+
readonly kind: SyntaxKind.YieldExpression;
|
|
212
|
+
readonly expression?: Expression;
|
|
213
|
+
readonly delegate: boolean;
|
|
214
|
+
}
|
|
215
|
+
export interface TaggedTemplateExpression extends Node {
|
|
216
|
+
readonly kind: SyntaxKind.TaggedTemplateExpression;
|
|
217
|
+
readonly tag: Expression;
|
|
218
|
+
readonly template: TemplateLiteral | NoSubstitutionTemplateLiteral;
|
|
219
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"expressions.js","sourceRoot":"","sources":["../../../src/ast/expressions.ts"],"names":[],"mappings":"AAAA;;;GAGG"}
|
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Syntax kinds and node flags for the xbintsc AST.
|
|
3
|
+
*
|
|
4
|
+
* These numeric/string tags are the discriminants used throughout the binder,
|
|
5
|
+
* checker and code generator to switch exhaustively over nodes.
|
|
6
|
+
*/
|
|
7
|
+
export declare const enum SyntaxKind {
|
|
8
|
+
Unknown = 0,
|
|
9
|
+
EndOfFileToken = 1,
|
|
10
|
+
SourceFile = 300,
|
|
11
|
+
QualifiedName = 301,
|
|
12
|
+
ExpressionWithTypeArguments = 302,
|
|
13
|
+
ImportType = 303,
|
|
14
|
+
Identifier = 2,
|
|
15
|
+
PrivateIdentifier = 3,
|
|
16
|
+
NumericLiteral = 4,
|
|
17
|
+
BigIntLiteral = 5,
|
|
18
|
+
StringLiteral = 6,
|
|
19
|
+
NoSubstitutionTemplateLiteral = 7,
|
|
20
|
+
TemplateLiteral = 8,
|
|
21
|
+
TemplateSpan = 9,
|
|
22
|
+
RegularExpressionLiteral = 10,
|
|
23
|
+
TrueKeyword = 11,
|
|
24
|
+
FalseKeyword = 12,
|
|
25
|
+
NullKeyword = 13,
|
|
26
|
+
UndefinedKeyword = 14,
|
|
27
|
+
ThisKeyword = 15,
|
|
28
|
+
ArrayLiteralExpression = 20,
|
|
29
|
+
ObjectLiteralExpression = 21,
|
|
30
|
+
PropertyAssignment = 22,
|
|
31
|
+
ShorthandPropertyAssignment = 23,
|
|
32
|
+
SpreadElement = 24,
|
|
33
|
+
FunctionExpression = 25,
|
|
34
|
+
ArrowFunction = 26,
|
|
35
|
+
ClassExpression = 27,
|
|
36
|
+
CallExpression = 28,
|
|
37
|
+
NewExpression = 29,
|
|
38
|
+
PropertyAccessExpression = 30,
|
|
39
|
+
ElementAccessExpression = 31,
|
|
40
|
+
ParenthesizedExpression = 32,
|
|
41
|
+
PrefixUnaryExpression = 33,
|
|
42
|
+
PostfixUnaryExpression = 34,
|
|
43
|
+
BinaryExpression = 35,
|
|
44
|
+
ConditionalExpression = 36,
|
|
45
|
+
AsExpression = 37,
|
|
46
|
+
SatisfiesExpression = 38,
|
|
47
|
+
NonNullExpression = 39,
|
|
48
|
+
TypeOfExpression = 40,
|
|
49
|
+
VoidExpression = 41,
|
|
50
|
+
DeleteExpression = 42,
|
|
51
|
+
AwaitExpression = 43,
|
|
52
|
+
YieldExpression = 44,
|
|
53
|
+
TaggedTemplateExpression = 45,
|
|
54
|
+
ExpressionStatement = 60,
|
|
55
|
+
Block = 61,
|
|
56
|
+
EmptyStatement = 62,
|
|
57
|
+
DebuggerStatement = 63,
|
|
58
|
+
VariableStatement = 64,
|
|
59
|
+
VariableDeclarationList = 65,
|
|
60
|
+
VariableDeclaration = 66,
|
|
61
|
+
IfStatement = 67,
|
|
62
|
+
WhileStatement = 68,
|
|
63
|
+
DoStatement = 69,
|
|
64
|
+
ForStatement = 70,
|
|
65
|
+
ForOfStatement = 71,
|
|
66
|
+
ForInStatement = 72,
|
|
67
|
+
ReturnStatement = 73,
|
|
68
|
+
BreakStatement = 74,
|
|
69
|
+
ContinueStatement = 75,
|
|
70
|
+
ThrowStatement = 76,
|
|
71
|
+
TryStatement = 77,
|
|
72
|
+
CatchClause = 78,
|
|
73
|
+
SwitchStatement = 79,
|
|
74
|
+
CaseClause = 80,
|
|
75
|
+
DefaultClause = 81,
|
|
76
|
+
LabeledStatement = 82,
|
|
77
|
+
FunctionDeclaration = 100,
|
|
78
|
+
ClassDeclaration = 101,
|
|
79
|
+
InterfaceDeclaration = 102,
|
|
80
|
+
TypeAliasDeclaration = 103,
|
|
81
|
+
EnumDeclaration = 104,
|
|
82
|
+
EnumMember = 105,
|
|
83
|
+
ModuleDeclaration = 106,
|
|
84
|
+
Parameter = 107,
|
|
85
|
+
TypeParameterDeclaration = 108,
|
|
86
|
+
PropertyDeclaration = 109,
|
|
87
|
+
MethodDeclaration = 110,
|
|
88
|
+
ConstructorDeclaration = 111,
|
|
89
|
+
HeritageClause = 112,
|
|
90
|
+
ImportDeclaration = 113,
|
|
91
|
+
ImportClause = 114,
|
|
92
|
+
NamedImports = 115,
|
|
93
|
+
ImportSpecifier = 116,
|
|
94
|
+
NamespaceImport = 117,
|
|
95
|
+
ExportDeclaration = 118,
|
|
96
|
+
ExportAssignment = 119,
|
|
97
|
+
NamedExports = 120,
|
|
98
|
+
ExportSpecifier = 121,
|
|
99
|
+
TypeReference = 200,
|
|
100
|
+
TypePredicate = 201,
|
|
101
|
+
AnyKeywordType = 202,
|
|
102
|
+
UnknownKeywordType = 203,
|
|
103
|
+
NumberKeywordType = 204,
|
|
104
|
+
BigIntKeywordType = 205,
|
|
105
|
+
StringKeywordType = 206,
|
|
106
|
+
BooleanKeywordType = 207,
|
|
107
|
+
SymbolKeywordType = 208,
|
|
108
|
+
VoidKeywordType = 209,
|
|
109
|
+
UndefinedKeywordType = 210,
|
|
110
|
+
NullKeywordType = 211,
|
|
111
|
+
NeverKeywordType = 212,
|
|
112
|
+
ObjectKeywordType = 213,
|
|
113
|
+
ThisKeywordType = 214,
|
|
114
|
+
LiteralType = 215,
|
|
115
|
+
ArrayType = 216,
|
|
116
|
+
TupleType = 217,
|
|
117
|
+
UnionType = 218,
|
|
118
|
+
IntersectionType = 219,
|
|
119
|
+
FunctionType = 220,
|
|
120
|
+
TypeLiteral = 221,
|
|
121
|
+
PropertySignature = 222,
|
|
122
|
+
MethodSignature = 223,
|
|
123
|
+
IndexSignature = 224,
|
|
124
|
+
ParenthesizedType = 225,
|
|
125
|
+
TypeQuery = 226,
|
|
126
|
+
IndexedAccessType = 227,
|
|
127
|
+
TypeOperator = 228,
|
|
128
|
+
MappedType = 229,
|
|
129
|
+
ConditionalType = 230,
|
|
130
|
+
InferType = 231,
|
|
131
|
+
OptionalType = 232,
|
|
132
|
+
RestType = 233
|
|
133
|
+
}
|
|
134
|
+
export declare const enum NodeFlags {
|
|
135
|
+
None = 0,
|
|
136
|
+
Let = 1,
|
|
137
|
+
Const = 2,
|
|
138
|
+
Var = 4,
|
|
139
|
+
Exported = 8,
|
|
140
|
+
Default = 16,
|
|
141
|
+
Declare = 32,
|
|
142
|
+
Async = 64,
|
|
143
|
+
Generator = 128,
|
|
144
|
+
Ambient = 256,
|
|
145
|
+
Readonly = 512,
|
|
146
|
+
Abstract = 1024,
|
|
147
|
+
Optional = 2048
|
|
148
|
+
}
|
|
149
|
+
export declare const enum ModifierKind {
|
|
150
|
+
Export = "export",
|
|
151
|
+
Default = "default",
|
|
152
|
+
Declare = "declare",
|
|
153
|
+
Abstract = "abstract",
|
|
154
|
+
Public = "public",
|
|
155
|
+
Private = "private",
|
|
156
|
+
Protected = "protected",
|
|
157
|
+
Static = "static",
|
|
158
|
+
Readonly = "readonly",
|
|
159
|
+
Async = "async"
|
|
160
|
+
}
|