xbintsc 0.1.3 → 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 +14 -13
- 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 -1159
- 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 -2307
- 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/dist/tests/e2e/compile.test.js +122 -2
- package/dist/tests/e2e/compile.test.js.map +1 -1
- package/dist/tests/parser/parser.test.js +9 -1
- package/dist/tests/parser/parser.test.js.map +1 -1
- package/package.json +1 -1
- package/runtime/rt.h +32 -0
- 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 -1305
- 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 -2369
- 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 -682
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared state and low-level token plumbing for the parser.
|
|
3
|
+
*
|
|
4
|
+
* The parser's method groups (statements, expressions, types, modules) are
|
|
5
|
+
* defined as separate modules and installed onto `Parser.prototype`. This class
|
|
6
|
+
* holds the state they all operate on plus the token accessors every group
|
|
7
|
+
* needs.
|
|
8
|
+
*/
|
|
9
|
+
import { DiagnosticBag, DiagnosticCode } from "../diagnostics/diagnostic.js";
|
|
10
|
+
import type { SourceFile } from "../diagnostics/source.js";
|
|
11
|
+
import { Scanner } from "../lexer/scanner.js";
|
|
12
|
+
import { Token, TokenKind } from "../lexer/token.js";
|
|
13
|
+
import type { Identifier, StringLiteral } from "../ast/nodes.js";
|
|
14
|
+
export interface ParserState {
|
|
15
|
+
index: number;
|
|
16
|
+
tokens: Token[];
|
|
17
|
+
pos: number;
|
|
18
|
+
consumed: number;
|
|
19
|
+
}
|
|
20
|
+
export declare class ParserContext {
|
|
21
|
+
readonly scanner: Scanner;
|
|
22
|
+
readonly diagnostics: DiagnosticBag;
|
|
23
|
+
readonly source: SourceFile;
|
|
24
|
+
tokens: Token[];
|
|
25
|
+
index: number;
|
|
26
|
+
/** Non-zero while a speculative parse is running; errors abort the attempt. */
|
|
27
|
+
speculating: number;
|
|
28
|
+
/** Monotonic count of tokens consumed; used to detect lack of progress. */
|
|
29
|
+
consumed: number;
|
|
30
|
+
constructor(source: SourceFile, diagnostics: DiagnosticBag);
|
|
31
|
+
get token(): Token;
|
|
32
|
+
/**
|
|
33
|
+
* Compare the current token kind without triggering TypeScript's control-flow
|
|
34
|
+
* narrowing of `this.token.kind`, which would otherwise be invalidated by the
|
|
35
|
+
* calls to `nextToken()` that occur between checks.
|
|
36
|
+
*/
|
|
37
|
+
at(kind: TokenKind): boolean;
|
|
38
|
+
atAhead(k: number, kind: TokenKind): boolean;
|
|
39
|
+
lookAhead(k: number): Token;
|
|
40
|
+
nextToken(): Token;
|
|
41
|
+
parseExpected(kind: TokenKind, message?: string): Token;
|
|
42
|
+
error(code: DiagnosticCode, message: string, token?: Token): void;
|
|
43
|
+
/**
|
|
44
|
+
* Run `fn` speculatively. Any diagnostic raised while it runs (which aborts
|
|
45
|
+
* the attempt via `SpeculationError`) is rolled back along with the scanner
|
|
46
|
+
* position, so the parser can try a different production cleanly.
|
|
47
|
+
*/
|
|
48
|
+
tryParse<T>(fn: () => T): T | undefined;
|
|
49
|
+
isIdentifierLike(token: Token): boolean;
|
|
50
|
+
parseIdentifier(allowKeywords?: boolean): Identifier;
|
|
51
|
+
parseIdentifierName(): Identifier;
|
|
52
|
+
parseSemicolon(): void;
|
|
53
|
+
canInsertSemicolon(): boolean;
|
|
54
|
+
parseDelimitedList<T>(close: TokenKind, parseElement: () => T): T[];
|
|
55
|
+
stringLiteralFromToken(token: Token): StringLiteral;
|
|
56
|
+
saveState(): ParserState;
|
|
57
|
+
restoreState(state: ParserState): void;
|
|
58
|
+
}
|
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared state and low-level token plumbing for the parser.
|
|
3
|
+
*
|
|
4
|
+
* The parser's method groups (statements, expressions, types, modules) are
|
|
5
|
+
* defined as separate modules and installed onto `Parser.prototype`. This class
|
|
6
|
+
* holds the state they all operate on plus the token accessors every group
|
|
7
|
+
* needs.
|
|
8
|
+
*/
|
|
9
|
+
import { DiagnosticCode } from "../diagnostics/diagnostic.js";
|
|
10
|
+
import { Scanner } from "../lexer/scanner.js";
|
|
11
|
+
import { TokenKind } from "../lexer/token.js";
|
|
12
|
+
import { SyntaxKind } from "../ast/kinds.js";
|
|
13
|
+
import { SpeculationError } from "./speculation.js";
|
|
14
|
+
export class ParserContext {
|
|
15
|
+
scanner;
|
|
16
|
+
diagnostics;
|
|
17
|
+
source;
|
|
18
|
+
tokens;
|
|
19
|
+
index = 0;
|
|
20
|
+
/** Non-zero while a speculative parse is running; errors abort the attempt. */
|
|
21
|
+
speculating = 0;
|
|
22
|
+
/** Monotonic count of tokens consumed; used to detect lack of progress. */
|
|
23
|
+
consumed = 0;
|
|
24
|
+
constructor(source, diagnostics) {
|
|
25
|
+
this.source = source;
|
|
26
|
+
this.diagnostics = diagnostics;
|
|
27
|
+
this.scanner = new Scanner(source, diagnostics);
|
|
28
|
+
this.tokens = [this.scanner.nextToken()];
|
|
29
|
+
}
|
|
30
|
+
// -- token access ---------------------------------------------------------
|
|
31
|
+
get token() {
|
|
32
|
+
return this.tokens[this.index];
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Compare the current token kind without triggering TypeScript's control-flow
|
|
36
|
+
* narrowing of `this.token.kind`, which would otherwise be invalidated by the
|
|
37
|
+
* calls to `nextToken()` that occur between checks.
|
|
38
|
+
*/
|
|
39
|
+
at(kind) {
|
|
40
|
+
return this.tokens[this.index].kind === kind;
|
|
41
|
+
}
|
|
42
|
+
atAhead(k, kind) {
|
|
43
|
+
return this.lookAhead(k).kind === kind;
|
|
44
|
+
}
|
|
45
|
+
lookAhead(k) {
|
|
46
|
+
while (this.tokens.length <= this.index + k) {
|
|
47
|
+
this.tokens.push(this.scanner.nextToken());
|
|
48
|
+
}
|
|
49
|
+
return this.tokens[this.index + k];
|
|
50
|
+
}
|
|
51
|
+
nextToken() {
|
|
52
|
+
this.consumed++;
|
|
53
|
+
const current = this.token;
|
|
54
|
+
if (this.index + 1 < this.tokens.length) {
|
|
55
|
+
this.index++;
|
|
56
|
+
}
|
|
57
|
+
else {
|
|
58
|
+
this.tokens = [this.scanner.nextToken()];
|
|
59
|
+
this.index = 0;
|
|
60
|
+
}
|
|
61
|
+
return current;
|
|
62
|
+
}
|
|
63
|
+
parseExpected(kind, message) {
|
|
64
|
+
if (this.token.kind === kind)
|
|
65
|
+
return this.nextToken();
|
|
66
|
+
this.error(DiagnosticCode.ExpectedToken, message ?? `Expected '${kind}' but found '${this.token.text || this.token.kind}'`, this.token);
|
|
67
|
+
return this.token;
|
|
68
|
+
}
|
|
69
|
+
error(code, message, token = this.token) {
|
|
70
|
+
this.diagnostics.error(code, message, { start: token.start, end: token.end }, this.source.fileName);
|
|
71
|
+
if (this.speculating > 0)
|
|
72
|
+
throw new SpeculationError();
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Run `fn` speculatively. Any diagnostic raised while it runs (which aborts
|
|
76
|
+
* the attempt via `SpeculationError`) is rolled back along with the scanner
|
|
77
|
+
* position, so the parser can try a different production cleanly.
|
|
78
|
+
*/
|
|
79
|
+
tryParse(fn) {
|
|
80
|
+
const mark = this.diagnostics.mark();
|
|
81
|
+
const state = this.saveState();
|
|
82
|
+
this.speculating++;
|
|
83
|
+
let result;
|
|
84
|
+
let ok = false;
|
|
85
|
+
try {
|
|
86
|
+
result = fn();
|
|
87
|
+
ok = true;
|
|
88
|
+
}
|
|
89
|
+
catch (error) {
|
|
90
|
+
if (!(error instanceof SpeculationError))
|
|
91
|
+
throw error;
|
|
92
|
+
}
|
|
93
|
+
finally {
|
|
94
|
+
this.speculating--;
|
|
95
|
+
}
|
|
96
|
+
if (!ok) {
|
|
97
|
+
this.diagnostics.reset(mark);
|
|
98
|
+
this.restoreState(state);
|
|
99
|
+
return undefined;
|
|
100
|
+
}
|
|
101
|
+
return result;
|
|
102
|
+
}
|
|
103
|
+
isIdentifierLike(token) {
|
|
104
|
+
if (token.kind === TokenKind.Identifier)
|
|
105
|
+
return true;
|
|
106
|
+
switch (token.kind) {
|
|
107
|
+
case TokenKind.AsKeyword:
|
|
108
|
+
case TokenKind.SatisfiesKeyword:
|
|
109
|
+
case TokenKind.FromKeyword:
|
|
110
|
+
case TokenKind.TypeKeyword:
|
|
111
|
+
case TokenKind.GetKeyword:
|
|
112
|
+
case TokenKind.SetKeyword:
|
|
113
|
+
case TokenKind.AsyncKeyword:
|
|
114
|
+
return true;
|
|
115
|
+
default:
|
|
116
|
+
return false;
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
parseIdentifier(allowKeywords = false) {
|
|
120
|
+
const token = this.token;
|
|
121
|
+
if (token.kind === TokenKind.Identifier || (allowKeywords && this.isIdentifierLike(token))) {
|
|
122
|
+
this.nextToken();
|
|
123
|
+
return { kind: SyntaxKind.Identifier, text: token.text, start: token.start, end: token.end };
|
|
124
|
+
}
|
|
125
|
+
this.error(DiagnosticCode.ExpectedIdentifier, `Expected identifier but found '${token.text || token.kind}'`);
|
|
126
|
+
if (token.kind !== TokenKind.EndOfFile)
|
|
127
|
+
this.nextToken();
|
|
128
|
+
return { kind: SyntaxKind.Identifier, text: token.text || "missing", start: token.start, end: token.end };
|
|
129
|
+
}
|
|
130
|
+
parseIdentifierName() {
|
|
131
|
+
return this.parseIdentifier(/* allowKeywords */ true);
|
|
132
|
+
}
|
|
133
|
+
parseSemicolon() {
|
|
134
|
+
if (this.at(TokenKind.Semicolon)) {
|
|
135
|
+
this.nextToken();
|
|
136
|
+
return;
|
|
137
|
+
}
|
|
138
|
+
if (this.canInsertSemicolon())
|
|
139
|
+
return;
|
|
140
|
+
this.error(DiagnosticCode.ExpectedToken, "Expected ';'", this.token);
|
|
141
|
+
}
|
|
142
|
+
canInsertSemicolon() {
|
|
143
|
+
return this.at(TokenKind.EndOfFile) || this.at(TokenKind.CloseBrace) || this.token.precededByLineBreak;
|
|
144
|
+
}
|
|
145
|
+
parseDelimitedList(close, parseElement) {
|
|
146
|
+
const items = [];
|
|
147
|
+
while (this.token.kind !== close && !this.at(TokenKind.EndOfFile)) {
|
|
148
|
+
const before = this.consumed;
|
|
149
|
+
items.push(parseElement());
|
|
150
|
+
if (this.at(TokenKind.Comma))
|
|
151
|
+
this.nextToken();
|
|
152
|
+
else
|
|
153
|
+
break;
|
|
154
|
+
if (this.consumed === before && this.token.kind !== close)
|
|
155
|
+
this.nextToken();
|
|
156
|
+
}
|
|
157
|
+
this.parseExpected(close);
|
|
158
|
+
return items;
|
|
159
|
+
}
|
|
160
|
+
stringLiteralFromToken(token) {
|
|
161
|
+
return { kind: SyntaxKind.StringLiteral, text: token.text, raw: token.text, value: String(token.value ?? ""), start: token.start, end: token.end };
|
|
162
|
+
}
|
|
163
|
+
// -- state save / restore (for speculative parsing) -----------------------
|
|
164
|
+
saveState() {
|
|
165
|
+
return { index: this.index, tokens: this.tokens.slice(), pos: this.scanner.position, consumed: this.consumed };
|
|
166
|
+
}
|
|
167
|
+
restoreState(state) {
|
|
168
|
+
this.index = state.index;
|
|
169
|
+
this.tokens = state.tokens;
|
|
170
|
+
this.scanner.seek(state.pos);
|
|
171
|
+
this.consumed = state.consumed;
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
//# sourceMappingURL=context.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"context.js","sourceRoot":"","sources":["../../../src/parser/context.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAiB,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAE7E,OAAO,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAC9C,OAAO,EAAS,SAAS,EAAE,MAAM,mBAAmB,CAAC;AACrD,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAE7C,OAAO,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AASpD,MAAM,OAAO,aAAa;IACf,OAAO,CAAU;IACjB,WAAW,CAAgB;IAC3B,MAAM,CAAa;IAC5B,MAAM,CAAU;IAChB,KAAK,GAAG,CAAC,CAAC;IACV,+EAA+E;IAC/E,WAAW,GAAG,CAAC,CAAC;IAChB,2EAA2E;IAC3E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C,KAAK,CAAC,GAAG,CAAC,CAAC;QAC7B,IAAI,CAAC,QAAQ,GAAG,KAAK,CAAC,QAAQ,CAAC;IACjC,CAAC;CACF"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Declaration parsing: functions, classes, interfaces, type aliases, enums,
|
|
3
|
+
* namespaces and type members.
|
|
4
|
+
*/
|
|
5
|
+
import { type ClassDeclaration, type ClassElement, type EnumDeclaration, type FunctionDeclaration, type HeritageClause, type InterfaceDeclaration, type Modifier, type ModuleDeclaration, type Parameter, type PropertyName, type TypeAliasDeclaration, type TypeElement, type TypeNode, type TypeParameterDeclaration } from "../ast/nodes.js";
|
|
6
|
+
import type { Parser } from "./parser.js";
|
|
7
|
+
export interface DeclarationMethods {
|
|
8
|
+
parseFunctionDeclaration(this: Parser, modifiers: Modifier[]): FunctionDeclaration;
|
|
9
|
+
parseTypeParameters(this: Parser): TypeParameterDeclaration[];
|
|
10
|
+
parseGreaterThan(this: Parser): void;
|
|
11
|
+
parseParameters(this: Parser): Parameter[];
|
|
12
|
+
parseReturnType(this: Parser): TypeNode;
|
|
13
|
+
parseClassDeclaration(this: Parser, modifiers: Modifier[]): ClassDeclaration;
|
|
14
|
+
parseHeritageClauses(this: Parser): HeritageClause[];
|
|
15
|
+
parseClassMembers(this: Parser): ClassElement[];
|
|
16
|
+
parseClassElement(this: Parser): ClassElement | undefined;
|
|
17
|
+
parsePropertyName(this: Parser): PropertyName;
|
|
18
|
+
parseInterfaceDeclaration(this: Parser, modifiers: Modifier[]): InterfaceDeclaration;
|
|
19
|
+
parseTypeAliasDeclaration(this: Parser, modifiers: Modifier[]): TypeAliasDeclaration;
|
|
20
|
+
parseEnumDeclaration(this: Parser, modifiers: Modifier[]): EnumDeclaration;
|
|
21
|
+
parseModuleDeclaration(this: Parser, modifiers: Modifier[]): ModuleDeclaration;
|
|
22
|
+
parseTypeMembers(this: Parser): TypeElement[];
|
|
23
|
+
parseTypeMember(this: Parser): TypeElement | undefined;
|
|
24
|
+
parseSemicolonOrComma(this: Parser): void;
|
|
25
|
+
}
|
|
26
|
+
export declare const declarationMethods: DeclarationMethods;
|