1
|
export as namespace acorn
|
2
|
export = acorn
|
3
|
|
4
|
declare namespace acorn {
|
5
|
function parse(input: string, options?: Options): Node
|
6
|
|
7
|
function parseExpressionAt(input: string, pos?: number, options?: Options): Node
|
8
|
|
9
|
function tokenizer(input: string, options?: Options): {
|
10
|
getToken(): Token
|
11
|
[Symbol.iterator](): Iterator<Token>
|
12
|
}
|
13
|
|
14
|
interface Options {
|
15
|
ecmaVersion?: 3 | 5 | 6 | 7 | 8 | 9 | 10 | 2015 | 2016 | 2017 | 2018 | 2019
|
16
|
sourceType?: 'script' | 'module'
|
17
|
onInsertedSemicolon?: (lastTokEnd: number, lastTokEndLoc?: Position) => void
|
18
|
onTrailingComma?: (lastTokEnd: number, lastTokEndLoc?: Position) => void
|
19
|
allowReserved?: boolean | 'never'
|
20
|
allowReturnOutsideFunction?: boolean
|
21
|
allowImportExportEverywhere?: boolean
|
22
|
allowAwaitOutsideFunction?: boolean
|
23
|
allowHashBang?: boolean
|
24
|
locations?: boolean
|
25
|
onToken?: ((token: Token) => any) | Token[]
|
26
|
onComment?: ((
|
27
|
isBlock: boolean, text: string, start: number, end: number, startLoc?: Position,
|
28
|
endLoc?: Position
|
29
|
) => void) | Comment[]
|
30
|
ranges?: boolean
|
31
|
program?: Node
|
32
|
sourceFile?: string
|
33
|
directSourceFile?: string
|
34
|
preserveParens?: boolean
|
35
|
}
|
36
|
|
37
|
class Parser {
|
38
|
constructor(options: Options, input: string, startPos?: number)
|
39
|
parse(this: Parser): Node
|
40
|
static parse(this: typeof Parser, input: string, options?: Options): Node
|
41
|
static parseExpressionAt(this: typeof Parser, input: string, pos: number, options?: Options): Node
|
42
|
static tokenizer(this: typeof Parser, input: string, options?: Options): {
|
43
|
getToken(): Token
|
44
|
[Symbol.iterator](): Iterator<Token>
|
45
|
}
|
46
|
static extend(this: typeof Parser, ...plugins: ((BaseParser: typeof Parser) => typeof Parser)[]): typeof Parser
|
47
|
}
|
48
|
|
49
|
interface Position { line: number; column: number; offset: number }
|
50
|
|
51
|
const defaultOptions: Options
|
52
|
|
53
|
function getLineInfo(input: string, offset: number): Position
|
54
|
|
55
|
class SourceLocation {
|
56
|
start: Position
|
57
|
end: Position
|
58
|
source?: string | null
|
59
|
constructor(p: Parser, start: Position, end: Position)
|
60
|
}
|
61
|
|
62
|
class Node {
|
63
|
type: string
|
64
|
start: number
|
65
|
end: number
|
66
|
loc?: SourceLocation
|
67
|
sourceFile?: string
|
68
|
range?: [number, number]
|
69
|
constructor(parser: Parser, pos: number, loc?: SourceLocation)
|
70
|
}
|
71
|
|
72
|
class TokenType {
|
73
|
label: string
|
74
|
keyword: string
|
75
|
beforeExpr: boolean
|
76
|
startsExpr: boolean
|
77
|
isLoop: boolean
|
78
|
isAssign: boolean
|
79
|
prefix: boolean
|
80
|
postfix: boolean
|
81
|
binop: number
|
82
|
updateContext?: (prevType: TokenType) => void
|
83
|
constructor(label: string, conf?: any)
|
84
|
}
|
85
|
|
86
|
const tokTypes: {
|
87
|
num: TokenType
|
88
|
regexp: TokenType
|
89
|
string: TokenType
|
90
|
name: TokenType
|
91
|
eof: TokenType
|
92
|
bracketL: TokenType
|
93
|
bracketR: TokenType
|
94
|
braceL: TokenType
|
95
|
braceR: TokenType
|
96
|
parenL: TokenType
|
97
|
parenR: TokenType
|
98
|
comma: TokenType
|
99
|
semi: TokenType
|
100
|
colon: TokenType
|
101
|
dot: TokenType
|
102
|
question: TokenType
|
103
|
arrow: TokenType
|
104
|
template: TokenType
|
105
|
ellipsis: TokenType
|
106
|
backQuote: TokenType
|
107
|
dollarBraceL: TokenType
|
108
|
eq: TokenType
|
109
|
assign: TokenType
|
110
|
incDec: TokenType
|
111
|
prefix: TokenType
|
112
|
logicalOR: TokenType
|
113
|
logicalAND: TokenType
|
114
|
bitwiseOR: TokenType
|
115
|
bitwiseXOR: TokenType
|
116
|
bitwiseAND: TokenType
|
117
|
equality: TokenType
|
118
|
relational: TokenType
|
119
|
bitShift: TokenType
|
120
|
plusMin: TokenType
|
121
|
modulo: TokenType
|
122
|
star: TokenType
|
123
|
slash: TokenType
|
124
|
starstar: TokenType
|
125
|
_break: TokenType
|
126
|
_case: TokenType
|
127
|
_catch: TokenType
|
128
|
_continue: TokenType
|
129
|
_debugger: TokenType
|
130
|
_default: TokenType
|
131
|
_do: TokenType
|
132
|
_else: TokenType
|
133
|
_finally: TokenType
|
134
|
_for: TokenType
|
135
|
_function: TokenType
|
136
|
_if: TokenType
|
137
|
_return: TokenType
|
138
|
_switch: TokenType
|
139
|
_throw: TokenType
|
140
|
_try: TokenType
|
141
|
_var: TokenType
|
142
|
_const: TokenType
|
143
|
_while: TokenType
|
144
|
_with: TokenType
|
145
|
_new: TokenType
|
146
|
_this: TokenType
|
147
|
_super: TokenType
|
148
|
_class: TokenType
|
149
|
_extends: TokenType
|
150
|
_export: TokenType
|
151
|
_import: TokenType
|
152
|
_null: TokenType
|
153
|
_true: TokenType
|
154
|
_false: TokenType
|
155
|
_in: TokenType
|
156
|
_instanceof: TokenType
|
157
|
_typeof: TokenType
|
158
|
_void: TokenType
|
159
|
_delete: TokenType
|
160
|
}
|
161
|
|
162
|
class TokContext {
|
163
|
constructor(token: string, isExpr: boolean, preserveSpace: boolean, override?: (p: Parser) => void)
|
164
|
}
|
165
|
|
166
|
const tokContexts: {
|
167
|
b_stat: TokContext
|
168
|
b_expr: TokContext
|
169
|
b_tmpl: TokContext
|
170
|
p_stat: TokContext
|
171
|
p_expr: TokContext
|
172
|
q_tmpl: TokContext
|
173
|
f_expr: TokContext
|
174
|
}
|
175
|
|
176
|
function isIdentifierStart(code: number, astral?: boolean): boolean
|
177
|
|
178
|
function isIdentifierChar(code: number, astral?: boolean): boolean
|
179
|
|
180
|
interface AbstractToken {
|
181
|
}
|
182
|
|
183
|
interface Comment extends AbstractToken {
|
184
|
type: string
|
185
|
value: string
|
186
|
start: number
|
187
|
end: number
|
188
|
loc?: SourceLocation
|
189
|
range?: [number, number]
|
190
|
}
|
191
|
|
192
|
class Token {
|
193
|
type: TokenType
|
194
|
value: any
|
195
|
start: number
|
196
|
end: number
|
197
|
loc?: SourceLocation
|
198
|
range?: [number, number]
|
199
|
constructor(p: Parser)
|
200
|
}
|
201
|
|
202
|
function isNewLine(code: number): boolean
|
203
|
|
204
|
const lineBreak: RegExp
|
205
|
|
206
|
const lineBreakG: RegExp
|
207
|
|
208
|
const version: string
|
209
|
}
|