@builder.io/sdk-solid 0.4.5 → 0.5.1
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/CHANGELOG.md +8 -0
- package/package.json +1 -1
- package/src/blocks/BaseText.jsx +1 -1
- package/src/blocks/button/button.jsx +5 -3
- package/src/blocks/button/component-info.js +16 -22
- package/src/blocks/columns/columns.jsx +12 -21
- package/src/blocks/columns/component-info.js +203 -226
- package/src/blocks/custom-code/component-info.js +19 -25
- package/src/blocks/embed/component-info.js +31 -37
- package/src/blocks/embed/helpers.js +3 -9
- package/src/blocks/form/component-info.js +174 -212
- package/src/blocks/form/form.jsx +1 -268
- package/src/blocks/fragment/component-info.js +1 -3
- package/src/blocks/helpers.js +27 -0
- package/src/blocks/image/component-info.js +105 -133
- package/src/blocks/image/image.helpers.js +3 -5
- package/src/blocks/img/component-info.js +8 -12
- package/src/blocks/img/img.jsx +2 -0
- package/src/blocks/input/component-info.js +29 -57
- package/src/blocks/input/input.jsx +2 -0
- package/src/blocks/raw-text/component-info.js +7 -11
- package/src/blocks/raw-text/raw-text.jsx +2 -2
- package/src/blocks/section/component-info.js +24 -31
- package/src/blocks/section/section.jsx +3 -0
- package/src/blocks/select/component-info.js +34 -48
- package/src/blocks/select/select.jsx +2 -0
- package/src/blocks/submit-button/component-info.js +6 -10
- package/src/blocks/submit-button/submit-button.jsx +3 -1
- package/src/blocks/symbol/component-info.js +30 -37
- package/src/blocks/symbol/symbol.helpers.js +60 -0
- package/src/blocks/symbol/symbol.jsx +31 -68
- package/src/blocks/text/component-info.js +10 -13
- package/src/blocks/text/text.jsx +1 -1
- package/src/blocks/textarea/component-info.js +22 -30
- package/src/blocks/textarea/textarea.jsx +3 -0
- package/src/blocks/video/component-info.js +74 -96
- package/src/blocks/video/video.jsx +1 -0
- package/src/components/{render-block/render-block.helpers.js → block/block.helpers.js} +26 -44
- package/src/components/{render-block/render-block.jsx → block/block.jsx} +65 -80
- package/src/components/{render-block → block/components}/block-styles.jsx +16 -16
- package/src/components/block/components/block-wrapper.jsx +50 -0
- package/src/components/block/components/component-ref/component-ref.helpers.js +41 -0
- package/src/components/block/components/component-ref/component-ref.jsx +58 -0
- package/src/components/block/components/interactive-element.jsx +30 -0
- package/src/components/block/components/repeated-block.jsx +20 -0
- package/src/components/blocks/blocks-wrapper.jsx +66 -0
- package/src/components/blocks/blocks.jsx +57 -0
- package/src/components/{render-content/render-content.jsx → content/components/enable-editor.jsx} +86 -175
- package/src/components/{render-content/components/render-styles.helpers.js → content/components/styles.helpers.js} +6 -7
- package/src/components/{render-content/components/render-styles.jsx → content/components/styles.jsx} +4 -4
- package/src/components/{render-content/render-content.helpers.js → content/content.helpers.js} +15 -15
- package/src/components/content/content.jsx +136 -0
- package/src/components/content/index.js +2 -0
- package/src/components/content/wrap-component-ref.js +2 -0
- package/src/components/{render-content-variants/render-content-variants.jsx → content-variants/content-variants.jsx} +19 -22
- package/src/components/{render-content-variants → content-variants}/helpers.js +28 -40
- package/src/constants/builder-registered-components.js +34 -25
- package/src/constants/device-sizes.js +6 -6
- package/src/constants/sdk-version.js +1 -1
- package/src/context/builder.context.js +1 -1
- package/src/context/components.context.js +5 -0
- package/src/functions/apply-patch-with-mutation.js +66 -0
- package/src/functions/camel-to-kebab-case.js +2 -4
- package/src/functions/evaluate/acorn.js +1595 -0
- package/src/functions/{evaluate.js → evaluate/evaluate.js} +36 -10
- package/src/functions/evaluate/index.js +2 -0
- package/src/functions/evaluate/interpreter.js +2801 -0
- package/src/functions/evaluate/non-node-runtime.js +92 -0
- package/src/functions/evaluate/types.js +0 -0
- package/src/functions/event-handler-name.js +2 -4
- package/src/functions/extract-text-styles.js +4 -12
- package/src/functions/fast-clone.js +2 -4
- package/src/functions/get-block-actions-handler.js +3 -5
- package/src/functions/get-block-actions.js +15 -4
- package/src/functions/get-block-component-options.js +11 -12
- package/src/functions/get-block-properties.js +29 -19
- package/src/functions/get-builder-search-params/index.js +5 -10
- package/src/functions/get-content/generate-content-url.js +17 -19
- package/src/functions/get-content/index.js +43 -29
- package/src/functions/get-fetch.js +1 -3
- package/src/functions/get-global-this.js +1 -3
- package/src/functions/get-processed-block.js +12 -13
- package/src/functions/get-react-native-block-styles.js +11 -12
- package/src/functions/if-target.js +1 -3
- package/src/functions/is-browser.js +1 -3
- package/src/functions/is-editing.js +1 -3
- package/src/functions/is-iframe.js +1 -3
- package/src/functions/is-non-node-server.js +9 -0
- package/src/functions/is-previewing.js +1 -3
- package/src/functions/on-change.js +1 -4
- package/src/functions/register-component.js +34 -42
- package/src/functions/register.js +1 -3
- package/src/functions/sanitize-react-native-block-styles.js +22 -17
- package/src/functions/set-editor-settings.js +1 -3
- package/src/functions/set.js +1 -3
- package/src/functions/track/helpers.js +3 -5
- package/src/functions/track/index.js +45 -43
- package/src/functions/track/interaction.js +11 -7
- package/src/functions/transform-block-properties.js +1 -3
- package/src/functions/transform-block.js +1 -3
- package/src/helpers/ab-tests.js +45 -28
- package/src/helpers/canTrack.js +3 -5
- package/src/helpers/cookie.js +15 -24
- package/src/helpers/css.js +3 -7
- package/src/helpers/flatten.js +15 -18
- package/src/helpers/localStorage.js +1 -4
- package/src/helpers/logger.js +1 -3
- package/src/helpers/nullable.js +2 -4
- package/src/helpers/preview-lru-cache/get.js +8 -0
- package/src/helpers/preview-lru-cache/helpers.js +10 -0
- package/src/helpers/preview-lru-cache/init.js +10 -0
- package/src/helpers/preview-lru-cache/set.js +35 -0
- package/src/helpers/preview-lru-cache/types.js +0 -0
- package/src/helpers/sessionId.js +14 -11
- package/src/helpers/time.js +1 -3
- package/src/helpers/url.js +2 -4
- package/src/helpers/uuid.js +4 -6
- package/src/helpers/visitorId.js +8 -7
- package/src/index-helpers/blocks-exports.js +3 -14
- package/src/index-helpers/top-of-file.js +1 -3
- package/src/index.js +2 -17
- package/src/scripts/init-editing.js +62 -48
- package/src/types/api-version.js +1 -3
- package/src/types/builder-props.js +0 -0
- package/src/blocks/util.js +0 -8
- package/src/components/render-block/render-component.jsx +0 -40
- package/src/components/render-block/render-repeated-block.jsx +0 -16
- package/src/components/render-blocks.jsx +0 -100
- package/src/components/render-content/builder-editing.jsx +0 -5
- package/src/components/render-content/index.js +0 -4
- package/src/components/render-content/wrap-component-ref.js +0 -4
- package/src/functions/evaluate.test.js +0 -17
- package/src/functions/get-builder-search-params/fn.test.js +0 -13
- package/src/functions/get-content/generate-content-url.test.js +0 -97
- package/src/functions/get-processed-block.test.js +0 -34
- package/src/functions/on-change.test.js +0 -19
- package/src/functions/set.test.js +0 -16
- package/src/helpers/url.test.js +0 -21
- /package/src/components/{render-block → block}/types.js +0 -0
- /package/src/components/{render-content/render-content.types.js → content/content.types.js} +0 -0
- /package/src/components/{render-content-variants/render-content-variants.types.js → content-variants/content-variants.types.js} +0 -0
|
@@ -0,0 +1,1595 @@
|
|
|
1
|
+
var __commonJS = (cb, mod) => function __require() {
|
|
2
|
+
return mod || (0, cb[Object.keys(cb)[0]])((mod = {
|
|
3
|
+
exports: {}
|
|
4
|
+
}).exports, mod), mod.exports;
|
|
5
|
+
};
|
|
6
|
+
var require_stdin = __commonJS({
|
|
7
|
+
"<stdin>"(exports, module) {
|
|
8
|
+
/**
|
|
9
|
+
* @license
|
|
10
|
+
* Copyright 2012 Marijn Haverbeke
|
|
11
|
+
* SPDX-License-Identifier: MIT
|
|
12
|
+
*/
|
|
13
|
+
(function (root, mod) {
|
|
14
|
+
if (typeof exports === "object" && typeof module === "object") return mod(exports);
|
|
15
|
+
if (typeof define === "function" && define.amd) return define(["exports"], mod);
|
|
16
|
+
mod(root.acorn || (root.acorn = {}));
|
|
17
|
+
})(exports, function (exports2) {
|
|
18
|
+
exports2.version = "0.5.0";
|
|
19
|
+
var options;
|
|
20
|
+
var input = "";
|
|
21
|
+
var inputLen;
|
|
22
|
+
var sourceFile;
|
|
23
|
+
exports2.parse = function (inpt, opts) {
|
|
24
|
+
input = String(inpt);
|
|
25
|
+
inputLen = input.length;
|
|
26
|
+
setOptions(opts);
|
|
27
|
+
initTokenState();
|
|
28
|
+
return parseTopLevel(options.program);
|
|
29
|
+
};
|
|
30
|
+
var defaultOptions = {
|
|
31
|
+
strictSemicolons: false,
|
|
32
|
+
allowTrailingCommas: true,
|
|
33
|
+
forbidReserved: false,
|
|
34
|
+
allowReturnOutsideFunction: false,
|
|
35
|
+
locations: false,
|
|
36
|
+
onComment: null,
|
|
37
|
+
ranges: false,
|
|
38
|
+
program: null,
|
|
39
|
+
sourceFile: null,
|
|
40
|
+
directSourceFile: null
|
|
41
|
+
};
|
|
42
|
+
function setOptions(opts) {
|
|
43
|
+
options = opts || {};
|
|
44
|
+
for (var opt in defaultOptions) {
|
|
45
|
+
if (!Object.prototype.hasOwnProperty.call(options, opt)) {
|
|
46
|
+
options[opt] = defaultOptions[opt];
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
sourceFile = options.sourceFile;
|
|
50
|
+
}
|
|
51
|
+
var getLineInfo = function (input2, offset) {
|
|
52
|
+
for (var line = 1, cur = 0;;) {
|
|
53
|
+
lineBreak.lastIndex = cur;
|
|
54
|
+
var match = lineBreak.exec(input2);
|
|
55
|
+
if (match && match.index < offset) {
|
|
56
|
+
++line;
|
|
57
|
+
cur = match.index + match[0].length;
|
|
58
|
+
} else {
|
|
59
|
+
break;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
return {
|
|
63
|
+
line,
|
|
64
|
+
column: offset - cur
|
|
65
|
+
};
|
|
66
|
+
};
|
|
67
|
+
var tokPos = 0;
|
|
68
|
+
var tokStart = 0;
|
|
69
|
+
var tokEnd = 0;
|
|
70
|
+
var tokStartLoc;
|
|
71
|
+
var tokEndLoc;
|
|
72
|
+
var tokType;
|
|
73
|
+
var tokVal;
|
|
74
|
+
var tokRegexpAllowed;
|
|
75
|
+
var tokCurLine;
|
|
76
|
+
var tokLineStart;
|
|
77
|
+
var lastStart = 0;
|
|
78
|
+
var lastEnd = 0;
|
|
79
|
+
var lastEndLoc;
|
|
80
|
+
var inFunction;
|
|
81
|
+
var labels;
|
|
82
|
+
var strict;
|
|
83
|
+
function raise(pos, message) {
|
|
84
|
+
var loc = getLineInfo(input, pos);
|
|
85
|
+
message += " (" + loc.line + ":" + loc.column + ")";
|
|
86
|
+
var err = new SyntaxError(message);
|
|
87
|
+
err.pos = pos;
|
|
88
|
+
err.loc = loc;
|
|
89
|
+
err.raisedAt = tokPos;
|
|
90
|
+
throw err;
|
|
91
|
+
}
|
|
92
|
+
var empty = [];
|
|
93
|
+
var _num = {
|
|
94
|
+
type: "num"
|
|
95
|
+
};
|
|
96
|
+
var _regexp = {
|
|
97
|
+
type: "regexp"
|
|
98
|
+
};
|
|
99
|
+
var _string = {
|
|
100
|
+
type: "string"
|
|
101
|
+
};
|
|
102
|
+
var _name = {
|
|
103
|
+
type: "name"
|
|
104
|
+
};
|
|
105
|
+
var _eof = {
|
|
106
|
+
type: "eof"
|
|
107
|
+
};
|
|
108
|
+
var _break = {
|
|
109
|
+
keyword: "break"
|
|
110
|
+
};
|
|
111
|
+
var _case = {
|
|
112
|
+
keyword: "case",
|
|
113
|
+
beforeExpr: true
|
|
114
|
+
};
|
|
115
|
+
var _catch = {
|
|
116
|
+
keyword: "catch"
|
|
117
|
+
};
|
|
118
|
+
var _continue = {
|
|
119
|
+
keyword: "continue"
|
|
120
|
+
};
|
|
121
|
+
var _debugger = {
|
|
122
|
+
keyword: "debugger"
|
|
123
|
+
};
|
|
124
|
+
var _default = {
|
|
125
|
+
keyword: "default"
|
|
126
|
+
};
|
|
127
|
+
var _do = {
|
|
128
|
+
keyword: "do",
|
|
129
|
+
isLoop: true
|
|
130
|
+
};
|
|
131
|
+
var _else = {
|
|
132
|
+
keyword: "else",
|
|
133
|
+
beforeExpr: true
|
|
134
|
+
};
|
|
135
|
+
var _finally = {
|
|
136
|
+
keyword: "finally"
|
|
137
|
+
};
|
|
138
|
+
var _for = {
|
|
139
|
+
keyword: "for",
|
|
140
|
+
isLoop: true
|
|
141
|
+
};
|
|
142
|
+
var _function = {
|
|
143
|
+
keyword: "function"
|
|
144
|
+
};
|
|
145
|
+
var _if = {
|
|
146
|
+
keyword: "if"
|
|
147
|
+
};
|
|
148
|
+
var _return = {
|
|
149
|
+
keyword: "return",
|
|
150
|
+
beforeExpr: true
|
|
151
|
+
};
|
|
152
|
+
var _switch = {
|
|
153
|
+
keyword: "switch"
|
|
154
|
+
};
|
|
155
|
+
var _throw = {
|
|
156
|
+
keyword: "throw",
|
|
157
|
+
beforeExpr: true
|
|
158
|
+
};
|
|
159
|
+
var _try = {
|
|
160
|
+
keyword: "try"
|
|
161
|
+
};
|
|
162
|
+
var _var = {
|
|
163
|
+
keyword: "var"
|
|
164
|
+
};
|
|
165
|
+
var _while = {
|
|
166
|
+
keyword: "while",
|
|
167
|
+
isLoop: true
|
|
168
|
+
};
|
|
169
|
+
var _with = {
|
|
170
|
+
keyword: "with"
|
|
171
|
+
};
|
|
172
|
+
var _new = {
|
|
173
|
+
keyword: "new",
|
|
174
|
+
beforeExpr: true
|
|
175
|
+
};
|
|
176
|
+
var _this = {
|
|
177
|
+
keyword: "this"
|
|
178
|
+
};
|
|
179
|
+
var _null = {
|
|
180
|
+
keyword: "null",
|
|
181
|
+
atomValue: null
|
|
182
|
+
};
|
|
183
|
+
var _true = {
|
|
184
|
+
keyword: "true",
|
|
185
|
+
atomValue: true
|
|
186
|
+
};
|
|
187
|
+
var _false = {
|
|
188
|
+
keyword: "false",
|
|
189
|
+
atomValue: false
|
|
190
|
+
};
|
|
191
|
+
var _in = {
|
|
192
|
+
keyword: "in",
|
|
193
|
+
binop: 7,
|
|
194
|
+
beforeExpr: true
|
|
195
|
+
};
|
|
196
|
+
var keywordTypes = {
|
|
197
|
+
break: _break,
|
|
198
|
+
case: _case,
|
|
199
|
+
catch: _catch,
|
|
200
|
+
continue: _continue,
|
|
201
|
+
debugger: _debugger,
|
|
202
|
+
default: _default,
|
|
203
|
+
do: _do,
|
|
204
|
+
else: _else,
|
|
205
|
+
finally: _finally,
|
|
206
|
+
for: _for,
|
|
207
|
+
function: _function,
|
|
208
|
+
if: _if,
|
|
209
|
+
return: _return,
|
|
210
|
+
switch: _switch,
|
|
211
|
+
throw: _throw,
|
|
212
|
+
try: _try,
|
|
213
|
+
var: _var,
|
|
214
|
+
while: _while,
|
|
215
|
+
with: _with,
|
|
216
|
+
null: _null,
|
|
217
|
+
true: _true,
|
|
218
|
+
false: _false,
|
|
219
|
+
new: _new,
|
|
220
|
+
in: _in,
|
|
221
|
+
instanceof: {
|
|
222
|
+
keyword: "instanceof",
|
|
223
|
+
binop: 7,
|
|
224
|
+
beforeExpr: true
|
|
225
|
+
},
|
|
226
|
+
this: _this,
|
|
227
|
+
typeof: {
|
|
228
|
+
keyword: "typeof",
|
|
229
|
+
prefix: true,
|
|
230
|
+
beforeExpr: true
|
|
231
|
+
},
|
|
232
|
+
void: {
|
|
233
|
+
keyword: "void",
|
|
234
|
+
prefix: true,
|
|
235
|
+
beforeExpr: true
|
|
236
|
+
},
|
|
237
|
+
delete: {
|
|
238
|
+
keyword: "delete",
|
|
239
|
+
prefix: true,
|
|
240
|
+
beforeExpr: true
|
|
241
|
+
}
|
|
242
|
+
};
|
|
243
|
+
var _bracketL = {
|
|
244
|
+
type: "[",
|
|
245
|
+
beforeExpr: true
|
|
246
|
+
};
|
|
247
|
+
var _bracketR = {
|
|
248
|
+
type: "]"
|
|
249
|
+
};
|
|
250
|
+
var _braceL = {
|
|
251
|
+
type: "{",
|
|
252
|
+
beforeExpr: true
|
|
253
|
+
};
|
|
254
|
+
var _braceR = {
|
|
255
|
+
type: "}"
|
|
256
|
+
};
|
|
257
|
+
var _parenL = {
|
|
258
|
+
type: "(",
|
|
259
|
+
beforeExpr: true
|
|
260
|
+
};
|
|
261
|
+
var _parenR = {
|
|
262
|
+
type: ")"
|
|
263
|
+
};
|
|
264
|
+
var _comma = {
|
|
265
|
+
type: ",",
|
|
266
|
+
beforeExpr: true
|
|
267
|
+
};
|
|
268
|
+
var _semi = {
|
|
269
|
+
type: ";",
|
|
270
|
+
beforeExpr: true
|
|
271
|
+
};
|
|
272
|
+
var _colon = {
|
|
273
|
+
type: ":",
|
|
274
|
+
beforeExpr: true
|
|
275
|
+
};
|
|
276
|
+
var _dot = {
|
|
277
|
+
type: "."
|
|
278
|
+
};
|
|
279
|
+
var _question = {
|
|
280
|
+
type: "?",
|
|
281
|
+
beforeExpr: true
|
|
282
|
+
};
|
|
283
|
+
var _slash = {
|
|
284
|
+
binop: 10,
|
|
285
|
+
beforeExpr: true
|
|
286
|
+
};
|
|
287
|
+
var _eq = {
|
|
288
|
+
isAssign: true,
|
|
289
|
+
beforeExpr: true
|
|
290
|
+
};
|
|
291
|
+
var _assign = {
|
|
292
|
+
isAssign: true,
|
|
293
|
+
beforeExpr: true
|
|
294
|
+
};
|
|
295
|
+
var _incDec = {
|
|
296
|
+
postfix: true,
|
|
297
|
+
prefix: true,
|
|
298
|
+
isUpdate: true
|
|
299
|
+
};
|
|
300
|
+
var _prefix = {
|
|
301
|
+
prefix: true,
|
|
302
|
+
beforeExpr: true
|
|
303
|
+
};
|
|
304
|
+
var _logicalOR = {
|
|
305
|
+
binop: 1,
|
|
306
|
+
beforeExpr: true
|
|
307
|
+
};
|
|
308
|
+
var _logicalAND = {
|
|
309
|
+
binop: 2,
|
|
310
|
+
beforeExpr: true
|
|
311
|
+
};
|
|
312
|
+
var _bitwiseOR = {
|
|
313
|
+
binop: 3,
|
|
314
|
+
beforeExpr: true
|
|
315
|
+
};
|
|
316
|
+
var _bitwiseXOR = {
|
|
317
|
+
binop: 4,
|
|
318
|
+
beforeExpr: true
|
|
319
|
+
};
|
|
320
|
+
var _bitwiseAND = {
|
|
321
|
+
binop: 5,
|
|
322
|
+
beforeExpr: true
|
|
323
|
+
};
|
|
324
|
+
var _equality = {
|
|
325
|
+
binop: 6,
|
|
326
|
+
beforeExpr: true
|
|
327
|
+
};
|
|
328
|
+
var _relational = {
|
|
329
|
+
binop: 7,
|
|
330
|
+
beforeExpr: true
|
|
331
|
+
};
|
|
332
|
+
var _bitShift = {
|
|
333
|
+
binop: 8,
|
|
334
|
+
beforeExpr: true
|
|
335
|
+
};
|
|
336
|
+
var _plusMin = {
|
|
337
|
+
binop: 9,
|
|
338
|
+
prefix: true,
|
|
339
|
+
beforeExpr: true
|
|
340
|
+
};
|
|
341
|
+
var _multiplyModulo = {
|
|
342
|
+
binop: 10,
|
|
343
|
+
beforeExpr: true
|
|
344
|
+
};
|
|
345
|
+
function makePredicate(words) {
|
|
346
|
+
var wordList = words.split(" ");
|
|
347
|
+
var set = Object.create(null);
|
|
348
|
+
for (var i = 0; i < wordList.length; i++) {
|
|
349
|
+
set[wordList[i]] = true;
|
|
350
|
+
}
|
|
351
|
+
return function (str) {
|
|
352
|
+
return set[str] || false;
|
|
353
|
+
};
|
|
354
|
+
}
|
|
355
|
+
var isReservedWord5 = makePredicate("class enum extends super const export import");
|
|
356
|
+
var isStrictReservedWord = makePredicate("implements interface let package private protected public static yield");
|
|
357
|
+
var isStrictBadIdWord = makePredicate("eval arguments");
|
|
358
|
+
var isKeyword = makePredicate("break case catch continue debugger default do else finally for function if return switch throw try var while with null true false instanceof typeof void delete new in this");
|
|
359
|
+
var nonASCIIwhitespace = /[\u1680\u180e\u2000-\u200a\u202f\u205f\u3000\ufeff]/;
|
|
360
|
+
var nonASCIIidentifierStartChars = "\xAA\xB5\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0370-\u0374\u0376\u0377\u037A-\u037D\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u048A-\u0527\u0531-\u0556\u0559\u0561-\u0587\u05D0-\u05EA\u05F0-\u05F2\u0620-\u064A\u066E\u066F\u0671-\u06D3\u06D5\u06E5\u06E6\u06EE\u06EF\u06FA-\u06FC\u06FF\u0710\u0712-\u072F\u074D-\u07A5\u07B1\u07CA-\u07EA\u07F4\u07F5\u07FA\u0800-\u0815\u081A\u0824\u0828\u0840-\u0858\u08A0\u08A2-\u08AC\u0904-\u0939\u093D\u0950\u0958-\u0961\u0971-\u0977\u0979-\u097F\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BD\u09CE\u09DC\u09DD\u09DF-\u09E1\u09F0\u09F1\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A59-\u0A5C\u0A5E\u0A72-\u0A74\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABD\u0AD0\u0AE0\u0AE1\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3D\u0B5C\u0B5D\u0B5F-\u0B61\u0B71\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BD0\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C33\u0C35-\u0C39\u0C3D\u0C58\u0C59\u0C60\u0C61\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBD\u0CDE\u0CE0\u0CE1\u0CF1\u0CF2\u0D05-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D\u0D4E\u0D60\u0D61\u0D7A-\u0D7F\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0E01-\u0E30\u0E32\u0E33\u0E40-\u0E46\u0E81\u0E82\u0E84\u0E87\u0E88\u0E8A\u0E8D\u0E94-\u0E97\u0E99-\u0E9F\u0EA1-\u0EA3\u0EA5\u0EA7\u0EAA\u0EAB\u0EAD-\u0EB0\u0EB2\u0EB3\u0EBD\u0EC0-\u0EC4\u0EC6\u0EDC-\u0EDF\u0F00\u0F40-\u0F47\u0F49-\u0F6C\u0F88-\u0F8C\u1000-\u102A\u103F\u1050-\u1055\u105A-\u105D\u1061\u1065\u1066\u106E-\u1070\u1075-\u1081\u108E\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u1380-\u138F\u13A0-\u13F4\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16EE-\u16F0\u1700-\u170C\u170E-\u1711\u1720-\u1731\u1740-\u1751\u1760-\u176C\u176E-\u1770\u1780-\u17B3\u17D7\u17DC\u1820-\u1877\u1880-\u18A8\u18AA\u18B0-\u18F5\u1900-\u191C\u1950-\u196D\u1970-\u1974\u1980-\u19AB\u19C1-\u19C7\u1A00-\u1A16\u1A20-\u1A54\u1AA7\u1B05-\u1B33\u1B45-\u1B4B\u1B83-\u1BA0\u1BAE\u1BAF\u1BBA-\u1BE5\u1C00-\u1C23\u1C4D-\u1C4F\u1C5A-\u1C7D\u1CE9-\u1CEC\u1CEE-\u1CF1\u1CF5\u1CF6\u1D00-\u1DBF\u1E00-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u2071\u207F\u2090-\u209C\u2102\u2107\u210A-\u2113\u2115\u2119-\u211D\u2124\u2126\u2128\u212A-\u212D\u212F-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2160-\u2188\u2C00-\u2C2E\u2C30-\u2C5E\u2C60-\u2CE4\u2CEB-\u2CEE\u2CF2\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D80-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2E2F\u3005-\u3007\u3021-\u3029\u3031-\u3035\u3038-\u303C\u3041-\u3096\u309D-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312D\u3131-\u318E\u31A0-\u31BA\u31F0-\u31FF\u3400-\u4DB5\u4E00-\u9FCC\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA61F\uA62A\uA62B\uA640-\uA66E\uA67F-\uA697\uA6A0-\uA6EF\uA717-\uA71F\uA722-\uA788\uA78B-\uA78E\uA790-\uA793\uA7A0-\uA7AA\uA7F8-\uA801\uA803-\uA805\uA807-\uA80A\uA80C-\uA822\uA840-\uA873\uA882-\uA8B3\uA8F2-\uA8F7\uA8FB\uA90A-\uA925\uA930-\uA946\uA960-\uA97C\uA984-\uA9B2\uA9CF\uAA00-\uAA28\uAA40-\uAA42\uAA44-\uAA4B\uAA60-\uAA76\uAA7A\uAA80-\uAAAF\uAAB1\uAAB5\uAAB6\uAAB9-\uAABD\uAAC0\uAAC2\uAADB-\uAADD\uAAE0-\uAAEA\uAAF2-\uAAF4\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uABC0-\uABE2\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D\uFB1F-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE70-\uFE74\uFE76-\uFEFC\uFF21-\uFF3A\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC";
|
|
361
|
+
var nonASCIIidentifierChars = "\u0300-\u036F\u0483-\u0487\u0591-\u05BD\u05BF\u05C1\u05C2\u05C4\u05C5\u05C7\u0610-\u061A\u0620-\u0649\u0672-\u06D3\u06E7-\u06E8\u06FB-\u06FC\u0730-\u074A\u0800-\u0814\u081B-\u0823\u0825-\u0827\u0829-\u082D\u0840-\u0857\u08E4-\u08FE\u0900-\u0903\u093A-\u093C\u093E-\u094F\u0951-\u0957\u0962-\u0963\u0966-\u096F\u0981-\u0983\u09BC\u09BE-\u09C4\u09C7\u09C8\u09D7\u09DF-\u09E0\u0A01-\u0A03\u0A3C\u0A3E-\u0A42\u0A47\u0A48\u0A4B-\u0A4D\u0A51\u0A66-\u0A71\u0A75\u0A81-\u0A83\u0ABC\u0ABE-\u0AC5\u0AC7-\u0AC9\u0ACB-\u0ACD\u0AE2-\u0AE3\u0AE6-\u0AEF\u0B01-\u0B03\u0B3C\u0B3E-\u0B44\u0B47\u0B48\u0B4B-\u0B4D\u0B56\u0B57\u0B5F-\u0B60\u0B66-\u0B6F\u0B82\u0BBE-\u0BC2\u0BC6-\u0BC8\u0BCA-\u0BCD\u0BD7\u0BE6-\u0BEF\u0C01-\u0C03\u0C46-\u0C48\u0C4A-\u0C4D\u0C55\u0C56\u0C62-\u0C63\u0C66-\u0C6F\u0C82\u0C83\u0CBC\u0CBE-\u0CC4\u0CC6-\u0CC8\u0CCA-\u0CCD\u0CD5\u0CD6\u0CE2-\u0CE3\u0CE6-\u0CEF\u0D02\u0D03\u0D46-\u0D48\u0D57\u0D62-\u0D63\u0D66-\u0D6F\u0D82\u0D83\u0DCA\u0DCF-\u0DD4\u0DD6\u0DD8-\u0DDF\u0DF2\u0DF3\u0E34-\u0E3A\u0E40-\u0E45\u0E50-\u0E59\u0EB4-\u0EB9\u0EC8-\u0ECD\u0ED0-\u0ED9\u0F18\u0F19\u0F20-\u0F29\u0F35\u0F37\u0F39\u0F41-\u0F47\u0F71-\u0F84\u0F86-\u0F87\u0F8D-\u0F97\u0F99-\u0FBC\u0FC6\u1000-\u1029\u1040-\u1049\u1067-\u106D\u1071-\u1074\u1082-\u108D\u108F-\u109D\u135D-\u135F\u170E-\u1710\u1720-\u1730\u1740-\u1750\u1772\u1773\u1780-\u17B2\u17DD\u17E0-\u17E9\u180B-\u180D\u1810-\u1819\u1920-\u192B\u1930-\u193B\u1951-\u196D\u19B0-\u19C0\u19C8-\u19C9\u19D0-\u19D9\u1A00-\u1A15\u1A20-\u1A53\u1A60-\u1A7C\u1A7F-\u1A89\u1A90-\u1A99\u1B46-\u1B4B\u1B50-\u1B59\u1B6B-\u1B73\u1BB0-\u1BB9\u1BE6-\u1BF3\u1C00-\u1C22\u1C40-\u1C49\u1C5B-\u1C7D\u1CD0-\u1CD2\u1D00-\u1DBE\u1E01-\u1F15\u200C\u200D\u203F\u2040\u2054\u20D0-\u20DC\u20E1\u20E5-\u20F0\u2D81-\u2D96\u2DE0-\u2DFF\u3021-\u3028\u3099\u309A\uA640-\uA66D\uA674-\uA67D\uA69F\uA6F0-\uA6F1\uA7F8-\uA800\uA806\uA80B\uA823-\uA827\uA880-\uA881\uA8B4-\uA8C4\uA8D0-\uA8D9\uA8F3-\uA8F7\uA900-\uA909\uA926-\uA92D\uA930-\uA945\uA980-\uA983\uA9B3-\uA9C0\uAA00-\uAA27\uAA40-\uAA41\uAA4C-\uAA4D\uAA50-\uAA59\uAA7B\uAAE0-\uAAE9\uAAF2-\uAAF3\uABC0-\uABE1\uABEC\uABED\uABF0-\uABF9\uFB20-\uFB28\uFE00-\uFE0F\uFE20-\uFE26\uFE33\uFE34\uFE4D-\uFE4F\uFF10-\uFF19\uFF3F";
|
|
362
|
+
var nonASCIIidentifierStart = new RegExp("[" + nonASCIIidentifierStartChars + "]");
|
|
363
|
+
var nonASCIIidentifier = new RegExp("[" + nonASCIIidentifierStartChars + nonASCIIidentifierChars + "]");
|
|
364
|
+
var newline = /[\n\r\u2028\u2029]/;
|
|
365
|
+
var lineBreak = /\r\n|[\n\r\u2028\u2029]/g;
|
|
366
|
+
var isIdentifierStart = function (code) {
|
|
367
|
+
if (code < 65) return code === 36;
|
|
368
|
+
if (code < 91) return true;
|
|
369
|
+
if (code < 97) return code === 95;
|
|
370
|
+
if (code < 123) return true;
|
|
371
|
+
return code >= 170 && nonASCIIidentifierStart.test(String.fromCharCode(code));
|
|
372
|
+
};
|
|
373
|
+
var isIdentifierChar = function (code) {
|
|
374
|
+
if (code < 48) return code === 36;
|
|
375
|
+
if (code < 58) return true;
|
|
376
|
+
if (code < 65) return false;
|
|
377
|
+
if (code < 91) return true;
|
|
378
|
+
if (code < 97) return code === 95;
|
|
379
|
+
if (code < 123) return true;
|
|
380
|
+
return code >= 170 && nonASCIIidentifier.test(String.fromCharCode(code));
|
|
381
|
+
};
|
|
382
|
+
function line_loc_t() {
|
|
383
|
+
this.line = tokCurLine;
|
|
384
|
+
this.column = tokPos - tokLineStart;
|
|
385
|
+
}
|
|
386
|
+
function initTokenState() {
|
|
387
|
+
tokCurLine = 1;
|
|
388
|
+
tokPos = tokLineStart = 0;
|
|
389
|
+
tokRegexpAllowed = true;
|
|
390
|
+
skipSpace();
|
|
391
|
+
}
|
|
392
|
+
function finishToken(type, val) {
|
|
393
|
+
tokEnd = tokPos;
|
|
394
|
+
if (options.locations) {
|
|
395
|
+
tokEndLoc = new line_loc_t();
|
|
396
|
+
}
|
|
397
|
+
tokType = type;
|
|
398
|
+
skipSpace();
|
|
399
|
+
tokVal = val;
|
|
400
|
+
tokRegexpAllowed = type.beforeExpr;
|
|
401
|
+
}
|
|
402
|
+
function skipBlockComment() {
|
|
403
|
+
var startLoc = options.onComment && options.locations && new line_loc_t();
|
|
404
|
+
var start = tokPos;
|
|
405
|
+
var end = input.indexOf("*/", tokPos += 2);
|
|
406
|
+
if (end === -1) {
|
|
407
|
+
raise(tokPos - 2, "Unterminated comment");
|
|
408
|
+
}
|
|
409
|
+
tokPos = end + 2;
|
|
410
|
+
if (options.locations) {
|
|
411
|
+
lineBreak.lastIndex = start;
|
|
412
|
+
var match;
|
|
413
|
+
while ((match = lineBreak.exec(input)) && match.index < tokPos) {
|
|
414
|
+
++tokCurLine;
|
|
415
|
+
tokLineStart = match.index + match[0].length;
|
|
416
|
+
}
|
|
417
|
+
}
|
|
418
|
+
if (options.onComment) {
|
|
419
|
+
options.onComment(true, input.slice(start + 2, end), start, tokPos, startLoc, options.locations && new line_loc_t());
|
|
420
|
+
}
|
|
421
|
+
}
|
|
422
|
+
function skipLineComment() {
|
|
423
|
+
var start = tokPos;
|
|
424
|
+
var startLoc = options.onComment && options.locations && new line_loc_t();
|
|
425
|
+
var ch = input.charCodeAt(tokPos += 2);
|
|
426
|
+
while (tokPos < inputLen && ch !== 10 && ch !== 13 && ch !== 8232 && ch !== 8233) {
|
|
427
|
+
++tokPos;
|
|
428
|
+
ch = input.charCodeAt(tokPos);
|
|
429
|
+
}
|
|
430
|
+
if (options.onComment) {
|
|
431
|
+
options.onComment(false, input.slice(start + 2, tokPos), start, tokPos, startLoc, options.locations && new line_loc_t());
|
|
432
|
+
}
|
|
433
|
+
}
|
|
434
|
+
function skipSpace() {
|
|
435
|
+
while (tokPos < inputLen) {
|
|
436
|
+
var ch = input.charCodeAt(tokPos);
|
|
437
|
+
if (ch === 32) {
|
|
438
|
+
++tokPos;
|
|
439
|
+
} else if (ch === 13) {
|
|
440
|
+
++tokPos;
|
|
441
|
+
var next2 = input.charCodeAt(tokPos);
|
|
442
|
+
if (next2 === 10) {
|
|
443
|
+
++tokPos;
|
|
444
|
+
}
|
|
445
|
+
if (options.locations) {
|
|
446
|
+
++tokCurLine;
|
|
447
|
+
tokLineStart = tokPos;
|
|
448
|
+
}
|
|
449
|
+
} else if (ch === 10 || ch === 8232 || ch === 8233) {
|
|
450
|
+
++tokPos;
|
|
451
|
+
if (options.locations) {
|
|
452
|
+
++tokCurLine;
|
|
453
|
+
tokLineStart = tokPos;
|
|
454
|
+
}
|
|
455
|
+
} else if (ch > 8 && ch < 14) {
|
|
456
|
+
++tokPos;
|
|
457
|
+
} else if (ch === 47) {
|
|
458
|
+
var next2 = input.charCodeAt(tokPos + 1);
|
|
459
|
+
if (next2 === 42) {
|
|
460
|
+
skipBlockComment();
|
|
461
|
+
} else if (next2 === 47) {
|
|
462
|
+
skipLineComment();
|
|
463
|
+
} else break;
|
|
464
|
+
} else if (ch === 160) {
|
|
465
|
+
++tokPos;
|
|
466
|
+
} else if (ch >= 5760 && nonASCIIwhitespace.test(String.fromCharCode(ch))) {
|
|
467
|
+
++tokPos;
|
|
468
|
+
} else {
|
|
469
|
+
break;
|
|
470
|
+
}
|
|
471
|
+
}
|
|
472
|
+
}
|
|
473
|
+
function readToken_dot() {
|
|
474
|
+
var next2 = input.charCodeAt(tokPos + 1);
|
|
475
|
+
if (next2 >= 48 && next2 <= 57) {
|
|
476
|
+
readNumber(true);
|
|
477
|
+
} else {
|
|
478
|
+
++tokPos;
|
|
479
|
+
finishToken(_dot);
|
|
480
|
+
}
|
|
481
|
+
}
|
|
482
|
+
function readToken_slash() {
|
|
483
|
+
var next2 = input.charCodeAt(tokPos + 1);
|
|
484
|
+
if (tokRegexpAllowed) {
|
|
485
|
+
++tokPos;
|
|
486
|
+
readRegexp();
|
|
487
|
+
} else if (next2 === 61) {
|
|
488
|
+
finishOp(_assign, 2);
|
|
489
|
+
} else {
|
|
490
|
+
finishOp(_slash, 1);
|
|
491
|
+
}
|
|
492
|
+
}
|
|
493
|
+
function readToken_mult_modulo() {
|
|
494
|
+
var next2 = input.charCodeAt(tokPos + 1);
|
|
495
|
+
if (next2 === 61) {
|
|
496
|
+
finishOp(_assign, 2);
|
|
497
|
+
} else {
|
|
498
|
+
finishOp(_multiplyModulo, 1);
|
|
499
|
+
}
|
|
500
|
+
}
|
|
501
|
+
function readToken_pipe_amp(code) {
|
|
502
|
+
var next2 = input.charCodeAt(tokPos + 1);
|
|
503
|
+
if (next2 === code) {
|
|
504
|
+
finishOp(code === 124 ? _logicalOR : _logicalAND, 2);
|
|
505
|
+
} else if (next2 === 61) {
|
|
506
|
+
finishOp(_assign, 2);
|
|
507
|
+
} else {
|
|
508
|
+
finishOp(code === 124 ? _bitwiseOR : _bitwiseAND, 1);
|
|
509
|
+
}
|
|
510
|
+
}
|
|
511
|
+
function readToken_caret() {
|
|
512
|
+
var next2 = input.charCodeAt(tokPos + 1);
|
|
513
|
+
if (next2 === 61) {
|
|
514
|
+
finishOp(_assign, 2);
|
|
515
|
+
} else {
|
|
516
|
+
finishOp(_bitwiseXOR, 1);
|
|
517
|
+
}
|
|
518
|
+
}
|
|
519
|
+
function readToken_plus_min(code) {
|
|
520
|
+
var next2 = input.charCodeAt(tokPos + 1);
|
|
521
|
+
if (next2 === code) {
|
|
522
|
+
if (next2 === 45 && input.charCodeAt(tokPos + 2) === 62 && newline.test(input.slice(lastEnd, tokPos))) {
|
|
523
|
+
tokPos += 3;
|
|
524
|
+
skipLineComment();
|
|
525
|
+
skipSpace();
|
|
526
|
+
readToken();
|
|
527
|
+
return;
|
|
528
|
+
}
|
|
529
|
+
finishOp(_incDec, 2);
|
|
530
|
+
} else if (next2 === 61) {
|
|
531
|
+
finishOp(_assign, 2);
|
|
532
|
+
} else {
|
|
533
|
+
finishOp(_plusMin, 1);
|
|
534
|
+
}
|
|
535
|
+
}
|
|
536
|
+
function readToken_lt_gt(code) {
|
|
537
|
+
var next2 = input.charCodeAt(tokPos + 1);
|
|
538
|
+
var size = 1;
|
|
539
|
+
if (next2 === code) {
|
|
540
|
+
size = code === 62 && input.charCodeAt(tokPos + 2) === 62 ? 3 : 2;
|
|
541
|
+
if (input.charCodeAt(tokPos + size) === 61) {
|
|
542
|
+
finishOp(_assign, size + 1);
|
|
543
|
+
} else {
|
|
544
|
+
finishOp(_bitShift, size);
|
|
545
|
+
}
|
|
546
|
+
return;
|
|
547
|
+
}
|
|
548
|
+
if (next2 === 33 && code === 60 && input.charCodeAt(tokPos + 2) === 45 && input.charCodeAt(tokPos + 3) === 45) {
|
|
549
|
+
tokPos += 4;
|
|
550
|
+
skipLineComment();
|
|
551
|
+
skipSpace();
|
|
552
|
+
readToken();
|
|
553
|
+
return;
|
|
554
|
+
}
|
|
555
|
+
if (next2 === 61) {
|
|
556
|
+
size = input.charCodeAt(tokPos + 2) === 61 ? 3 : 2;
|
|
557
|
+
}
|
|
558
|
+
finishOp(_relational, size);
|
|
559
|
+
}
|
|
560
|
+
function readToken_eq_excl(code) {
|
|
561
|
+
var next2 = input.charCodeAt(tokPos + 1);
|
|
562
|
+
if (next2 === 61) {
|
|
563
|
+
finishOp(_equality, input.charCodeAt(tokPos + 2) === 61 ? 3 : 2);
|
|
564
|
+
} else {
|
|
565
|
+
finishOp(code === 61 ? _eq : _prefix, 1);
|
|
566
|
+
}
|
|
567
|
+
}
|
|
568
|
+
function getTokenFromCode(code) {
|
|
569
|
+
switch (code) {
|
|
570
|
+
case 46:
|
|
571
|
+
return readToken_dot();
|
|
572
|
+
case 40:
|
|
573
|
+
++tokPos;
|
|
574
|
+
return finishToken(_parenL);
|
|
575
|
+
case 41:
|
|
576
|
+
++tokPos;
|
|
577
|
+
return finishToken(_parenR);
|
|
578
|
+
case 59:
|
|
579
|
+
++tokPos;
|
|
580
|
+
return finishToken(_semi);
|
|
581
|
+
case 44:
|
|
582
|
+
++tokPos;
|
|
583
|
+
return finishToken(_comma);
|
|
584
|
+
case 91:
|
|
585
|
+
++tokPos;
|
|
586
|
+
return finishToken(_bracketL);
|
|
587
|
+
case 93:
|
|
588
|
+
++tokPos;
|
|
589
|
+
return finishToken(_bracketR);
|
|
590
|
+
case 123:
|
|
591
|
+
++tokPos;
|
|
592
|
+
return finishToken(_braceL);
|
|
593
|
+
case 125:
|
|
594
|
+
++tokPos;
|
|
595
|
+
return finishToken(_braceR);
|
|
596
|
+
case 58:
|
|
597
|
+
++tokPos;
|
|
598
|
+
return finishToken(_colon);
|
|
599
|
+
case 63:
|
|
600
|
+
++tokPos;
|
|
601
|
+
return finishToken(_question);
|
|
602
|
+
case 48:
|
|
603
|
+
var next2 = input.charCodeAt(tokPos + 1);
|
|
604
|
+
if (next2 === 120 || next2 === 88) return readHexNumber();
|
|
605
|
+
case 49:
|
|
606
|
+
case 50:
|
|
607
|
+
case 51:
|
|
608
|
+
case 52:
|
|
609
|
+
case 53:
|
|
610
|
+
case 54:
|
|
611
|
+
case 55:
|
|
612
|
+
case 56:
|
|
613
|
+
case 57:
|
|
614
|
+
return readNumber(false);
|
|
615
|
+
case 34:
|
|
616
|
+
case 39:
|
|
617
|
+
return readString(code);
|
|
618
|
+
case 47:
|
|
619
|
+
return readToken_slash();
|
|
620
|
+
case 37:
|
|
621
|
+
case 42:
|
|
622
|
+
return readToken_mult_modulo();
|
|
623
|
+
case 124:
|
|
624
|
+
case 38:
|
|
625
|
+
return readToken_pipe_amp(code);
|
|
626
|
+
case 94:
|
|
627
|
+
return readToken_caret();
|
|
628
|
+
case 43:
|
|
629
|
+
case 45:
|
|
630
|
+
return readToken_plus_min(code);
|
|
631
|
+
case 60:
|
|
632
|
+
case 62:
|
|
633
|
+
return readToken_lt_gt(code);
|
|
634
|
+
case 61:
|
|
635
|
+
case 33:
|
|
636
|
+
return readToken_eq_excl(code);
|
|
637
|
+
case 126:
|
|
638
|
+
return finishOp(_prefix, 1);
|
|
639
|
+
}
|
|
640
|
+
return false;
|
|
641
|
+
}
|
|
642
|
+
function readToken(forceRegexp) {
|
|
643
|
+
if (!forceRegexp) {
|
|
644
|
+
tokStart = tokPos;
|
|
645
|
+
} else {
|
|
646
|
+
tokPos = tokStart + 1;
|
|
647
|
+
}
|
|
648
|
+
if (options.locations) {
|
|
649
|
+
tokStartLoc = new line_loc_t();
|
|
650
|
+
}
|
|
651
|
+
if (forceRegexp) return readRegexp();
|
|
652
|
+
if (tokPos >= inputLen) return finishToken(_eof);
|
|
653
|
+
var code = input.charCodeAt(tokPos);
|
|
654
|
+
if (isIdentifierStart(code) || code === 92) {
|
|
655
|
+
return readWord();
|
|
656
|
+
}
|
|
657
|
+
var tok = getTokenFromCode(code);
|
|
658
|
+
if (tok === false) {
|
|
659
|
+
var ch = String.fromCharCode(code);
|
|
660
|
+
if (ch === "\\" || nonASCIIidentifierStart.test(ch)) {
|
|
661
|
+
return readWord();
|
|
662
|
+
}
|
|
663
|
+
raise(tokPos, "Unexpected character '" + ch + "'");
|
|
664
|
+
}
|
|
665
|
+
}
|
|
666
|
+
function finishOp(type, size) {
|
|
667
|
+
var str = input.slice(tokPos, tokPos + size);
|
|
668
|
+
tokPos += size;
|
|
669
|
+
finishToken(type, str);
|
|
670
|
+
}
|
|
671
|
+
function readRegexp() {
|
|
672
|
+
var escaped;
|
|
673
|
+
var inClass;
|
|
674
|
+
var start = tokPos;
|
|
675
|
+
for (;;) {
|
|
676
|
+
if (tokPos >= inputLen) raise(start, "Unterminated regexp");
|
|
677
|
+
var ch = input.charAt(tokPos);
|
|
678
|
+
if (newline.test(ch)) raise(start, "Unterminated regexp");
|
|
679
|
+
if (!escaped) {
|
|
680
|
+
if (ch === "[") {
|
|
681
|
+
inClass = true;
|
|
682
|
+
} else if (ch === "]" && inClass) {
|
|
683
|
+
inClass = false;
|
|
684
|
+
} else if (ch === "/" && !inClass) {
|
|
685
|
+
break;
|
|
686
|
+
}
|
|
687
|
+
escaped = ch === "\\";
|
|
688
|
+
} else escaped = false;
|
|
689
|
+
++tokPos;
|
|
690
|
+
}
|
|
691
|
+
var content = input.slice(start, tokPos);
|
|
692
|
+
++tokPos;
|
|
693
|
+
var mods = readWord1();
|
|
694
|
+
if (mods && !/^[gmi]*$/.test(mods)) {
|
|
695
|
+
raise(start, "Invalid regexp flag");
|
|
696
|
+
}
|
|
697
|
+
try {
|
|
698
|
+
var value = new RegExp(content, mods);
|
|
699
|
+
} catch (e) {
|
|
700
|
+
if (e instanceof SyntaxError) raise(start, e.message);
|
|
701
|
+
throw e;
|
|
702
|
+
}
|
|
703
|
+
finishToken(_regexp, value);
|
|
704
|
+
}
|
|
705
|
+
function readInt(radix, len) {
|
|
706
|
+
var start = tokPos;
|
|
707
|
+
var total = 0;
|
|
708
|
+
var e = len === void 0 ? Infinity : len;
|
|
709
|
+
for (var i = 0; i < e; ++i) {
|
|
710
|
+
var code = input.charCodeAt(tokPos),
|
|
711
|
+
val;
|
|
712
|
+
if (code >= 97) {
|
|
713
|
+
val = code - 97 + 10;
|
|
714
|
+
} else if (code >= 65) {
|
|
715
|
+
val = code - 65 + 10;
|
|
716
|
+
} else if (code >= 48 && code <= 57) {
|
|
717
|
+
val = code - 48;
|
|
718
|
+
} else {
|
|
719
|
+
val = Infinity;
|
|
720
|
+
}
|
|
721
|
+
if (val >= radix) break;
|
|
722
|
+
++tokPos;
|
|
723
|
+
total = total * radix + val;
|
|
724
|
+
}
|
|
725
|
+
if (tokPos === start || len !== void 0 && tokPos - start !== len) {
|
|
726
|
+
return null;
|
|
727
|
+
}
|
|
728
|
+
return total;
|
|
729
|
+
}
|
|
730
|
+
function readHexNumber() {
|
|
731
|
+
tokPos += 2;
|
|
732
|
+
var val = readInt(16);
|
|
733
|
+
if (val === null) {
|
|
734
|
+
raise(tokStart + 2, "Expected hexadecimal number");
|
|
735
|
+
}
|
|
736
|
+
if (isIdentifierStart(input.charCodeAt(tokPos))) {
|
|
737
|
+
raise(tokPos, "Identifier directly after number");
|
|
738
|
+
}
|
|
739
|
+
finishToken(_num, val);
|
|
740
|
+
}
|
|
741
|
+
function readNumber(startsWithDot) {
|
|
742
|
+
var start = tokPos;
|
|
743
|
+
var isFloat = false;
|
|
744
|
+
var octal = input.charCodeAt(tokPos) === 48;
|
|
745
|
+
if (!startsWithDot && readInt(10) === null) {
|
|
746
|
+
raise(start, "Invalid number");
|
|
747
|
+
}
|
|
748
|
+
if (input.charCodeAt(tokPos) === 46) {
|
|
749
|
+
++tokPos;
|
|
750
|
+
readInt(10);
|
|
751
|
+
isFloat = true;
|
|
752
|
+
}
|
|
753
|
+
var next2 = input.charCodeAt(tokPos);
|
|
754
|
+
if (next2 === 69 || next2 === 101) {
|
|
755
|
+
next2 = input.charCodeAt(++tokPos);
|
|
756
|
+
if (next2 === 43 || next2 === 45) {
|
|
757
|
+
++tokPos;
|
|
758
|
+
}
|
|
759
|
+
if (readInt(10) === null) {
|
|
760
|
+
raise(start, "Invalid number");
|
|
761
|
+
}
|
|
762
|
+
isFloat = true;
|
|
763
|
+
}
|
|
764
|
+
if (isIdentifierStart(input.charCodeAt(tokPos))) {
|
|
765
|
+
raise(tokPos, "Identifier directly after number");
|
|
766
|
+
}
|
|
767
|
+
var str = input.slice(start, tokPos);
|
|
768
|
+
var val;
|
|
769
|
+
if (isFloat) {
|
|
770
|
+
val = parseFloat(str);
|
|
771
|
+
} else if (!octal || str.length === 1) {
|
|
772
|
+
val = parseInt(str, 10);
|
|
773
|
+
} else if (/[89]/.test(str) || strict) {
|
|
774
|
+
raise(start, "Invalid number");
|
|
775
|
+
} else {
|
|
776
|
+
val = parseInt(str, 8);
|
|
777
|
+
}
|
|
778
|
+
finishToken(_num, val);
|
|
779
|
+
}
|
|
780
|
+
function readString(quote) {
|
|
781
|
+
tokPos++;
|
|
782
|
+
var out = "";
|
|
783
|
+
for (;;) {
|
|
784
|
+
if (tokPos >= inputLen) raise(tokStart, "Unterminated string constant");
|
|
785
|
+
var ch = input.charCodeAt(tokPos);
|
|
786
|
+
if (ch === quote) {
|
|
787
|
+
++tokPos;
|
|
788
|
+
finishToken(_string, out);
|
|
789
|
+
return;
|
|
790
|
+
}
|
|
791
|
+
if (ch === 92) {
|
|
792
|
+
ch = input.charCodeAt(++tokPos);
|
|
793
|
+
var octal = /^[0-7]+/.exec(input.slice(tokPos, tokPos + 3));
|
|
794
|
+
if (octal) {
|
|
795
|
+
octal = octal[0];
|
|
796
|
+
}
|
|
797
|
+
while (octal && parseInt(octal, 8) > 255) {
|
|
798
|
+
octal = octal.slice(0, -1);
|
|
799
|
+
}
|
|
800
|
+
if (octal === "0") {
|
|
801
|
+
octal = null;
|
|
802
|
+
}
|
|
803
|
+
++tokPos;
|
|
804
|
+
if (octal) {
|
|
805
|
+
if (strict) raise(tokPos - 2, "Octal literal in strict mode");
|
|
806
|
+
out += String.fromCharCode(parseInt(octal, 8));
|
|
807
|
+
tokPos += octal.length - 1;
|
|
808
|
+
} else {
|
|
809
|
+
switch (ch) {
|
|
810
|
+
case 110:
|
|
811
|
+
out += "\n";
|
|
812
|
+
break;
|
|
813
|
+
case 114:
|
|
814
|
+
out += "\r";
|
|
815
|
+
break;
|
|
816
|
+
case 120:
|
|
817
|
+
out += String.fromCharCode(readHexChar(2));
|
|
818
|
+
break;
|
|
819
|
+
case 117:
|
|
820
|
+
out += String.fromCharCode(readHexChar(4));
|
|
821
|
+
break;
|
|
822
|
+
case 85:
|
|
823
|
+
out += String.fromCharCode(readHexChar(8));
|
|
824
|
+
break;
|
|
825
|
+
case 116:
|
|
826
|
+
out += " ";
|
|
827
|
+
break;
|
|
828
|
+
case 98:
|
|
829
|
+
out += "\b";
|
|
830
|
+
break;
|
|
831
|
+
case 118:
|
|
832
|
+
out += "\v";
|
|
833
|
+
break;
|
|
834
|
+
case 102:
|
|
835
|
+
out += "\f";
|
|
836
|
+
break;
|
|
837
|
+
case 48:
|
|
838
|
+
out += "\0";
|
|
839
|
+
break;
|
|
840
|
+
case 13:
|
|
841
|
+
if (input.charCodeAt(tokPos) === 10) {
|
|
842
|
+
++tokPos;
|
|
843
|
+
}
|
|
844
|
+
case 10:
|
|
845
|
+
if (options.locations) {
|
|
846
|
+
tokLineStart = tokPos;
|
|
847
|
+
++tokCurLine;
|
|
848
|
+
}
|
|
849
|
+
break;
|
|
850
|
+
default:
|
|
851
|
+
out += String.fromCharCode(ch);
|
|
852
|
+
break;
|
|
853
|
+
}
|
|
854
|
+
}
|
|
855
|
+
} else {
|
|
856
|
+
if (ch === 13 || ch === 10 || ch === 8232 || ch === 8233) {
|
|
857
|
+
raise(tokStart, "Unterminated string constant");
|
|
858
|
+
}
|
|
859
|
+
out += String.fromCharCode(ch);
|
|
860
|
+
++tokPos;
|
|
861
|
+
}
|
|
862
|
+
}
|
|
863
|
+
}
|
|
864
|
+
function readHexChar(len) {
|
|
865
|
+
var n = readInt(16, len);
|
|
866
|
+
if (n === null) raise(tokStart, "Bad character escape sequence");
|
|
867
|
+
return n;
|
|
868
|
+
}
|
|
869
|
+
var containsEsc;
|
|
870
|
+
function readWord1() {
|
|
871
|
+
containsEsc = false;
|
|
872
|
+
var word;
|
|
873
|
+
var first = true;
|
|
874
|
+
var start = tokPos;
|
|
875
|
+
for (;;) {
|
|
876
|
+
var ch = input.charCodeAt(tokPos);
|
|
877
|
+
if (isIdentifierChar(ch)) {
|
|
878
|
+
if (containsEsc) {
|
|
879
|
+
word += input.charAt(tokPos);
|
|
880
|
+
}
|
|
881
|
+
++tokPos;
|
|
882
|
+
} else if (ch === 92) {
|
|
883
|
+
if (!containsEsc) {
|
|
884
|
+
word = input.slice(start, tokPos);
|
|
885
|
+
}
|
|
886
|
+
containsEsc = true;
|
|
887
|
+
if (input.charCodeAt(++tokPos) !== 117) {
|
|
888
|
+
raise(tokPos, "Expecting Unicode escape sequence \\uXXXX");
|
|
889
|
+
}
|
|
890
|
+
++tokPos;
|
|
891
|
+
var esc = readHexChar(4);
|
|
892
|
+
var escStr = String.fromCharCode(esc);
|
|
893
|
+
if (!escStr) raise(tokPos - 1, "Invalid Unicode escape");
|
|
894
|
+
if (!(first ? isIdentifierStart(esc) : isIdentifierChar(esc))) {
|
|
895
|
+
raise(tokPos - 4, "Invalid Unicode escape");
|
|
896
|
+
}
|
|
897
|
+
word += escStr;
|
|
898
|
+
} else {
|
|
899
|
+
break;
|
|
900
|
+
}
|
|
901
|
+
first = false;
|
|
902
|
+
}
|
|
903
|
+
return containsEsc ? word : input.slice(start, tokPos);
|
|
904
|
+
}
|
|
905
|
+
function readWord() {
|
|
906
|
+
var word = readWord1();
|
|
907
|
+
var type = _name;
|
|
908
|
+
if (!containsEsc && isKeyword(word)) {
|
|
909
|
+
type = keywordTypes[word];
|
|
910
|
+
}
|
|
911
|
+
finishToken(type, word);
|
|
912
|
+
}
|
|
913
|
+
function next() {
|
|
914
|
+
lastStart = tokStart;
|
|
915
|
+
lastEnd = tokEnd;
|
|
916
|
+
lastEndLoc = tokEndLoc;
|
|
917
|
+
readToken();
|
|
918
|
+
}
|
|
919
|
+
function setStrict(strct) {
|
|
920
|
+
strict = strct;
|
|
921
|
+
tokPos = tokStart;
|
|
922
|
+
if (options.locations) {
|
|
923
|
+
while (tokPos < tokLineStart) {
|
|
924
|
+
tokLineStart = input.lastIndexOf("\n", tokLineStart - 2) + 1;
|
|
925
|
+
--tokCurLine;
|
|
926
|
+
}
|
|
927
|
+
}
|
|
928
|
+
skipSpace();
|
|
929
|
+
readToken();
|
|
930
|
+
}
|
|
931
|
+
function node_t() {
|
|
932
|
+
this.type = null;
|
|
933
|
+
this.start = tokStart;
|
|
934
|
+
this.end = null;
|
|
935
|
+
}
|
|
936
|
+
function node_loc_t() {
|
|
937
|
+
this.start = tokStartLoc;
|
|
938
|
+
this.end = null;
|
|
939
|
+
if (sourceFile) {
|
|
940
|
+
this.source = sourceFile;
|
|
941
|
+
}
|
|
942
|
+
}
|
|
943
|
+
function startNode() {
|
|
944
|
+
var node = new node_t();
|
|
945
|
+
if (options.locations) {
|
|
946
|
+
node.loc = new node_loc_t();
|
|
947
|
+
}
|
|
948
|
+
if (options.directSourceFile) {
|
|
949
|
+
node.sourceFile = options.directSourceFile;
|
|
950
|
+
}
|
|
951
|
+
if (options.ranges) {
|
|
952
|
+
node.range = [tokStart, 0];
|
|
953
|
+
}
|
|
954
|
+
return node;
|
|
955
|
+
}
|
|
956
|
+
function startNodeFrom(other) {
|
|
957
|
+
var node = new node_t();
|
|
958
|
+
node.start = other.start;
|
|
959
|
+
if (options.locations) {
|
|
960
|
+
node.loc = new node_loc_t();
|
|
961
|
+
node.loc.start = other.loc.start;
|
|
962
|
+
}
|
|
963
|
+
if (options.ranges) {
|
|
964
|
+
node.range = [other.range[0], 0];
|
|
965
|
+
}
|
|
966
|
+
return node;
|
|
967
|
+
}
|
|
968
|
+
function finishNode(node, type) {
|
|
969
|
+
node.type = type;
|
|
970
|
+
node.end = lastEnd;
|
|
971
|
+
if (options.locations) {
|
|
972
|
+
node.loc.end = lastEndLoc;
|
|
973
|
+
}
|
|
974
|
+
if (options.ranges) {
|
|
975
|
+
node.range[1] = lastEnd;
|
|
976
|
+
}
|
|
977
|
+
return node;
|
|
978
|
+
}
|
|
979
|
+
function isUseStrict(stmt) {
|
|
980
|
+
return stmt.type === "ExpressionStatement" && stmt.expression.type === "Literal" && stmt.expression.value === "use strict";
|
|
981
|
+
}
|
|
982
|
+
function eat(type) {
|
|
983
|
+
if (tokType === type) {
|
|
984
|
+
next();
|
|
985
|
+
return true;
|
|
986
|
+
}
|
|
987
|
+
return false;
|
|
988
|
+
}
|
|
989
|
+
function canInsertSemicolon() {
|
|
990
|
+
return !options.strictSemicolons && (tokType === _eof || tokType === _braceR || newline.test(input.slice(lastEnd, tokStart)));
|
|
991
|
+
}
|
|
992
|
+
function semicolon() {
|
|
993
|
+
if (!eat(_semi) && !canInsertSemicolon()) {
|
|
994
|
+
unexpected();
|
|
995
|
+
}
|
|
996
|
+
}
|
|
997
|
+
function expect(type) {
|
|
998
|
+
if (tokType === type) {
|
|
999
|
+
next();
|
|
1000
|
+
} else {
|
|
1001
|
+
unexpected();
|
|
1002
|
+
}
|
|
1003
|
+
}
|
|
1004
|
+
function unexpected() {
|
|
1005
|
+
raise(tokStart, "Unexpected token");
|
|
1006
|
+
}
|
|
1007
|
+
function checkLVal(expr) {
|
|
1008
|
+
if (expr.type !== "Identifier" && expr.type !== "MemberExpression") {
|
|
1009
|
+
raise(expr.start, "Assigning to rvalue");
|
|
1010
|
+
}
|
|
1011
|
+
if (strict && expr.type === "Identifier" && isStrictBadIdWord(expr.name)) {
|
|
1012
|
+
raise(expr.start, "Assigning to " + expr.name + " in strict mode");
|
|
1013
|
+
}
|
|
1014
|
+
}
|
|
1015
|
+
function parseTopLevel(program) {
|
|
1016
|
+
lastStart = lastEnd = tokPos;
|
|
1017
|
+
if (options.locations) {
|
|
1018
|
+
lastEndLoc = new line_loc_t();
|
|
1019
|
+
}
|
|
1020
|
+
inFunction = strict = false;
|
|
1021
|
+
labels = [];
|
|
1022
|
+
readToken();
|
|
1023
|
+
var node = program || startNode();
|
|
1024
|
+
var first = true;
|
|
1025
|
+
if (!program) {
|
|
1026
|
+
node.body = [];
|
|
1027
|
+
}
|
|
1028
|
+
while (tokType !== _eof) {
|
|
1029
|
+
var stmt = parseStatement();
|
|
1030
|
+
node.body.push(stmt);
|
|
1031
|
+
if (first && isUseStrict(stmt)) {
|
|
1032
|
+
setStrict(true);
|
|
1033
|
+
}
|
|
1034
|
+
first = false;
|
|
1035
|
+
}
|
|
1036
|
+
return finishNode(node, "Program");
|
|
1037
|
+
}
|
|
1038
|
+
var loopLabel = {
|
|
1039
|
+
kind: "loop"
|
|
1040
|
+
};
|
|
1041
|
+
var switchLabel = {
|
|
1042
|
+
kind: "switch"
|
|
1043
|
+
};
|
|
1044
|
+
function parseStatement() {
|
|
1045
|
+
if (tokType === _slash || tokType === _assign && tokVal === "/=") {
|
|
1046
|
+
readToken(true);
|
|
1047
|
+
}
|
|
1048
|
+
var starttype = tokType;
|
|
1049
|
+
var node = startNode();
|
|
1050
|
+
switch (starttype) {
|
|
1051
|
+
case _break:
|
|
1052
|
+
case _continue:
|
|
1053
|
+
next();
|
|
1054
|
+
var isBreak = starttype === _break;
|
|
1055
|
+
if (eat(_semi) || canInsertSemicolon()) {
|
|
1056
|
+
node.label = null;
|
|
1057
|
+
} else if (tokType !== _name) {
|
|
1058
|
+
unexpected();
|
|
1059
|
+
} else {
|
|
1060
|
+
node.label = parseIdent();
|
|
1061
|
+
semicolon();
|
|
1062
|
+
}
|
|
1063
|
+
for (var i = 0; i < labels.length; ++i) {
|
|
1064
|
+
var lab = labels[i];
|
|
1065
|
+
if (node.label === null || lab.name === node.label.name) {
|
|
1066
|
+
if (lab.kind !== null && (isBreak || lab.kind === "loop")) break;
|
|
1067
|
+
if (node.label && isBreak) break;
|
|
1068
|
+
}
|
|
1069
|
+
}
|
|
1070
|
+
if (i === labels.length) {
|
|
1071
|
+
raise(node.start, "Unsyntactic " + starttype.keyword);
|
|
1072
|
+
}
|
|
1073
|
+
return finishNode(node, isBreak ? "BreakStatement" : "ContinueStatement");
|
|
1074
|
+
case _debugger:
|
|
1075
|
+
next();
|
|
1076
|
+
semicolon();
|
|
1077
|
+
return finishNode(node, "DebuggerStatement");
|
|
1078
|
+
case _do:
|
|
1079
|
+
next();
|
|
1080
|
+
labels.push(loopLabel);
|
|
1081
|
+
node.body = parseStatement();
|
|
1082
|
+
labels.pop();
|
|
1083
|
+
expect(_while);
|
|
1084
|
+
node.test = parseParenExpression();
|
|
1085
|
+
semicolon();
|
|
1086
|
+
return finishNode(node, "DoWhileStatement");
|
|
1087
|
+
case _for:
|
|
1088
|
+
next();
|
|
1089
|
+
labels.push(loopLabel);
|
|
1090
|
+
expect(_parenL);
|
|
1091
|
+
if (tokType === _semi) return parseFor(node, null);
|
|
1092
|
+
if (tokType === _var) {
|
|
1093
|
+
var init = startNode();
|
|
1094
|
+
next();
|
|
1095
|
+
parseVar(init, true);
|
|
1096
|
+
finishNode(init, "VariableDeclaration");
|
|
1097
|
+
if (init.declarations.length === 1 && eat(_in)) return parseForIn(node, init);
|
|
1098
|
+
return parseFor(node, init);
|
|
1099
|
+
}
|
|
1100
|
+
var init = parseExpression(false, true);
|
|
1101
|
+
if (eat(_in)) {
|
|
1102
|
+
checkLVal(init);
|
|
1103
|
+
return parseForIn(node, init);
|
|
1104
|
+
}
|
|
1105
|
+
return parseFor(node, init);
|
|
1106
|
+
case _function:
|
|
1107
|
+
next();
|
|
1108
|
+
return parseFunction(node, true);
|
|
1109
|
+
case _if:
|
|
1110
|
+
next();
|
|
1111
|
+
node.test = parseParenExpression();
|
|
1112
|
+
node.consequent = parseStatement();
|
|
1113
|
+
node.alternate = eat(_else) ? parseStatement() : null;
|
|
1114
|
+
return finishNode(node, "IfStatement");
|
|
1115
|
+
case _return:
|
|
1116
|
+
if (!inFunction && !options.allowReturnOutsideFunction) {
|
|
1117
|
+
raise(tokStart, "'return' outside of function");
|
|
1118
|
+
}
|
|
1119
|
+
next();
|
|
1120
|
+
if (eat(_semi) || canInsertSemicolon()) {
|
|
1121
|
+
node.argument = null;
|
|
1122
|
+
} else {
|
|
1123
|
+
node.argument = parseExpression();
|
|
1124
|
+
semicolon();
|
|
1125
|
+
}
|
|
1126
|
+
return finishNode(node, "ReturnStatement");
|
|
1127
|
+
case _switch:
|
|
1128
|
+
next();
|
|
1129
|
+
node.discriminant = parseParenExpression();
|
|
1130
|
+
node.cases = [];
|
|
1131
|
+
expect(_braceL);
|
|
1132
|
+
labels.push(switchLabel);
|
|
1133
|
+
for (var cur, sawDefault; tokType !== _braceR;) {
|
|
1134
|
+
if (tokType === _case || tokType === _default) {
|
|
1135
|
+
var isCase = tokType === _case;
|
|
1136
|
+
if (cur) {
|
|
1137
|
+
finishNode(cur, "SwitchCase");
|
|
1138
|
+
}
|
|
1139
|
+
node.cases.push(cur = startNode());
|
|
1140
|
+
cur.consequent = [];
|
|
1141
|
+
next();
|
|
1142
|
+
if (isCase) {
|
|
1143
|
+
cur.test = parseExpression();
|
|
1144
|
+
} else {
|
|
1145
|
+
if (sawDefault) {
|
|
1146
|
+
raise(lastStart, "Multiple default clauses");
|
|
1147
|
+
}
|
|
1148
|
+
sawDefault = true;
|
|
1149
|
+
cur.test = null;
|
|
1150
|
+
}
|
|
1151
|
+
expect(_colon);
|
|
1152
|
+
} else {
|
|
1153
|
+
if (!cur) unexpected();
|
|
1154
|
+
cur.consequent.push(parseStatement());
|
|
1155
|
+
}
|
|
1156
|
+
}
|
|
1157
|
+
if (cur) finishNode(cur, "SwitchCase");
|
|
1158
|
+
next();
|
|
1159
|
+
labels.pop();
|
|
1160
|
+
return finishNode(node, "SwitchStatement");
|
|
1161
|
+
case _throw:
|
|
1162
|
+
next();
|
|
1163
|
+
if (newline.test(input.slice(lastEnd, tokStart))) raise(lastEnd, "Illegal newline after throw");
|
|
1164
|
+
node.argument = parseExpression();
|
|
1165
|
+
semicolon();
|
|
1166
|
+
return finishNode(node, "ThrowStatement");
|
|
1167
|
+
case _try:
|
|
1168
|
+
next();
|
|
1169
|
+
node.block = parseBlock();
|
|
1170
|
+
node.handler = null;
|
|
1171
|
+
if (tokType === _catch) {
|
|
1172
|
+
var clause = startNode();
|
|
1173
|
+
next();
|
|
1174
|
+
expect(_parenL);
|
|
1175
|
+
clause.param = parseIdent();
|
|
1176
|
+
if (strict && isStrictBadIdWord(clause.param.name)) raise(clause.param.start, "Binding " + clause.param.name + " in strict mode");
|
|
1177
|
+
expect(_parenR);
|
|
1178
|
+
clause.body = parseBlock();
|
|
1179
|
+
node.handler = finishNode(clause, "CatchClause");
|
|
1180
|
+
}
|
|
1181
|
+
node.finalizer = eat(_finally) ? parseBlock() : null;
|
|
1182
|
+
if (!node.handler && !node.finalizer) raise(node.start, "Missing catch or finally clause");
|
|
1183
|
+
return finishNode(node, "TryStatement");
|
|
1184
|
+
case _var:
|
|
1185
|
+
next();
|
|
1186
|
+
parseVar(node);
|
|
1187
|
+
semicolon();
|
|
1188
|
+
return finishNode(node, "VariableDeclaration");
|
|
1189
|
+
case _while:
|
|
1190
|
+
next();
|
|
1191
|
+
node.test = parseParenExpression();
|
|
1192
|
+
labels.push(loopLabel);
|
|
1193
|
+
node.body = parseStatement();
|
|
1194
|
+
labels.pop();
|
|
1195
|
+
return finishNode(node, "WhileStatement");
|
|
1196
|
+
case _with:
|
|
1197
|
+
if (strict) raise(tokStart, "'with' in strict mode");
|
|
1198
|
+
next();
|
|
1199
|
+
node.object = parseParenExpression();
|
|
1200
|
+
node.body = parseStatement();
|
|
1201
|
+
return finishNode(node, "WithStatement");
|
|
1202
|
+
case _braceL:
|
|
1203
|
+
return parseBlock();
|
|
1204
|
+
case _semi:
|
|
1205
|
+
next();
|
|
1206
|
+
return finishNode(node, "EmptyStatement");
|
|
1207
|
+
default:
|
|
1208
|
+
var maybeName = tokVal;
|
|
1209
|
+
var expr = parseExpression();
|
|
1210
|
+
if (starttype === _name && expr.type === "Identifier" && eat(_colon)) {
|
|
1211
|
+
for (var i = 0; i < labels.length; ++i) {
|
|
1212
|
+
if (labels[i].name === maybeName) {
|
|
1213
|
+
raise(expr.start, "Label '" + maybeName + "' is already declared");
|
|
1214
|
+
}
|
|
1215
|
+
}
|
|
1216
|
+
var kind = tokType.isLoop ? "loop" : tokType === _switch ? "switch" : null;
|
|
1217
|
+
labels.push({
|
|
1218
|
+
name: maybeName,
|
|
1219
|
+
kind
|
|
1220
|
+
});
|
|
1221
|
+
node.body = parseStatement();
|
|
1222
|
+
labels.pop();
|
|
1223
|
+
node.label = expr;
|
|
1224
|
+
return finishNode(node, "LabeledStatement");
|
|
1225
|
+
} else {
|
|
1226
|
+
node.expression = expr;
|
|
1227
|
+
semicolon();
|
|
1228
|
+
return finishNode(node, "ExpressionStatement");
|
|
1229
|
+
}
|
|
1230
|
+
}
|
|
1231
|
+
}
|
|
1232
|
+
function parseParenExpression() {
|
|
1233
|
+
expect(_parenL);
|
|
1234
|
+
var val = parseExpression();
|
|
1235
|
+
expect(_parenR);
|
|
1236
|
+
return val;
|
|
1237
|
+
}
|
|
1238
|
+
function parseBlock(allowStrict) {
|
|
1239
|
+
var node = startNode();
|
|
1240
|
+
var first = true;
|
|
1241
|
+
var strict2 = false;
|
|
1242
|
+
var oldStrict;
|
|
1243
|
+
node.body = [];
|
|
1244
|
+
expect(_braceL);
|
|
1245
|
+
while (!eat(_braceR)) {
|
|
1246
|
+
var stmt = parseStatement();
|
|
1247
|
+
node.body.push(stmt);
|
|
1248
|
+
if (first && allowStrict && isUseStrict(stmt)) {
|
|
1249
|
+
oldStrict = strict2;
|
|
1250
|
+
setStrict(strict2 = true);
|
|
1251
|
+
}
|
|
1252
|
+
first = false;
|
|
1253
|
+
}
|
|
1254
|
+
if (strict2 && !oldStrict) setStrict(false);
|
|
1255
|
+
return finishNode(node, "BlockStatement");
|
|
1256
|
+
}
|
|
1257
|
+
function parseFor(node, init) {
|
|
1258
|
+
node.init = init;
|
|
1259
|
+
expect(_semi);
|
|
1260
|
+
node.test = tokType === _semi ? null : parseExpression();
|
|
1261
|
+
expect(_semi);
|
|
1262
|
+
node.update = tokType === _parenR ? null : parseExpression();
|
|
1263
|
+
expect(_parenR);
|
|
1264
|
+
node.body = parseStatement();
|
|
1265
|
+
labels.pop();
|
|
1266
|
+
return finishNode(node, "ForStatement");
|
|
1267
|
+
}
|
|
1268
|
+
function parseForIn(node, init) {
|
|
1269
|
+
node.left = init;
|
|
1270
|
+
node.right = parseExpression();
|
|
1271
|
+
expect(_parenR);
|
|
1272
|
+
node.body = parseStatement();
|
|
1273
|
+
labels.pop();
|
|
1274
|
+
return finishNode(node, "ForInStatement");
|
|
1275
|
+
}
|
|
1276
|
+
function parseVar(node, noIn) {
|
|
1277
|
+
node.declarations = [];
|
|
1278
|
+
node.kind = "var";
|
|
1279
|
+
for (;;) {
|
|
1280
|
+
var decl = startNode();
|
|
1281
|
+
decl.id = parseIdent();
|
|
1282
|
+
if (strict && isStrictBadIdWord(decl.id.name)) raise(decl.id.start, "Binding " + decl.id.name + " in strict mode");
|
|
1283
|
+
decl.init = eat(_eq) ? parseExpression(true, noIn) : null;
|
|
1284
|
+
node.declarations.push(finishNode(decl, "VariableDeclarator"));
|
|
1285
|
+
if (!eat(_comma)) break;
|
|
1286
|
+
}
|
|
1287
|
+
}
|
|
1288
|
+
function parseExpression(noComma, noIn) {
|
|
1289
|
+
var expr = parseMaybeAssign(noIn);
|
|
1290
|
+
if (!noComma && tokType === _comma) {
|
|
1291
|
+
var node = startNodeFrom(expr);
|
|
1292
|
+
node.expressions = [expr];
|
|
1293
|
+
while (eat(_comma)) node.expressions.push(parseMaybeAssign(noIn));
|
|
1294
|
+
return finishNode(node, "SequenceExpression");
|
|
1295
|
+
}
|
|
1296
|
+
return expr;
|
|
1297
|
+
}
|
|
1298
|
+
function parseMaybeAssign(noIn) {
|
|
1299
|
+
var left = parseMaybeConditional(noIn);
|
|
1300
|
+
if (tokType.isAssign) {
|
|
1301
|
+
var node = startNodeFrom(left);
|
|
1302
|
+
node.operator = tokVal;
|
|
1303
|
+
node.left = left;
|
|
1304
|
+
next();
|
|
1305
|
+
node.right = parseMaybeAssign(noIn);
|
|
1306
|
+
checkLVal(left);
|
|
1307
|
+
return finishNode(node, "AssignmentExpression");
|
|
1308
|
+
}
|
|
1309
|
+
return left;
|
|
1310
|
+
}
|
|
1311
|
+
function parseMaybeConditional(noIn) {
|
|
1312
|
+
var expr = parseExprOps(noIn);
|
|
1313
|
+
if (eat(_question)) {
|
|
1314
|
+
var node = startNodeFrom(expr);
|
|
1315
|
+
node.test = expr;
|
|
1316
|
+
node.consequent = parseExpression(true);
|
|
1317
|
+
expect(_colon);
|
|
1318
|
+
node.alternate = parseExpression(true, noIn);
|
|
1319
|
+
return finishNode(node, "ConditionalExpression");
|
|
1320
|
+
}
|
|
1321
|
+
return expr;
|
|
1322
|
+
}
|
|
1323
|
+
function parseExprOps(noIn) {
|
|
1324
|
+
return parseExprOp(parseMaybeUnary(), -1, noIn);
|
|
1325
|
+
}
|
|
1326
|
+
function parseExprOp(left, minPrec, noIn) {
|
|
1327
|
+
var prec = tokType.binop;
|
|
1328
|
+
if (prec !== null && (!noIn || tokType !== _in)) {
|
|
1329
|
+
if (prec > minPrec) {
|
|
1330
|
+
var node = startNodeFrom(left);
|
|
1331
|
+
node.left = left;
|
|
1332
|
+
node.operator = tokVal;
|
|
1333
|
+
var op = tokType;
|
|
1334
|
+
next();
|
|
1335
|
+
node.right = parseExprOp(parseMaybeUnary(), prec, noIn);
|
|
1336
|
+
var exprNode = finishNode(node, op === _logicalOR || op === _logicalAND ? "LogicalExpression" : "BinaryExpression");
|
|
1337
|
+
return parseExprOp(exprNode, minPrec, noIn);
|
|
1338
|
+
}
|
|
1339
|
+
}
|
|
1340
|
+
return left;
|
|
1341
|
+
}
|
|
1342
|
+
function parseMaybeUnary() {
|
|
1343
|
+
if (tokType.prefix) {
|
|
1344
|
+
var node = startNode();
|
|
1345
|
+
var update = tokType.isUpdate;
|
|
1346
|
+
node.operator = tokVal;
|
|
1347
|
+
node.prefix = true;
|
|
1348
|
+
tokRegexpAllowed = true;
|
|
1349
|
+
next();
|
|
1350
|
+
node.argument = parseMaybeUnary();
|
|
1351
|
+
if (update) checkLVal(node.argument);else if (strict && node.operator === "delete" && node.argument.type === "Identifier") raise(node.start, "Deleting local variable in strict mode");
|
|
1352
|
+
return finishNode(node, update ? "UpdateExpression" : "UnaryExpression");
|
|
1353
|
+
}
|
|
1354
|
+
var expr = parseExprSubscripts();
|
|
1355
|
+
while (tokType.postfix && !canInsertSemicolon()) {
|
|
1356
|
+
var node = startNodeFrom(expr);
|
|
1357
|
+
node.operator = tokVal;
|
|
1358
|
+
node.prefix = false;
|
|
1359
|
+
node.argument = expr;
|
|
1360
|
+
checkLVal(expr);
|
|
1361
|
+
next();
|
|
1362
|
+
expr = finishNode(node, "UpdateExpression");
|
|
1363
|
+
}
|
|
1364
|
+
return expr;
|
|
1365
|
+
}
|
|
1366
|
+
function parseExprSubscripts() {
|
|
1367
|
+
return parseSubscripts(parseExprAtom());
|
|
1368
|
+
}
|
|
1369
|
+
function parseSubscripts(base, noCalls) {
|
|
1370
|
+
var node;
|
|
1371
|
+
if (eat(_dot)) {
|
|
1372
|
+
node = startNodeFrom(base);
|
|
1373
|
+
node.object = base;
|
|
1374
|
+
node.property = parseIdent(true);
|
|
1375
|
+
node.computed = false;
|
|
1376
|
+
return parseSubscripts(finishNode(node, "MemberExpression"), noCalls);
|
|
1377
|
+
}
|
|
1378
|
+
if (eat(_bracketL)) {
|
|
1379
|
+
node = startNodeFrom(base);
|
|
1380
|
+
node.object = base;
|
|
1381
|
+
node.property = parseExpression();
|
|
1382
|
+
node.computed = true;
|
|
1383
|
+
expect(_bracketR);
|
|
1384
|
+
return parseSubscripts(finishNode(node, "MemberExpression"), noCalls);
|
|
1385
|
+
}
|
|
1386
|
+
if (!noCalls && eat(_parenL)) {
|
|
1387
|
+
node = startNodeFrom(base);
|
|
1388
|
+
node.callee = base;
|
|
1389
|
+
node.arguments = parseExprList(_parenR, false);
|
|
1390
|
+
return parseSubscripts(finishNode(node, "CallExpression"), noCalls);
|
|
1391
|
+
}
|
|
1392
|
+
return base;
|
|
1393
|
+
}
|
|
1394
|
+
function parseExprAtom() {
|
|
1395
|
+
var node;
|
|
1396
|
+
switch (tokType) {
|
|
1397
|
+
case _this:
|
|
1398
|
+
node = startNode();
|
|
1399
|
+
next();
|
|
1400
|
+
return finishNode(node, "ThisExpression");
|
|
1401
|
+
case _name:
|
|
1402
|
+
return parseIdent();
|
|
1403
|
+
case _num:
|
|
1404
|
+
case _string:
|
|
1405
|
+
case _regexp:
|
|
1406
|
+
node = startNode();
|
|
1407
|
+
node.value = tokVal;
|
|
1408
|
+
node.raw = input.slice(tokStart, tokEnd);
|
|
1409
|
+
next();
|
|
1410
|
+
return finishNode(node, "Literal");
|
|
1411
|
+
case _null:
|
|
1412
|
+
case _true:
|
|
1413
|
+
case _false:
|
|
1414
|
+
node = startNode();
|
|
1415
|
+
node.value = tokType.atomValue;
|
|
1416
|
+
node.raw = tokType.keyword;
|
|
1417
|
+
next();
|
|
1418
|
+
return finishNode(node, "Literal");
|
|
1419
|
+
case _parenL:
|
|
1420
|
+
var tokStartLoc1 = tokStartLoc;
|
|
1421
|
+
var tokStart1 = tokStart;
|
|
1422
|
+
next();
|
|
1423
|
+
var val = parseExpression();
|
|
1424
|
+
val.start = tokStart1;
|
|
1425
|
+
val.end = tokEnd;
|
|
1426
|
+
if (options.locations) {
|
|
1427
|
+
val.loc.start = tokStartLoc1;
|
|
1428
|
+
val.loc.end = tokEndLoc;
|
|
1429
|
+
}
|
|
1430
|
+
if (options.ranges) {
|
|
1431
|
+
val.range = [tokStart1, tokEnd];
|
|
1432
|
+
}
|
|
1433
|
+
expect(_parenR);
|
|
1434
|
+
return val;
|
|
1435
|
+
case _bracketL:
|
|
1436
|
+
node = startNode();
|
|
1437
|
+
next();
|
|
1438
|
+
node.elements = parseExprList(_bracketR, true, true);
|
|
1439
|
+
return finishNode(node, "ArrayExpression");
|
|
1440
|
+
case _braceL:
|
|
1441
|
+
return parseObj();
|
|
1442
|
+
case _function:
|
|
1443
|
+
node = startNode();
|
|
1444
|
+
next();
|
|
1445
|
+
return parseFunction(node, false);
|
|
1446
|
+
case _new:
|
|
1447
|
+
return parseNew();
|
|
1448
|
+
}
|
|
1449
|
+
unexpected();
|
|
1450
|
+
}
|
|
1451
|
+
function parseNew() {
|
|
1452
|
+
var node = startNode();
|
|
1453
|
+
next();
|
|
1454
|
+
node.callee = parseSubscripts(parseExprAtom(), true);
|
|
1455
|
+
node.arguments = eat(_parenL) ? parseExprList(_parenR, false) : empty;
|
|
1456
|
+
return finishNode(node, "NewExpression");
|
|
1457
|
+
}
|
|
1458
|
+
function parseObj() {
|
|
1459
|
+
var node = startNode();
|
|
1460
|
+
var first = true;
|
|
1461
|
+
var sawGetSet = false;
|
|
1462
|
+
node.properties = [];
|
|
1463
|
+
next();
|
|
1464
|
+
while (!eat(_braceR)) {
|
|
1465
|
+
if (!first) {
|
|
1466
|
+
expect(_comma);
|
|
1467
|
+
if (options.allowTrailingCommas && eat(_braceR)) {
|
|
1468
|
+
break;
|
|
1469
|
+
}
|
|
1470
|
+
} else {
|
|
1471
|
+
first = false;
|
|
1472
|
+
}
|
|
1473
|
+
var prop = {
|
|
1474
|
+
key: parsePropertyName()
|
|
1475
|
+
};
|
|
1476
|
+
var isGetSet = false;
|
|
1477
|
+
var kind;
|
|
1478
|
+
if (eat(_colon)) {
|
|
1479
|
+
prop.value = parseExpression(true);
|
|
1480
|
+
kind = prop.kind = "init";
|
|
1481
|
+
} else if (prop.key.type === "Identifier" && (prop.key.name === "get" || prop.key.name === "set")) {
|
|
1482
|
+
isGetSet = sawGetSet = true;
|
|
1483
|
+
kind = prop.kind = prop.key.name;
|
|
1484
|
+
prop.key = parsePropertyName();
|
|
1485
|
+
if (tokType !== _parenL) unexpected();
|
|
1486
|
+
prop.value = parseFunction(startNode(), false);
|
|
1487
|
+
} else {
|
|
1488
|
+
unexpected();
|
|
1489
|
+
}
|
|
1490
|
+
if (prop.key.type === "Identifier" && (strict || sawGetSet)) {
|
|
1491
|
+
for (var i = 0; i < node.properties.length; ++i) {
|
|
1492
|
+
var other = node.properties[i];
|
|
1493
|
+
if (other.key.name === prop.key.name) {
|
|
1494
|
+
var conflict = kind === other.kind || isGetSet && other.kind === "init" || kind === "init" && (other.kind === "get" || other.kind === "set");
|
|
1495
|
+
if (conflict && !strict && kind === "init" && other.kind === "init") {
|
|
1496
|
+
conflict = false;
|
|
1497
|
+
}
|
|
1498
|
+
if (conflict) {
|
|
1499
|
+
raise(prop.key.start, "Redefinition of property");
|
|
1500
|
+
}
|
|
1501
|
+
}
|
|
1502
|
+
}
|
|
1503
|
+
}
|
|
1504
|
+
node.properties.push(prop);
|
|
1505
|
+
}
|
|
1506
|
+
return finishNode(node, "ObjectExpression");
|
|
1507
|
+
}
|
|
1508
|
+
function parsePropertyName() {
|
|
1509
|
+
if (tokType === _num || tokType === _string) {
|
|
1510
|
+
return parseExprAtom();
|
|
1511
|
+
}
|
|
1512
|
+
return parseIdent(true);
|
|
1513
|
+
}
|
|
1514
|
+
function parseFunction(node, isStatement) {
|
|
1515
|
+
if (tokType === _name) {
|
|
1516
|
+
node.id = parseIdent();
|
|
1517
|
+
} else if (isStatement) {
|
|
1518
|
+
unexpected();
|
|
1519
|
+
} else {
|
|
1520
|
+
node.id = null;
|
|
1521
|
+
}
|
|
1522
|
+
node.params = [];
|
|
1523
|
+
var first = true;
|
|
1524
|
+
expect(_parenL);
|
|
1525
|
+
while (!eat(_parenR)) {
|
|
1526
|
+
if (!first) {
|
|
1527
|
+
expect(_comma);
|
|
1528
|
+
} else {
|
|
1529
|
+
first = false;
|
|
1530
|
+
}
|
|
1531
|
+
node.params.push(parseIdent());
|
|
1532
|
+
}
|
|
1533
|
+
var oldInFunc = inFunction;
|
|
1534
|
+
var oldLabels = labels;
|
|
1535
|
+
inFunction = true;
|
|
1536
|
+
labels = [];
|
|
1537
|
+
node.body = parseBlock(true);
|
|
1538
|
+
inFunction = oldInFunc;
|
|
1539
|
+
labels = oldLabels;
|
|
1540
|
+
if (strict || node.body.body.length && isUseStrict(node.body.body[0])) {
|
|
1541
|
+
for (var i = node.id ? -1 : 0; i < node.params.length; ++i) {
|
|
1542
|
+
var id = i < 0 ? node.id : node.params[i];
|
|
1543
|
+
if (isStrictReservedWord(id.name) || isStrictBadIdWord(id.name)) {
|
|
1544
|
+
raise(id.start, "Defining '" + id.name + "' in strict mode");
|
|
1545
|
+
}
|
|
1546
|
+
if (i >= 0) {
|
|
1547
|
+
for (var j = 0; j < i; ++j) {
|
|
1548
|
+
if (id.name === node.params[j].name) {
|
|
1549
|
+
raise(id.start, "Argument name clash in strict mode");
|
|
1550
|
+
}
|
|
1551
|
+
}
|
|
1552
|
+
}
|
|
1553
|
+
}
|
|
1554
|
+
}
|
|
1555
|
+
return finishNode(node, isStatement ? "FunctionDeclaration" : "FunctionExpression");
|
|
1556
|
+
}
|
|
1557
|
+
function parseExprList(close, allowTrailingComma, allowEmpty) {
|
|
1558
|
+
var elts = [];
|
|
1559
|
+
var first = true;
|
|
1560
|
+
while (!eat(close)) {
|
|
1561
|
+
if (!first) {
|
|
1562
|
+
expect(_comma);
|
|
1563
|
+
if (allowTrailingComma && options.allowTrailingCommas && eat(close)) {
|
|
1564
|
+
break;
|
|
1565
|
+
}
|
|
1566
|
+
} else {
|
|
1567
|
+
first = false;
|
|
1568
|
+
}
|
|
1569
|
+
elts.push(allowEmpty && tokType === _comma ? null : parseExpression(true));
|
|
1570
|
+
}
|
|
1571
|
+
return elts;
|
|
1572
|
+
}
|
|
1573
|
+
function parseIdent(liberal) {
|
|
1574
|
+
var node = startNode();
|
|
1575
|
+
if (liberal && options.forbidReserved === "everywhere") {
|
|
1576
|
+
liberal = false;
|
|
1577
|
+
}
|
|
1578
|
+
if (tokType === _name) {
|
|
1579
|
+
if (!liberal && (options.forbidReserved && isReservedWord5(tokVal) || strict && isStrictReservedWord(tokVal)) && input.slice(tokStart, tokEnd).indexOf("\\") === -1) {
|
|
1580
|
+
raise(tokStart, "The keyword '" + tokVal + "' is reserved");
|
|
1581
|
+
}
|
|
1582
|
+
node.name = tokVal;
|
|
1583
|
+
} else if (liberal && tokType.keyword) {
|
|
1584
|
+
node.name = tokType.keyword;
|
|
1585
|
+
} else {
|
|
1586
|
+
unexpected();
|
|
1587
|
+
}
|
|
1588
|
+
tokRegexpAllowed = false;
|
|
1589
|
+
next();
|
|
1590
|
+
return finishNode(node, "Identifier");
|
|
1591
|
+
}
|
|
1592
|
+
});
|
|
1593
|
+
}
|
|
1594
|
+
});
|
|
1595
|
+
export default require_stdin()
|