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 | 11 | 12 | 2015 | 2016 | 2017 | 2018 | 2019 | 2020 | 2021 | 'latest'
|
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 | privateId: TokenType
|
92 | eof: TokenType
|
93 | bracketL: TokenType
|
94 | bracketR: TokenType
|
95 | braceL: TokenType
|
96 | braceR: TokenType
|
97 | parenL: TokenType
|
98 | parenR: TokenType
|
99 | comma: TokenType
|
100 | semi: TokenType
|
101 | colon: TokenType
|
102 | dot: TokenType
|
103 | question: TokenType
|
104 | arrow: TokenType
|
105 | template: TokenType
|
106 | ellipsis: TokenType
|
107 | backQuote: TokenType
|
108 | dollarBraceL: TokenType
|
109 | eq: TokenType
|
110 | assign: TokenType
|
111 | incDec: TokenType
|
112 | prefix: TokenType
|
113 | logicalOR: TokenType
|
114 | logicalAND: TokenType
|
115 | bitwiseOR: TokenType
|
116 | bitwiseXOR: TokenType
|
117 | bitwiseAND: TokenType
|
118 | equality: TokenType
|
119 | relational: TokenType
|
120 | bitShift: TokenType
|
121 | plusMin: TokenType
|
122 | modulo: TokenType
|
123 | star: TokenType
|
124 | slash: TokenType
|
125 | starstar: TokenType
|
126 | _break: TokenType
|
127 | _case: TokenType
|
128 | _catch: TokenType
|
129 | _continue: TokenType
|
130 | _debugger: TokenType
|
131 | _default: TokenType
|
132 | _do: TokenType
|
133 | _else: TokenType
|
134 | _finally: TokenType
|
135 | _for: TokenType
|
136 | _function: TokenType
|
137 | _if: TokenType
|
138 | _return: TokenType
|
139 | _switch: TokenType
|
140 | _throw: TokenType
|
141 | _try: TokenType
|
142 | _var: TokenType
|
143 | _const: TokenType
|
144 | _while: TokenType
|
145 | _with: TokenType
|
146 | _new: TokenType
|
147 | _this: TokenType
|
148 | _super: TokenType
|
149 | _class: TokenType
|
150 | _extends: TokenType
|
151 | _export: TokenType
|
152 | _import: TokenType
|
153 | _null: TokenType
|
154 | _true: TokenType
|
155 | _false: TokenType
|
156 | _in: TokenType
|
157 | _instanceof: TokenType
|
158 | _typeof: TokenType
|
159 | _void: TokenType
|
160 | _delete: TokenType
|
161 | }
|
162 |
|
163 | class TokContext {
|
164 | constructor(token: string, isExpr: boolean, preserveSpace: boolean, override?: (p: Parser) => void)
|
165 | }
|
166 |
|
167 | const tokContexts: {
|
168 | b_stat: TokContext
|
169 | b_expr: TokContext
|
170 | b_tmpl: TokContext
|
171 | p_stat: TokContext
|
172 | p_expr: TokContext
|
173 | q_tmpl: TokContext
|
174 | f_expr: TokContext
|
175 | }
|
176 |
|
177 | function isIdentifierStart(code: number, astral?: boolean): boolean
|
178 |
|
179 | function isIdentifierChar(code: number, astral?: boolean): boolean
|
180 |
|
181 | interface AbstractToken {
|
182 | }
|
183 |
|
184 | interface Comment extends AbstractToken {
|
185 | type: string
|
186 | value: string
|
187 | start: number
|
188 | end: number
|
189 | loc?: SourceLocation
|
190 | range?: [number, number]
|
191 | }
|
192 |
|
193 | class Token {
|
194 | type: TokenType
|
195 | value: any
|
196 | start: number
|
197 | end: number
|
198 | loc?: SourceLocation
|
199 | range?: [number, number]
|
200 | constructor(p: Parser)
|
201 | }
|
202 |
|
203 | function isNewLine(code: number): boolean
|
204 |
|
205 | const lineBreak: RegExp
|
206 |
|
207 | const lineBreakG: RegExp
|
208 |
|
209 | const version: string
|
210 | }
|