@danielblomma/cortex-mcp 1.3.2 → 1.4.0
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 +62 -14
- package/package.json +2 -2
- package/scaffold/mcp/package-lock.json +3 -7
- package/scaffold/mcp/package.json +1 -1
- package/scaffold/scripts/dashboard.mjs +15 -1
- package/scaffold/scripts/ingest.mjs +323 -50
- package/scaffold/scripts/parsers/bash-treesitter.mjs +229 -0
- package/scaffold/scripts/parsers/cpp-dispatch.mjs +56 -0
- package/scaffold/scripts/parsers/cpp-treesitter.mjs +333 -0
- package/scaffold/scripts/parsers/csharp.mjs +197 -10
- package/scaffold/scripts/parsers/dotnet/CSharpParser/CSharpParser.csproj +1 -0
- package/scaffold/scripts/parsers/dotnet/CSharpParser/Program.cs +126 -21
- package/scaffold/scripts/parsers/go-treesitter.mjs +283 -0
- package/scaffold/scripts/parsers/java-treesitter.mjs +250 -0
- package/scaffold/scripts/parsers/javascript/ast.mjs +118 -12
- package/scaffold/scripts/parsers/javascript/chunks.mjs +4 -0
- package/scaffold/scripts/parsers/javascript/patterns.mjs +6 -0
- package/scaffold/scripts/parsers/javascript.mjs +4 -19
- package/scaffold/scripts/parsers/node_modules/.package-lock.json +57 -0
- package/scaffold/scripts/parsers/node_modules/acorn/CHANGELOG.md +972 -0
- package/scaffold/scripts/parsers/node_modules/acorn/LICENSE +21 -0
- package/scaffold/scripts/parsers/node_modules/acorn/README.md +301 -0
- package/scaffold/scripts/parsers/node_modules/acorn/bin/acorn +4 -0
- package/scaffold/scripts/parsers/node_modules/acorn/dist/acorn.d.mts +883 -0
- package/scaffold/scripts/parsers/node_modules/acorn/dist/acorn.d.ts +883 -0
- package/scaffold/scripts/parsers/node_modules/acorn/dist/acorn.js +6295 -0
- package/scaffold/scripts/parsers/node_modules/acorn/dist/acorn.mjs +6266 -0
- package/scaffold/scripts/parsers/node_modules/acorn/dist/bin.js +90 -0
- package/scaffold/scripts/parsers/node_modules/acorn/package.json +50 -0
- package/scaffold/scripts/parsers/node_modules/acorn-typescript/CHANGELOG.md +421 -0
- package/scaffold/scripts/parsers/node_modules/acorn-typescript/LICENSE +21 -0
- package/scaffold/scripts/parsers/node_modules/acorn-typescript/README.md +81 -0
- package/scaffold/scripts/parsers/node_modules/acorn-typescript/lib/error.d.ts +103 -0
- package/scaffold/scripts/parsers/node_modules/acorn-typescript/lib/error.js +78 -0
- package/scaffold/scripts/parsers/node_modules/acorn-typescript/lib/error.js.map +1 -0
- package/scaffold/scripts/parsers/node_modules/acorn-typescript/lib/extentions/decorators.d.ts +167 -0
- package/scaffold/scripts/parsers/node_modules/acorn-typescript/lib/extentions/decorators.js +75 -0
- package/scaffold/scripts/parsers/node_modules/acorn-typescript/lib/extentions/decorators.js.map +1 -0
- package/scaffold/scripts/parsers/node_modules/acorn-typescript/lib/extentions/import-assertions.d.ts +177 -0
- package/scaffold/scripts/parsers/node_modules/acorn-typescript/lib/extentions/import-assertions.js +56 -0
- package/scaffold/scripts/parsers/node_modules/acorn-typescript/lib/extentions/import-assertions.js.map +1 -0
- package/scaffold/scripts/parsers/node_modules/acorn-typescript/lib/extentions/jsx/index.d.ts +198 -0
- package/scaffold/scripts/parsers/node_modules/acorn-typescript/lib/extentions/jsx/index.js +327 -0
- package/scaffold/scripts/parsers/node_modules/acorn-typescript/lib/extentions/jsx/index.js.map +1 -0
- package/scaffold/scripts/parsers/node_modules/acorn-typescript/lib/extentions/jsx/xhtml.d.ts +256 -0
- package/scaffold/scripts/parsers/node_modules/acorn-typescript/lib/extentions/jsx/xhtml.js +256 -0
- package/scaffold/scripts/parsers/node_modules/acorn-typescript/lib/extentions/jsx/xhtml.js.map +1 -0
- package/scaffold/scripts/parsers/node_modules/acorn-typescript/lib/index.d.ts +472 -0
- package/scaffold/scripts/parsers/node_modules/acorn-typescript/lib/index.js +1 -0
- package/scaffold/scripts/parsers/node_modules/acorn-typescript/lib/index.js.map +1 -0
- package/scaffold/scripts/parsers/node_modules/acorn-typescript/lib/index.mjs +1 -0
- package/scaffold/scripts/parsers/node_modules/acorn-typescript/lib/middleware.d.ts +159 -0
- package/scaffold/scripts/parsers/node_modules/acorn-typescript/lib/middleware.js +2 -0
- package/scaffold/scripts/parsers/node_modules/acorn-typescript/lib/middleware.js.map +1 -0
- package/scaffold/scripts/parsers/node_modules/acorn-typescript/lib/parseutil.d.ts +10 -0
- package/scaffold/scripts/parsers/node_modules/acorn-typescript/lib/parseutil.js +38 -0
- package/scaffold/scripts/parsers/node_modules/acorn-typescript/lib/parseutil.js.map +1 -0
- package/scaffold/scripts/parsers/node_modules/acorn-typescript/lib/scopeflags.d.ts +12 -0
- package/scaffold/scripts/parsers/node_modules/acorn-typescript/lib/scopeflags.js +29 -0
- package/scaffold/scripts/parsers/node_modules/acorn-typescript/lib/scopeflags.js.map +1 -0
- package/scaffold/scripts/parsers/node_modules/acorn-typescript/lib/tokenType.d.ts +2 -0
- package/scaffold/scripts/parsers/node_modules/acorn-typescript/lib/tokenType.js +118 -0
- package/scaffold/scripts/parsers/node_modules/acorn-typescript/lib/tokenType.js.map +1 -0
- package/scaffold/scripts/parsers/node_modules/acorn-typescript/lib/types.d.ts +60 -0
- package/scaffold/scripts/parsers/node_modules/acorn-typescript/lib/types.js +2 -0
- package/scaffold/scripts/parsers/node_modules/acorn-typescript/lib/types.js.map +1 -0
- package/scaffold/scripts/parsers/node_modules/acorn-typescript/lib/whitespace.d.ts +2 -0
- package/scaffold/scripts/parsers/node_modules/acorn-typescript/lib/whitespace.js +19 -0
- package/scaffold/scripts/parsers/node_modules/acorn-typescript/lib/whitespace.js.map +1 -0
- package/scaffold/scripts/parsers/node_modules/acorn-typescript/package.json +53 -0
- package/scaffold/scripts/parsers/node_modules/acorn-typescript/tsconfig.json +19 -0
- package/scaffold/scripts/parsers/node_modules/acorn-walk/CHANGELOG.md +209 -0
- package/scaffold/scripts/parsers/node_modules/acorn-walk/LICENSE +21 -0
- package/scaffold/scripts/parsers/node_modules/acorn-walk/README.md +124 -0
- package/scaffold/scripts/parsers/node_modules/acorn-walk/dist/walk.d.mts +152 -0
- package/scaffold/scripts/parsers/node_modules/acorn-walk/dist/walk.d.ts +152 -0
- package/scaffold/scripts/parsers/node_modules/acorn-walk/dist/walk.js +485 -0
- package/scaffold/scripts/parsers/node_modules/acorn-walk/dist/walk.mjs +467 -0
- package/scaffold/scripts/parsers/node_modules/acorn-walk/package.json +50 -0
- package/scaffold/scripts/parsers/node_modules/tree-sitter-wasms/LICENSE +24 -0
- package/scaffold/scripts/parsers/node_modules/tree-sitter-wasms/README.md +23 -0
- package/scaffold/scripts/parsers/node_modules/tree-sitter-wasms/out/tree-sitter-bash.wasm +0 -0
- package/scaffold/scripts/parsers/node_modules/tree-sitter-wasms/out/tree-sitter-c.wasm +0 -0
- package/scaffold/scripts/parsers/node_modules/tree-sitter-wasms/out/tree-sitter-c_sharp.wasm +0 -0
- package/scaffold/scripts/parsers/node_modules/tree-sitter-wasms/out/tree-sitter-cpp.wasm +0 -0
- package/scaffold/scripts/parsers/node_modules/tree-sitter-wasms/out/tree-sitter-css.wasm +0 -0
- package/scaffold/scripts/parsers/node_modules/tree-sitter-wasms/out/tree-sitter-dart.wasm +0 -0
- package/scaffold/scripts/parsers/node_modules/tree-sitter-wasms/out/tree-sitter-elisp.wasm +0 -0
- package/scaffold/scripts/parsers/node_modules/tree-sitter-wasms/out/tree-sitter-elixir.wasm +0 -0
- package/scaffold/scripts/parsers/node_modules/tree-sitter-wasms/out/tree-sitter-elm.wasm +0 -0
- package/scaffold/scripts/parsers/node_modules/tree-sitter-wasms/out/tree-sitter-embedded_template.wasm +0 -0
- package/scaffold/scripts/parsers/node_modules/tree-sitter-wasms/out/tree-sitter-go.wasm +0 -0
- package/scaffold/scripts/parsers/node_modules/tree-sitter-wasms/out/tree-sitter-html.wasm +0 -0
- package/scaffold/scripts/parsers/node_modules/tree-sitter-wasms/out/tree-sitter-java.wasm +0 -0
- package/scaffold/scripts/parsers/node_modules/tree-sitter-wasms/out/tree-sitter-javascript.wasm +0 -0
- package/scaffold/scripts/parsers/node_modules/tree-sitter-wasms/out/tree-sitter-json.wasm +0 -0
- package/scaffold/scripts/parsers/node_modules/tree-sitter-wasms/out/tree-sitter-kotlin.wasm +0 -0
- package/scaffold/scripts/parsers/node_modules/tree-sitter-wasms/out/tree-sitter-lua.wasm +0 -0
- package/scaffold/scripts/parsers/node_modules/tree-sitter-wasms/out/tree-sitter-objc.wasm +0 -0
- package/scaffold/scripts/parsers/node_modules/tree-sitter-wasms/out/tree-sitter-ocaml.wasm +0 -0
- package/scaffold/scripts/parsers/node_modules/tree-sitter-wasms/out/tree-sitter-php.wasm +0 -0
- package/scaffold/scripts/parsers/node_modules/tree-sitter-wasms/out/tree-sitter-python.wasm +0 -0
- package/scaffold/scripts/parsers/node_modules/tree-sitter-wasms/out/tree-sitter-ql.wasm +0 -0
- package/scaffold/scripts/parsers/node_modules/tree-sitter-wasms/out/tree-sitter-rescript.wasm +0 -0
- package/scaffold/scripts/parsers/node_modules/tree-sitter-wasms/out/tree-sitter-ruby.wasm +0 -0
- package/scaffold/scripts/parsers/node_modules/tree-sitter-wasms/out/tree-sitter-rust.wasm +0 -0
- package/scaffold/scripts/parsers/node_modules/tree-sitter-wasms/out/tree-sitter-scala.wasm +0 -0
- package/scaffold/scripts/parsers/node_modules/tree-sitter-wasms/out/tree-sitter-solidity.wasm +0 -0
- package/scaffold/scripts/parsers/node_modules/tree-sitter-wasms/out/tree-sitter-swift.wasm +0 -0
- package/scaffold/scripts/parsers/node_modules/tree-sitter-wasms/out/tree-sitter-systemrdl.wasm +0 -0
- package/scaffold/scripts/parsers/node_modules/tree-sitter-wasms/out/tree-sitter-tlaplus.wasm +0 -0
- package/scaffold/scripts/parsers/node_modules/tree-sitter-wasms/out/tree-sitter-toml.wasm +0 -0
- package/scaffold/scripts/parsers/node_modules/tree-sitter-wasms/out/tree-sitter-tsx.wasm +0 -0
- package/scaffold/scripts/parsers/node_modules/tree-sitter-wasms/out/tree-sitter-typescript.wasm +0 -0
- package/scaffold/scripts/parsers/node_modules/tree-sitter-wasms/out/tree-sitter-vue.wasm +0 -0
- package/scaffold/scripts/parsers/node_modules/tree-sitter-wasms/out/tree-sitter-yaml.wasm +0 -0
- package/scaffold/scripts/parsers/node_modules/tree-sitter-wasms/out/tree-sitter-zig.wasm +0 -0
- package/scaffold/scripts/parsers/node_modules/tree-sitter-wasms/package.json +64 -0
- package/scaffold/scripts/parsers/node_modules/web-tree-sitter/LICENSE +21 -0
- package/scaffold/scripts/parsers/node_modules/web-tree-sitter/README.md +198 -0
- package/scaffold/scripts/parsers/node_modules/web-tree-sitter/package.json +37 -0
- package/scaffold/scripts/parsers/node_modules/web-tree-sitter/tree-sitter-web.d.ts +242 -0
- package/scaffold/scripts/parsers/node_modules/web-tree-sitter/tree-sitter.js +1 -0
- package/scaffold/scripts/parsers/node_modules/web-tree-sitter/tree-sitter.wasm +0 -0
- package/scaffold/scripts/parsers/package-lock.json +19 -1
- package/scaffold/scripts/parsers/package.json +3 -1
- package/scaffold/scripts/parsers/python-treesitter.mjs +271 -0
- package/scaffold/scripts/parsers/ruby-treesitter.mjs +271 -0
- package/scaffold/scripts/parsers/rust-dispatch.mjs +43 -0
- package/scaffold/scripts/parsers/rust-treesitter.mjs +291 -0
- package/scaffold/scripts/parsers/tree-sitter/base.mjs +163 -0
- package/scaffold/scripts/parsers/tree-sitter/queries/bash.calls.scm +7 -0
- package/scaffold/scripts/parsers/tree-sitter/queries/bash.chunks.scm +6 -0
- package/scaffold/scripts/parsers/tree-sitter/queries/bash.imports.scm +5 -0
- package/scaffold/scripts/parsers/tree-sitter/queries/cpp.calls.scm +17 -0
- package/scaffold/scripts/parsers/tree-sitter/queries/cpp.chunks.scm +30 -0
- package/scaffold/scripts/parsers/tree-sitter/queries/cpp.imports.scm +6 -0
- package/scaffold/scripts/parsers/tree-sitter/queries/go.calls.scm +11 -0
- package/scaffold/scripts/parsers/tree-sitter/queries/go.chunks.scm +19 -0
- package/scaffold/scripts/parsers/tree-sitter/queries/go.imports.scm +6 -0
- package/scaffold/scripts/parsers/tree-sitter/queries/java.calls.scm +6 -0
- package/scaffold/scripts/parsers/tree-sitter/queries/java.chunks.scm +23 -0
- package/scaffold/scripts/parsers/tree-sitter/queries/java.imports.scm +6 -0
- package/scaffold/scripts/parsers/tree-sitter/queries/python.calls.scm +11 -0
- package/scaffold/scripts/parsers/tree-sitter/queries/python.chunks.scm +11 -0
- package/scaffold/scripts/parsers/tree-sitter/queries/python.imports.scm +13 -0
- package/scaffold/scripts/parsers/tree-sitter/queries/ruby.calls.scm +6 -0
- package/scaffold/scripts/parsers/tree-sitter/queries/ruby.chunks.scm +16 -0
- package/scaffold/scripts/parsers/tree-sitter/queries/ruby.imports.scm +8 -0
- package/scaffold/scripts/parsers/tree-sitter/queries/rust.calls.scm +31 -0
- package/scaffold/scripts/parsers/tree-sitter/queries/rust.chunks.scm +29 -0
- package/scaffold/scripts/parsers/tree-sitter/queries/rust.imports.scm +5 -0
- package/scaffold/scripts/parsers/vb6.mjs +395 -0
|
@@ -0,0 +1,883 @@
|
|
|
1
|
+
export interface Node {
|
|
2
|
+
start: number
|
|
3
|
+
end: number
|
|
4
|
+
type: string
|
|
5
|
+
range?: [number, number]
|
|
6
|
+
loc?: SourceLocation | null
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export interface SourceLocation {
|
|
10
|
+
source?: string | null
|
|
11
|
+
start: Position
|
|
12
|
+
end: Position
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export interface Position {
|
|
16
|
+
/** 1-based */
|
|
17
|
+
line: number
|
|
18
|
+
/** 0-based */
|
|
19
|
+
column: number
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export interface Identifier extends Node {
|
|
23
|
+
type: "Identifier"
|
|
24
|
+
name: string
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export interface Literal extends Node {
|
|
28
|
+
type: "Literal"
|
|
29
|
+
value?: string | boolean | null | number | RegExp | bigint
|
|
30
|
+
raw?: string
|
|
31
|
+
regex?: {
|
|
32
|
+
pattern: string
|
|
33
|
+
flags: string
|
|
34
|
+
}
|
|
35
|
+
bigint?: string
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export interface Program extends Node {
|
|
39
|
+
type: "Program"
|
|
40
|
+
body: Array<Statement | ModuleDeclaration>
|
|
41
|
+
sourceType: "script" | "module"
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export interface Function extends Node {
|
|
45
|
+
id?: Identifier | null
|
|
46
|
+
params: Array<Pattern>
|
|
47
|
+
body: BlockStatement | Expression
|
|
48
|
+
generator: boolean
|
|
49
|
+
expression: boolean
|
|
50
|
+
async: boolean
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
export interface ExpressionStatement extends Node {
|
|
54
|
+
type: "ExpressionStatement"
|
|
55
|
+
expression: Expression | Literal
|
|
56
|
+
directive?: string
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
export interface BlockStatement extends Node {
|
|
60
|
+
type: "BlockStatement"
|
|
61
|
+
body: Array<Statement>
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
export interface EmptyStatement extends Node {
|
|
65
|
+
type: "EmptyStatement"
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
export interface DebuggerStatement extends Node {
|
|
69
|
+
type: "DebuggerStatement"
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
export interface WithStatement extends Node {
|
|
73
|
+
type: "WithStatement"
|
|
74
|
+
object: Expression
|
|
75
|
+
body: Statement
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
export interface ReturnStatement extends Node {
|
|
79
|
+
type: "ReturnStatement"
|
|
80
|
+
argument?: Expression | null
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
export interface LabeledStatement extends Node {
|
|
84
|
+
type: "LabeledStatement"
|
|
85
|
+
label: Identifier
|
|
86
|
+
body: Statement
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
export interface BreakStatement extends Node {
|
|
90
|
+
type: "BreakStatement"
|
|
91
|
+
label?: Identifier | null
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
export interface ContinueStatement extends Node {
|
|
95
|
+
type: "ContinueStatement"
|
|
96
|
+
label?: Identifier | null
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
export interface IfStatement extends Node {
|
|
100
|
+
type: "IfStatement"
|
|
101
|
+
test: Expression
|
|
102
|
+
consequent: Statement
|
|
103
|
+
alternate?: Statement | null
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
export interface SwitchStatement extends Node {
|
|
107
|
+
type: "SwitchStatement"
|
|
108
|
+
discriminant: Expression
|
|
109
|
+
cases: Array<SwitchCase>
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
export interface SwitchCase extends Node {
|
|
113
|
+
type: "SwitchCase"
|
|
114
|
+
test?: Expression | null
|
|
115
|
+
consequent: Array<Statement>
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
export interface ThrowStatement extends Node {
|
|
119
|
+
type: "ThrowStatement"
|
|
120
|
+
argument: Expression
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
export interface TryStatement extends Node {
|
|
124
|
+
type: "TryStatement"
|
|
125
|
+
block: BlockStatement
|
|
126
|
+
handler?: CatchClause | null
|
|
127
|
+
finalizer?: BlockStatement | null
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
export interface CatchClause extends Node {
|
|
131
|
+
type: "CatchClause"
|
|
132
|
+
param?: Pattern | null
|
|
133
|
+
body: BlockStatement
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
export interface WhileStatement extends Node {
|
|
137
|
+
type: "WhileStatement"
|
|
138
|
+
test: Expression
|
|
139
|
+
body: Statement
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
export interface DoWhileStatement extends Node {
|
|
143
|
+
type: "DoWhileStatement"
|
|
144
|
+
body: Statement
|
|
145
|
+
test: Expression
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
export interface ForStatement extends Node {
|
|
149
|
+
type: "ForStatement"
|
|
150
|
+
init?: VariableDeclaration | Expression | null
|
|
151
|
+
test?: Expression | null
|
|
152
|
+
update?: Expression | null
|
|
153
|
+
body: Statement
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
export interface ForInStatement extends Node {
|
|
157
|
+
type: "ForInStatement"
|
|
158
|
+
left: VariableDeclaration | Pattern
|
|
159
|
+
right: Expression
|
|
160
|
+
body: Statement
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
export interface FunctionDeclaration extends Function {
|
|
164
|
+
type: "FunctionDeclaration"
|
|
165
|
+
id: Identifier
|
|
166
|
+
body: BlockStatement
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
export interface VariableDeclaration extends Node {
|
|
170
|
+
type: "VariableDeclaration"
|
|
171
|
+
declarations: Array<VariableDeclarator>
|
|
172
|
+
kind: "var" | "let" | "const" | "using" | "await using"
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
export interface VariableDeclarator extends Node {
|
|
176
|
+
type: "VariableDeclarator"
|
|
177
|
+
id: Pattern
|
|
178
|
+
init?: Expression | null
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
export interface ThisExpression extends Node {
|
|
182
|
+
type: "ThisExpression"
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
export interface ArrayExpression extends Node {
|
|
186
|
+
type: "ArrayExpression"
|
|
187
|
+
elements: Array<Expression | SpreadElement | null>
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
export interface ObjectExpression extends Node {
|
|
191
|
+
type: "ObjectExpression"
|
|
192
|
+
properties: Array<Property | SpreadElement>
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
export interface Property extends Node {
|
|
196
|
+
type: "Property"
|
|
197
|
+
key: Expression
|
|
198
|
+
value: Expression
|
|
199
|
+
kind: "init" | "get" | "set"
|
|
200
|
+
method: boolean
|
|
201
|
+
shorthand: boolean
|
|
202
|
+
computed: boolean
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
export interface FunctionExpression extends Function {
|
|
206
|
+
type: "FunctionExpression"
|
|
207
|
+
body: BlockStatement
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
export interface UnaryExpression extends Node {
|
|
211
|
+
type: "UnaryExpression"
|
|
212
|
+
operator: UnaryOperator
|
|
213
|
+
prefix: boolean
|
|
214
|
+
argument: Expression
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
export type UnaryOperator = "-" | "+" | "!" | "~" | "typeof" | "void" | "delete"
|
|
218
|
+
|
|
219
|
+
export interface UpdateExpression extends Node {
|
|
220
|
+
type: "UpdateExpression"
|
|
221
|
+
operator: UpdateOperator
|
|
222
|
+
argument: Expression
|
|
223
|
+
prefix: boolean
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
export type UpdateOperator = "++" | "--"
|
|
227
|
+
|
|
228
|
+
export interface BinaryExpression extends Node {
|
|
229
|
+
type: "BinaryExpression"
|
|
230
|
+
operator: BinaryOperator
|
|
231
|
+
left: Expression | PrivateIdentifier
|
|
232
|
+
right: Expression
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
export type BinaryOperator = "==" | "!=" | "===" | "!==" | "<" | "<=" | ">" | ">=" | "<<" | ">>" | ">>>" | "+" | "-" | "*" | "/" | "%" | "|" | "^" | "&" | "in" | "instanceof" | "**"
|
|
236
|
+
|
|
237
|
+
export interface AssignmentExpression extends Node {
|
|
238
|
+
type: "AssignmentExpression"
|
|
239
|
+
operator: AssignmentOperator
|
|
240
|
+
left: Pattern
|
|
241
|
+
right: Expression
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
export type AssignmentOperator = "=" | "+=" | "-=" | "*=" | "/=" | "%=" | "<<=" | ">>=" | ">>>=" | "|=" | "^=" | "&=" | "**=" | "||=" | "&&=" | "??="
|
|
245
|
+
|
|
246
|
+
export interface LogicalExpression extends Node {
|
|
247
|
+
type: "LogicalExpression"
|
|
248
|
+
operator: LogicalOperator
|
|
249
|
+
left: Expression
|
|
250
|
+
right: Expression
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
export type LogicalOperator = "||" | "&&" | "??"
|
|
254
|
+
|
|
255
|
+
export interface MemberExpression extends Node {
|
|
256
|
+
type: "MemberExpression"
|
|
257
|
+
object: Expression | Super
|
|
258
|
+
property: Expression | PrivateIdentifier
|
|
259
|
+
computed: boolean
|
|
260
|
+
optional: boolean
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
export interface ConditionalExpression extends Node {
|
|
264
|
+
type: "ConditionalExpression"
|
|
265
|
+
test: Expression
|
|
266
|
+
alternate: Expression
|
|
267
|
+
consequent: Expression
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
export interface CallExpression extends Node {
|
|
271
|
+
type: "CallExpression"
|
|
272
|
+
callee: Expression | Super
|
|
273
|
+
arguments: Array<Expression | SpreadElement>
|
|
274
|
+
optional: boolean
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
export interface NewExpression extends Node {
|
|
278
|
+
type: "NewExpression"
|
|
279
|
+
callee: Expression
|
|
280
|
+
arguments: Array<Expression | SpreadElement>
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
export interface SequenceExpression extends Node {
|
|
284
|
+
type: "SequenceExpression"
|
|
285
|
+
expressions: Array<Expression>
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
export interface ForOfStatement extends Node {
|
|
289
|
+
type: "ForOfStatement"
|
|
290
|
+
left: VariableDeclaration | Pattern
|
|
291
|
+
right: Expression
|
|
292
|
+
body: Statement
|
|
293
|
+
await: boolean
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
export interface Super extends Node {
|
|
297
|
+
type: "Super"
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
export interface SpreadElement extends Node {
|
|
301
|
+
type: "SpreadElement"
|
|
302
|
+
argument: Expression
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
export interface ArrowFunctionExpression extends Function {
|
|
306
|
+
type: "ArrowFunctionExpression"
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
export interface YieldExpression extends Node {
|
|
310
|
+
type: "YieldExpression"
|
|
311
|
+
argument?: Expression | null
|
|
312
|
+
delegate: boolean
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
export interface TemplateLiteral extends Node {
|
|
316
|
+
type: "TemplateLiteral"
|
|
317
|
+
quasis: Array<TemplateElement>
|
|
318
|
+
expressions: Array<Expression>
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
export interface TaggedTemplateExpression extends Node {
|
|
322
|
+
type: "TaggedTemplateExpression"
|
|
323
|
+
tag: Expression
|
|
324
|
+
quasi: TemplateLiteral
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
export interface TemplateElement extends Node {
|
|
328
|
+
type: "TemplateElement"
|
|
329
|
+
tail: boolean
|
|
330
|
+
value: {
|
|
331
|
+
cooked?: string | null
|
|
332
|
+
raw: string
|
|
333
|
+
}
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
export interface AssignmentProperty extends Node {
|
|
337
|
+
type: "Property"
|
|
338
|
+
key: Expression
|
|
339
|
+
value: Pattern
|
|
340
|
+
kind: "init"
|
|
341
|
+
method: false
|
|
342
|
+
shorthand: boolean
|
|
343
|
+
computed: boolean
|
|
344
|
+
}
|
|
345
|
+
|
|
346
|
+
export interface ObjectPattern extends Node {
|
|
347
|
+
type: "ObjectPattern"
|
|
348
|
+
properties: Array<AssignmentProperty | RestElement>
|
|
349
|
+
}
|
|
350
|
+
|
|
351
|
+
export interface ArrayPattern extends Node {
|
|
352
|
+
type: "ArrayPattern"
|
|
353
|
+
elements: Array<Pattern | null>
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
export interface RestElement extends Node {
|
|
357
|
+
type: "RestElement"
|
|
358
|
+
argument: Pattern
|
|
359
|
+
}
|
|
360
|
+
|
|
361
|
+
export interface AssignmentPattern extends Node {
|
|
362
|
+
type: "AssignmentPattern"
|
|
363
|
+
left: Pattern
|
|
364
|
+
right: Expression
|
|
365
|
+
}
|
|
366
|
+
|
|
367
|
+
export interface Class extends Node {
|
|
368
|
+
id?: Identifier | null
|
|
369
|
+
superClass?: Expression | null
|
|
370
|
+
body: ClassBody
|
|
371
|
+
}
|
|
372
|
+
|
|
373
|
+
export interface ClassBody extends Node {
|
|
374
|
+
type: "ClassBody"
|
|
375
|
+
body: Array<MethodDefinition | PropertyDefinition | StaticBlock>
|
|
376
|
+
}
|
|
377
|
+
|
|
378
|
+
export interface MethodDefinition extends Node {
|
|
379
|
+
type: "MethodDefinition"
|
|
380
|
+
key: Expression | PrivateIdentifier
|
|
381
|
+
value: FunctionExpression
|
|
382
|
+
kind: "constructor" | "method" | "get" | "set"
|
|
383
|
+
computed: boolean
|
|
384
|
+
static: boolean
|
|
385
|
+
}
|
|
386
|
+
|
|
387
|
+
export interface ClassDeclaration extends Class {
|
|
388
|
+
type: "ClassDeclaration"
|
|
389
|
+
id: Identifier
|
|
390
|
+
}
|
|
391
|
+
|
|
392
|
+
export interface ClassExpression extends Class {
|
|
393
|
+
type: "ClassExpression"
|
|
394
|
+
}
|
|
395
|
+
|
|
396
|
+
export interface MetaProperty extends Node {
|
|
397
|
+
type: "MetaProperty"
|
|
398
|
+
meta: Identifier
|
|
399
|
+
property: Identifier
|
|
400
|
+
}
|
|
401
|
+
|
|
402
|
+
export interface ImportDeclaration extends Node {
|
|
403
|
+
type: "ImportDeclaration"
|
|
404
|
+
specifiers: Array<ImportSpecifier | ImportDefaultSpecifier | ImportNamespaceSpecifier>
|
|
405
|
+
source: Literal
|
|
406
|
+
attributes: Array<ImportAttribute>
|
|
407
|
+
}
|
|
408
|
+
|
|
409
|
+
export interface ImportSpecifier extends Node {
|
|
410
|
+
type: "ImportSpecifier"
|
|
411
|
+
imported: Identifier | Literal
|
|
412
|
+
local: Identifier
|
|
413
|
+
}
|
|
414
|
+
|
|
415
|
+
export interface ImportDefaultSpecifier extends Node {
|
|
416
|
+
type: "ImportDefaultSpecifier"
|
|
417
|
+
local: Identifier
|
|
418
|
+
}
|
|
419
|
+
|
|
420
|
+
export interface ImportNamespaceSpecifier extends Node {
|
|
421
|
+
type: "ImportNamespaceSpecifier"
|
|
422
|
+
local: Identifier
|
|
423
|
+
}
|
|
424
|
+
|
|
425
|
+
export interface ImportAttribute extends Node {
|
|
426
|
+
type: "ImportAttribute"
|
|
427
|
+
key: Identifier | Literal
|
|
428
|
+
value: Literal
|
|
429
|
+
}
|
|
430
|
+
|
|
431
|
+
export interface ExportNamedDeclaration extends Node {
|
|
432
|
+
type: "ExportNamedDeclaration"
|
|
433
|
+
declaration?: Declaration | null
|
|
434
|
+
specifiers: Array<ExportSpecifier>
|
|
435
|
+
source?: Literal | null
|
|
436
|
+
attributes: Array<ImportAttribute>
|
|
437
|
+
}
|
|
438
|
+
|
|
439
|
+
export interface ExportSpecifier extends Node {
|
|
440
|
+
type: "ExportSpecifier"
|
|
441
|
+
exported: Identifier | Literal
|
|
442
|
+
local: Identifier | Literal
|
|
443
|
+
}
|
|
444
|
+
|
|
445
|
+
export interface AnonymousFunctionDeclaration extends Function {
|
|
446
|
+
type: "FunctionDeclaration"
|
|
447
|
+
id: null
|
|
448
|
+
body: BlockStatement
|
|
449
|
+
}
|
|
450
|
+
|
|
451
|
+
export interface AnonymousClassDeclaration extends Class {
|
|
452
|
+
type: "ClassDeclaration"
|
|
453
|
+
id: null
|
|
454
|
+
}
|
|
455
|
+
|
|
456
|
+
export interface ExportDefaultDeclaration extends Node {
|
|
457
|
+
type: "ExportDefaultDeclaration"
|
|
458
|
+
declaration: AnonymousFunctionDeclaration | FunctionDeclaration | AnonymousClassDeclaration | ClassDeclaration | Expression
|
|
459
|
+
}
|
|
460
|
+
|
|
461
|
+
export interface ExportAllDeclaration extends Node {
|
|
462
|
+
type: "ExportAllDeclaration"
|
|
463
|
+
source: Literal
|
|
464
|
+
exported?: Identifier | Literal | null
|
|
465
|
+
attributes: Array<ImportAttribute>
|
|
466
|
+
}
|
|
467
|
+
|
|
468
|
+
export interface AwaitExpression extends Node {
|
|
469
|
+
type: "AwaitExpression"
|
|
470
|
+
argument: Expression
|
|
471
|
+
}
|
|
472
|
+
|
|
473
|
+
export interface ChainExpression extends Node {
|
|
474
|
+
type: "ChainExpression"
|
|
475
|
+
expression: MemberExpression | CallExpression
|
|
476
|
+
}
|
|
477
|
+
|
|
478
|
+
export interface ImportExpression extends Node {
|
|
479
|
+
type: "ImportExpression"
|
|
480
|
+
source: Expression
|
|
481
|
+
options: Expression | null
|
|
482
|
+
}
|
|
483
|
+
|
|
484
|
+
export interface ParenthesizedExpression extends Node {
|
|
485
|
+
type: "ParenthesizedExpression"
|
|
486
|
+
expression: Expression
|
|
487
|
+
}
|
|
488
|
+
|
|
489
|
+
export interface PropertyDefinition extends Node {
|
|
490
|
+
type: "PropertyDefinition"
|
|
491
|
+
key: Expression | PrivateIdentifier
|
|
492
|
+
value?: Expression | null
|
|
493
|
+
computed: boolean
|
|
494
|
+
static: boolean
|
|
495
|
+
}
|
|
496
|
+
|
|
497
|
+
export interface PrivateIdentifier extends Node {
|
|
498
|
+
type: "PrivateIdentifier"
|
|
499
|
+
name: string
|
|
500
|
+
}
|
|
501
|
+
|
|
502
|
+
export interface StaticBlock extends Node {
|
|
503
|
+
type: "StaticBlock"
|
|
504
|
+
body: Array<Statement>
|
|
505
|
+
}
|
|
506
|
+
|
|
507
|
+
export type Statement =
|
|
508
|
+
| ExpressionStatement
|
|
509
|
+
| BlockStatement
|
|
510
|
+
| EmptyStatement
|
|
511
|
+
| DebuggerStatement
|
|
512
|
+
| WithStatement
|
|
513
|
+
| ReturnStatement
|
|
514
|
+
| LabeledStatement
|
|
515
|
+
| BreakStatement
|
|
516
|
+
| ContinueStatement
|
|
517
|
+
| IfStatement
|
|
518
|
+
| SwitchStatement
|
|
519
|
+
| ThrowStatement
|
|
520
|
+
| TryStatement
|
|
521
|
+
| WhileStatement
|
|
522
|
+
| DoWhileStatement
|
|
523
|
+
| ForStatement
|
|
524
|
+
| ForInStatement
|
|
525
|
+
| ForOfStatement
|
|
526
|
+
| Declaration
|
|
527
|
+
|
|
528
|
+
export type Declaration =
|
|
529
|
+
| FunctionDeclaration
|
|
530
|
+
| VariableDeclaration
|
|
531
|
+
| ClassDeclaration
|
|
532
|
+
|
|
533
|
+
export type Expression =
|
|
534
|
+
| Identifier
|
|
535
|
+
| Literal
|
|
536
|
+
| ThisExpression
|
|
537
|
+
| ArrayExpression
|
|
538
|
+
| ObjectExpression
|
|
539
|
+
| FunctionExpression
|
|
540
|
+
| UnaryExpression
|
|
541
|
+
| UpdateExpression
|
|
542
|
+
| BinaryExpression
|
|
543
|
+
| AssignmentExpression
|
|
544
|
+
| LogicalExpression
|
|
545
|
+
| MemberExpression
|
|
546
|
+
| ConditionalExpression
|
|
547
|
+
| CallExpression
|
|
548
|
+
| NewExpression
|
|
549
|
+
| SequenceExpression
|
|
550
|
+
| ArrowFunctionExpression
|
|
551
|
+
| YieldExpression
|
|
552
|
+
| TemplateLiteral
|
|
553
|
+
| TaggedTemplateExpression
|
|
554
|
+
| ClassExpression
|
|
555
|
+
| MetaProperty
|
|
556
|
+
| AwaitExpression
|
|
557
|
+
| ChainExpression
|
|
558
|
+
| ImportExpression
|
|
559
|
+
| ParenthesizedExpression
|
|
560
|
+
|
|
561
|
+
export type Pattern =
|
|
562
|
+
| Identifier
|
|
563
|
+
| MemberExpression
|
|
564
|
+
| ObjectPattern
|
|
565
|
+
| ArrayPattern
|
|
566
|
+
| RestElement
|
|
567
|
+
| AssignmentPattern
|
|
568
|
+
|
|
569
|
+
export type ModuleDeclaration =
|
|
570
|
+
| ImportDeclaration
|
|
571
|
+
| ExportNamedDeclaration
|
|
572
|
+
| ExportDefaultDeclaration
|
|
573
|
+
| ExportAllDeclaration
|
|
574
|
+
|
|
575
|
+
/**
|
|
576
|
+
* This interface is only used for defining {@link AnyNode}.
|
|
577
|
+
* It exists so that it can be extended by plugins:
|
|
578
|
+
*
|
|
579
|
+
* @example
|
|
580
|
+
* ```typescript
|
|
581
|
+
* declare module 'acorn' {
|
|
582
|
+
* interface NodeTypes {
|
|
583
|
+
* pluginName: FirstNode | SecondNode | ThirdNode | ... | LastNode
|
|
584
|
+
* }
|
|
585
|
+
* }
|
|
586
|
+
* ```
|
|
587
|
+
*/
|
|
588
|
+
interface NodeTypes {
|
|
589
|
+
core: Statement | Expression | Declaration | ModuleDeclaration | Literal | Program | SwitchCase | CatchClause | Property | Super | SpreadElement | TemplateElement | AssignmentProperty | ObjectPattern | ArrayPattern | RestElement | AssignmentPattern | ClassBody | MethodDefinition | MetaProperty | ImportAttribute | ImportSpecifier | ImportDefaultSpecifier | ImportNamespaceSpecifier | ExportSpecifier | AnonymousFunctionDeclaration | AnonymousClassDeclaration | PropertyDefinition | PrivateIdentifier | StaticBlock | VariableDeclarator
|
|
590
|
+
}
|
|
591
|
+
|
|
592
|
+
export type AnyNode = NodeTypes[keyof NodeTypes]
|
|
593
|
+
|
|
594
|
+
export function parse(input: string, options: Options): Program
|
|
595
|
+
|
|
596
|
+
export function parseExpressionAt(input: string, pos: number, options: Options): Expression
|
|
597
|
+
|
|
598
|
+
export function tokenizer(input: string, options: Options): {
|
|
599
|
+
getToken(): Token
|
|
600
|
+
[Symbol.iterator](): Iterator<Token>
|
|
601
|
+
}
|
|
602
|
+
|
|
603
|
+
export type ecmaVersion = 3 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 2015 | 2016 | 2017 | 2018 | 2019 | 2020 | 2021 | 2022 | 2023 | 2024 | 2025 | 2026 | "latest"
|
|
604
|
+
|
|
605
|
+
export interface Options {
|
|
606
|
+
/**
|
|
607
|
+
* `ecmaVersion` indicates the ECMAScript version to parse. Can be a
|
|
608
|
+
* number, either in year (`2022`) or plain version number (`6`) form,
|
|
609
|
+
* or `"latest"` (the latest the library supports). This influences
|
|
610
|
+
* support for strict mode, the set of reserved words, and support for
|
|
611
|
+
* new syntax features.
|
|
612
|
+
*/
|
|
613
|
+
ecmaVersion: ecmaVersion
|
|
614
|
+
|
|
615
|
+
/**
|
|
616
|
+
* `sourceType` indicates the mode the code should be parsed in.
|
|
617
|
+
* Can be either `"script"`, `"module"` or `"commonjs"`. This influences global
|
|
618
|
+
* strict mode and parsing of `import` and `export` declarations.
|
|
619
|
+
*/
|
|
620
|
+
sourceType?: "script" | "module" | "commonjs"
|
|
621
|
+
|
|
622
|
+
/**
|
|
623
|
+
* a callback that will be called when a semicolon is automatically inserted.
|
|
624
|
+
* @param lastTokEnd the position of the comma as an offset
|
|
625
|
+
* @param lastTokEndLoc location if {@link locations} is enabled
|
|
626
|
+
*/
|
|
627
|
+
onInsertedSemicolon?: (lastTokEnd: number, lastTokEndLoc?: Position) => void
|
|
628
|
+
|
|
629
|
+
/**
|
|
630
|
+
* similar to `onInsertedSemicolon`, but for trailing commas
|
|
631
|
+
* @param lastTokEnd the position of the comma as an offset
|
|
632
|
+
* @param lastTokEndLoc location if `locations` is enabled
|
|
633
|
+
*/
|
|
634
|
+
onTrailingComma?: (lastTokEnd: number, lastTokEndLoc?: Position) => void
|
|
635
|
+
|
|
636
|
+
/**
|
|
637
|
+
* By default, reserved words are only enforced if ecmaVersion >= 5.
|
|
638
|
+
* Set `allowReserved` to a boolean value to explicitly turn this on
|
|
639
|
+
* an off. When this option has the value "never", reserved words
|
|
640
|
+
* and keywords can also not be used as property names.
|
|
641
|
+
*/
|
|
642
|
+
allowReserved?: boolean | "never"
|
|
643
|
+
|
|
644
|
+
/**
|
|
645
|
+
* When enabled, a return at the top level is not considered an error.
|
|
646
|
+
*/
|
|
647
|
+
allowReturnOutsideFunction?: boolean
|
|
648
|
+
|
|
649
|
+
/**
|
|
650
|
+
* When enabled, import/export statements are not constrained to
|
|
651
|
+
* appearing at the top of the program, and an import.meta expression
|
|
652
|
+
* in a script isn't considered an error.
|
|
653
|
+
*/
|
|
654
|
+
allowImportExportEverywhere?: boolean
|
|
655
|
+
|
|
656
|
+
/**
|
|
657
|
+
* By default, `await` identifiers are allowed to appear at the top-level scope only if {@link ecmaVersion} >= 2022.
|
|
658
|
+
* When enabled, await identifiers are allowed to appear at the top-level scope,
|
|
659
|
+
* but they are still not allowed in non-async functions.
|
|
660
|
+
*/
|
|
661
|
+
allowAwaitOutsideFunction?: boolean
|
|
662
|
+
|
|
663
|
+
/**
|
|
664
|
+
* When enabled, super identifiers are not constrained to
|
|
665
|
+
* appearing in methods and do not raise an error when they appear elsewhere.
|
|
666
|
+
*/
|
|
667
|
+
allowSuperOutsideMethod?: boolean
|
|
668
|
+
|
|
669
|
+
/**
|
|
670
|
+
* When enabled, hashbang directive in the beginning of file is
|
|
671
|
+
* allowed and treated as a line comment. Enabled by default when
|
|
672
|
+
* {@link ecmaVersion} >= 2023.
|
|
673
|
+
*/
|
|
674
|
+
allowHashBang?: boolean
|
|
675
|
+
|
|
676
|
+
/**
|
|
677
|
+
* By default, the parser will verify that private properties are
|
|
678
|
+
* only used in places where they are valid and have been declared.
|
|
679
|
+
* Set this to false to turn such checks off.
|
|
680
|
+
*/
|
|
681
|
+
checkPrivateFields?: boolean
|
|
682
|
+
|
|
683
|
+
/**
|
|
684
|
+
* When `locations` is on, `loc` properties holding objects with
|
|
685
|
+
* `start` and `end` properties as {@link Position} objects will be attached to the
|
|
686
|
+
* nodes.
|
|
687
|
+
*/
|
|
688
|
+
locations?: boolean
|
|
689
|
+
|
|
690
|
+
/**
|
|
691
|
+
* a callback that will cause Acorn to call that export function with object in the same
|
|
692
|
+
* format as tokens returned from `tokenizer().getToken()`. Note
|
|
693
|
+
* that you are not allowed to call the parser from the
|
|
694
|
+
* callback—that will corrupt its internal state.
|
|
695
|
+
*/
|
|
696
|
+
onToken?: ((token: Token) => void) | Token[]
|
|
697
|
+
|
|
698
|
+
|
|
699
|
+
/**
|
|
700
|
+
* This takes a export function or an array.
|
|
701
|
+
*
|
|
702
|
+
* When a export function is passed, Acorn will call that export function with `(block, text, start,
|
|
703
|
+
* end)` parameters whenever a comment is skipped. `block` is a
|
|
704
|
+
* boolean indicating whether this is a block (`/* *\/`) comment,
|
|
705
|
+
* `text` is the content of the comment, and `start` and `end` are
|
|
706
|
+
* character offsets that denote the start and end of the comment.
|
|
707
|
+
* When the {@link locations} option is on, two more parameters are
|
|
708
|
+
* passed, the full locations of {@link Position} export type of the start and
|
|
709
|
+
* end of the comments.
|
|
710
|
+
*
|
|
711
|
+
* When a array is passed, each found comment of {@link Comment} export type is pushed to the array.
|
|
712
|
+
*
|
|
713
|
+
* Note that you are not allowed to call the
|
|
714
|
+
* parser from the callback—that will corrupt its internal state.
|
|
715
|
+
*/
|
|
716
|
+
onComment?: ((
|
|
717
|
+
isBlock: boolean, text: string, start: number, end: number, startLoc?: Position,
|
|
718
|
+
endLoc?: Position
|
|
719
|
+
) => void) | Comment[]
|
|
720
|
+
|
|
721
|
+
/**
|
|
722
|
+
* Nodes have their start and end characters offsets recorded in
|
|
723
|
+
* `start` and `end` properties (directly on the node, rather than
|
|
724
|
+
* the `loc` object, which holds line/column data. To also add a
|
|
725
|
+
* [semi-standardized][range] `range` property holding a `[start,
|
|
726
|
+
* end]` array with the same numbers, set the `ranges` option to
|
|
727
|
+
* `true`.
|
|
728
|
+
*/
|
|
729
|
+
ranges?: boolean
|
|
730
|
+
|
|
731
|
+
/**
|
|
732
|
+
* It is possible to parse multiple files into a single AST by
|
|
733
|
+
* passing the tree produced by parsing the first file as
|
|
734
|
+
* `program` option in subsequent parses. This will add the
|
|
735
|
+
* toplevel forms of the parsed file to the `Program` (top) node
|
|
736
|
+
* of an existing parse tree.
|
|
737
|
+
*/
|
|
738
|
+
program?: Node
|
|
739
|
+
|
|
740
|
+
/**
|
|
741
|
+
* When {@link locations} is on, you can pass this to record the source
|
|
742
|
+
* file in every node's `loc` object.
|
|
743
|
+
*/
|
|
744
|
+
sourceFile?: string
|
|
745
|
+
|
|
746
|
+
/**
|
|
747
|
+
* This value, if given, is stored in every node, whether {@link locations} is on or off.
|
|
748
|
+
*/
|
|
749
|
+
directSourceFile?: string
|
|
750
|
+
|
|
751
|
+
/**
|
|
752
|
+
* When enabled, parenthesized expressions are represented by
|
|
753
|
+
* (non-standard) ParenthesizedExpression nodes
|
|
754
|
+
*/
|
|
755
|
+
preserveParens?: boolean
|
|
756
|
+
}
|
|
757
|
+
|
|
758
|
+
export class Parser {
|
|
759
|
+
options: Options
|
|
760
|
+
input: string
|
|
761
|
+
|
|
762
|
+
protected constructor(options: Options, input: string, startPos?: number)
|
|
763
|
+
parse(): Program
|
|
764
|
+
|
|
765
|
+
static parse(input: string, options: Options): Program
|
|
766
|
+
static parseExpressionAt(input: string, pos: number, options: Options): Expression
|
|
767
|
+
static tokenizer(input: string, options: Options): {
|
|
768
|
+
getToken(): Token
|
|
769
|
+
[Symbol.iterator](): Iterator<Token>
|
|
770
|
+
}
|
|
771
|
+
static extend(...plugins: ((BaseParser: typeof Parser) => typeof Parser)[]): typeof Parser
|
|
772
|
+
}
|
|
773
|
+
|
|
774
|
+
export const defaultOptions: Options
|
|
775
|
+
|
|
776
|
+
export function getLineInfo(input: string, offset: number): Position
|
|
777
|
+
|
|
778
|
+
export class TokenType {
|
|
779
|
+
label: string
|
|
780
|
+
keyword: string | undefined
|
|
781
|
+
}
|
|
782
|
+
|
|
783
|
+
export const tokTypes: {
|
|
784
|
+
num: TokenType
|
|
785
|
+
regexp: TokenType
|
|
786
|
+
string: TokenType
|
|
787
|
+
name: TokenType
|
|
788
|
+
privateId: TokenType
|
|
789
|
+
eof: TokenType
|
|
790
|
+
|
|
791
|
+
bracketL: TokenType
|
|
792
|
+
bracketR: TokenType
|
|
793
|
+
braceL: TokenType
|
|
794
|
+
braceR: TokenType
|
|
795
|
+
parenL: TokenType
|
|
796
|
+
parenR: TokenType
|
|
797
|
+
comma: TokenType
|
|
798
|
+
semi: TokenType
|
|
799
|
+
colon: TokenType
|
|
800
|
+
dot: TokenType
|
|
801
|
+
question: TokenType
|
|
802
|
+
questionDot: TokenType
|
|
803
|
+
arrow: TokenType
|
|
804
|
+
template: TokenType
|
|
805
|
+
invalidTemplate: TokenType
|
|
806
|
+
ellipsis: TokenType
|
|
807
|
+
backQuote: TokenType
|
|
808
|
+
dollarBraceL: TokenType
|
|
809
|
+
|
|
810
|
+
eq: TokenType
|
|
811
|
+
assign: TokenType
|
|
812
|
+
incDec: TokenType
|
|
813
|
+
prefix: TokenType
|
|
814
|
+
logicalOR: TokenType
|
|
815
|
+
logicalAND: TokenType
|
|
816
|
+
bitwiseOR: TokenType
|
|
817
|
+
bitwiseXOR: TokenType
|
|
818
|
+
bitwiseAND: TokenType
|
|
819
|
+
equality: TokenType
|
|
820
|
+
relational: TokenType
|
|
821
|
+
bitShift: TokenType
|
|
822
|
+
plusMin: TokenType
|
|
823
|
+
modulo: TokenType
|
|
824
|
+
star: TokenType
|
|
825
|
+
slash: TokenType
|
|
826
|
+
starstar: TokenType
|
|
827
|
+
coalesce: TokenType
|
|
828
|
+
|
|
829
|
+
_break: TokenType
|
|
830
|
+
_case: TokenType
|
|
831
|
+
_catch: TokenType
|
|
832
|
+
_continue: TokenType
|
|
833
|
+
_debugger: TokenType
|
|
834
|
+
_default: TokenType
|
|
835
|
+
_do: TokenType
|
|
836
|
+
_else: TokenType
|
|
837
|
+
_finally: TokenType
|
|
838
|
+
_for: TokenType
|
|
839
|
+
_function: TokenType
|
|
840
|
+
_if: TokenType
|
|
841
|
+
_return: TokenType
|
|
842
|
+
_switch: TokenType
|
|
843
|
+
_throw: TokenType
|
|
844
|
+
_try: TokenType
|
|
845
|
+
_var: TokenType
|
|
846
|
+
_const: TokenType
|
|
847
|
+
_while: TokenType
|
|
848
|
+
_with: TokenType
|
|
849
|
+
_new: TokenType
|
|
850
|
+
_this: TokenType
|
|
851
|
+
_super: TokenType
|
|
852
|
+
_class: TokenType
|
|
853
|
+
_extends: TokenType
|
|
854
|
+
_export: TokenType
|
|
855
|
+
_import: TokenType
|
|
856
|
+
_null: TokenType
|
|
857
|
+
_true: TokenType
|
|
858
|
+
_false: TokenType
|
|
859
|
+
_in: TokenType
|
|
860
|
+
_instanceof: TokenType
|
|
861
|
+
_typeof: TokenType
|
|
862
|
+
_void: TokenType
|
|
863
|
+
_delete: TokenType
|
|
864
|
+
}
|
|
865
|
+
|
|
866
|
+
export interface Comment {
|
|
867
|
+
type: "Line" | "Block"
|
|
868
|
+
value: string
|
|
869
|
+
start: number
|
|
870
|
+
end: number
|
|
871
|
+
loc?: SourceLocation
|
|
872
|
+
range?: [number, number]
|
|
873
|
+
}
|
|
874
|
+
|
|
875
|
+
export class Token {
|
|
876
|
+
type: TokenType
|
|
877
|
+
start: number
|
|
878
|
+
end: number
|
|
879
|
+
loc?: SourceLocation
|
|
880
|
+
range?: [number, number]
|
|
881
|
+
}
|
|
882
|
+
|
|
883
|
+
export const version: string
|