Coverage Report

Created: 2026-08-14 06:19

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/moddable/xs/sources/xsSyntaxical.c
Line
Count
Source
1
/*
2
 * Copyright (c) 2016-2025  Moddable Tech, Inc.
3
 *
4
 *   This file is part of the Moddable SDK Runtime.
5
 * 
6
 *   The Moddable SDK Runtime is free software: you can redistribute it and/or modify
7
 *   it under the terms of the GNU Lesser General Public License as published by
8
 *   the Free Software Foundation, either version 3 of the License, or
9
 *   (at your option) any later version.
10
 * 
11
 *   The Moddable SDK Runtime is distributed in the hope that it will be useful,
12
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 *   GNU Lesser General Public License for more details.
15
 * 
16
 *   You should have received a copy of the GNU Lesser General Public License
17
 *   along with the Moddable SDK Runtime.  If not, see <http://www.gnu.org/licenses/>.
18
 *
19
 * This file incorporates work covered by the following copyright and  
20
 * permission notice:  
21
 *
22
 *       Copyright (C) 2010-2016 Marvell International Ltd.
23
 *       Copyright (C) 2002-2010 Kinoma, Inc.
24
 *
25
 *       Licensed under the Apache License, Version 2.0 (the "License");
26
 *       you may not use this file except in compliance with the License.
27
 *       You may obtain a copy of the License at
28
 *
29
 *        http://www.apache.org/licenses/LICENSE-2.0
30
 *
31
 *       Unless required by applicable law or agreed to in writing, software
32
 *       distributed under the License is distributed on an "AS IS" BASIS,
33
 *       WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
34
 *       See the License for the specific language governing permissions and
35
 *       limitations under the License.
36
 */
37
38
#include "xsScript.h"
39
40
static txBoolean fxIsKeyword(txParser* parser, txSymbol* keyword);
41
static txBoolean fxIsToken(txParser* parser, txToken theToken);
42
static void fxMatchToken(txParser* parser, txToken theToken);
43
static txNode* fxPopNode(txParser* parser);
44
static void fxPushNode(txParser* parser, txNode* node);
45
static void fxPushBigIntNode(txParser* parser, txBigInt* value, txInteger line);
46
static void fxPushIndexNode(txParser* parser, txIndex value, txInteger line);
47
static void fxPushIntegerNode(txParser* parser, txInteger value, txInteger line);
48
static void fxPushNodeStruct(txParser* parser, txInteger count, txToken token, txInteger line);
49
static void fxPushNodeList(txParser* parser, txInteger count);
50
static void fxPushNULL(txParser* parser);
51
static void fxPushNumberNode(txParser* parser, txNumber value, txInteger line);
52
static void fxPushRawNode(txParser* parser, txInteger length, txString value, txInteger line);
53
static void fxPushStringNode(txParser* parser, txInteger length, txString value, txInteger line);
54
static void fxPushSymbol(txParser* parser, txSymbol* symbol);
55
static void fxSwapNodes(txParser* parser);
56
57
static void fxExportDeclaration(txParser* parser);
58
static void fxExportBinding(txParser* parser, txNode* node);
59
static void fxImportDeclaration(txParser* parser);
60
static void fxWithAttributes(txParser* parser);
61
static void fxSpecifiers(txParser* parser);
62
63
static void fxBody(txParser* parser);
64
static void fxStatements(txParser* parser);
65
static void fxBlock(txParser* parser);
66
static void fxStatement(txParser* parser, txInteger blockIt);
67
static void fxSemicolon(txParser* parser);
68
69
static void fxBreakStatement(txParser* parser);
70
static void fxContinueStatement(txParser* parser);
71
static void fxDebuggerStatement(txParser* parser);
72
static void fxDoStatement(txParser* parser);
73
static void fxForStatement(txParser* parser);
74
static void fxIfStatement(txParser* parser);
75
static void fxReturnStatement(txParser* parser);
76
static void fxSwitchStatement(txParser* parser);
77
static void fxThrowStatement(txParser* parser);
78
static void fxTryStatement(txParser* parser);
79
static void fxVariableStatement(txParser* parser, txToken theToken, txUnsigned flags);
80
static void fxWhileStatement(txParser* parser);
81
static void fxWithStatement(txParser* parser);
82
83
static void fxCommaExpression(txParser* parser);
84
static void fxAssignmentExpression(txParser* parser);
85
static void fxConditionalExpression(txParser* parser);
86
static void fxOrExpression(txParser* parser);
87
static void fxAndExpression(txParser* parser);
88
static void fxCoalesceExpression(txParser* parser);
89
static void fxBitOrExpression(txParser* parser);
90
static void fxBitXorExpression(txParser* parser);
91
static void fxBitAndExpression(txParser* parser);
92
static void fxEqualExpression(txParser* parser);
93
static void fxRelationalExpression(txParser* parser);
94
static void fxShiftExpression(txParser* parser);
95
static void fxAdditiveExpression(txParser* parser);
96
static void fxMultiplicativeExpression(txParser* parser);
97
static void fxExponentiationExpression(txParser* parser);
98
static void fxUnaryExpression(txParser* parser);
99
static void fxPrefixExpression(txParser* parser);
100
static void fxPostfixExpression(txParser* parser);
101
static void fxCallExpression(txParser* parser);
102
103
static void fxLiteralExpression(txParser* parser, txUnsigned flag);
104
static void fxArrayExpression(txParser* parser);
105
static void fxArrowExpression(txParser* parser, txUnsigned flag);
106
static void fxClassExpression(txParser* parser, txInteger theLine, txSymbol** theSymbol);
107
static void fxFunctionExpression(txParser* parser, txInteger theLine, txSymbol** theSymbol, txUnsigned flag);
108
static void fxGeneratorExpression(txParser* parser, txInteger theLine, txSymbol** theSymbol, txUnsigned flag);
109
static void fxGroupExpression(txParser* parser, txUnsigned flag);
110
static void fxObjectExpression(txParser* parser);
111
static void fxNewExpression(txParser* parser);
112
static void fxTemplateExpression(txParser* parser);
113
static void fxYieldExpression(txParser* parser);
114
115
static void fxParameters(txParser* parser);
116
static void fxPropertyName(txParser* parser, txSymbol** theSymbol, txToken* theToken0, txToken* theToken1, txToken* theToken2, txUnsigned* flag);
117
118
static void fxBinding(txParser* parser, txToken theToken, txUnsigned flags);
119
static txNode* fxBindingFromExpression(txParser* parser, txNode* theNode, txToken theToken);
120
static void fxArrayBinding(txParser* parser, txToken theToken);
121
static txNode* fxArrayBindingFromExpression(txParser* parser, txNode* theNode, txToken theToken);
122
static txUnsigned fxObjectBinding(txParser* parser, txToken theToken);
123
static txNode* fxObjectBindingFromExpression(txParser* parser, txNode* theNode, txToken theToken);
124
static void fxParametersBinding(txParser* parser);
125
static txNode* fxParametersBindingFromExpressions(txParser* parser, txNode* theNode);
126
static void fxRestBinding(txParser* parser, txToken theToken, txUnsigned flag);
127
static txNode* fxRestBindingFromExpression(txParser* parser, txNode* theNode, txToken theToken, txUnsigned flag);
128
129
static void fxCheckArrowFunction(txParser* parser, txInteger count);
130
static void fxCheckNativeConstructor(txParser* parser);
131
static void fxCheckNativeFunction(txParser* parser);
132
static txBoolean fxCheckReference(txParser* parser, txToken theToken);
133
static void fxCheckStrictBinding(txParser* parser, txNode* node);
134
static void fxCheckStrictFunction(txParser* parser, txFunctionNode* function);
135
static void fxCheckStrictSymbol(txParser* parser, txSymbol* symbol);
136
static void fxCheckUniqueProperty(txParser* parser, txNode* base, txNode* current);
137
static void fxCheckUniquePropertyAux(txParser* parser, txNode* baseNode, txNode* currentNode);
138
139
static void fxJSONObject(txParser* parser);
140
static void fxJSONArray(txParser* parser);
141
142
static void fxJSXAttributeName(txParser* parser);
143
static void fxJSXAttributeValue(txParser* parser);
144
static void fxJSXElement(txParser* parser);
145
static void fxJSXElementName(txParser* parser);
146
static txBoolean fxJSXMatch(txParser* parser, txNode* opening, txNode* closing);
147
static txSymbol* fxJSXNamespace(txParser* parser, txSymbol* namespace, txSymbol* name);
148
149
11.7k
#define XS_TOKEN_BEGIN_STATEMENT 1
150
4.28M
#define XS_TOKEN_BEGIN_EXPRESSION 2
151
3.02M
#define XS_TOKEN_ASSIGN_EXPRESSION 4
152
2.93M
#define XS_TOKEN_EQUAL_EXPRESSION 8
153
2.99M
#define XS_TOKEN_RELATIONAL_EXPRESSION 16
154
3.02M
#define XS_TOKEN_SHIFT_EXPRESSION 32
155
15.8M
#define XS_TOKEN_ADDITIVE_EXPRESSION 64
156
15.9M
#define XS_TOKEN_MULTIPLICATIVE_EXPRESSION 128
157
15.8M
#define XS_TOKEN_EXPONENTIATION_EXPRESSION 256
158
16.1M
#define XS_TOKEN_PREFIX_EXPRESSION 512
159
14.8M
#define XS_TOKEN_POSTFIX_EXPRESSION 1024
160
566k
#define XS_TOKEN_END_STATEMENT 2048
161
#define XS_TOKEN_REFERENCE_EXPRESSION 4096
162
493k
#define XS_TOKEN_BEGIN_BINDING 16384
163
234k
#define XS_TOKEN_IDENTIFIER_NAME 32768
164
16.3M
#define XS_TOKEN_UNARY_EXPRESSION 65536
165
15.9M
#define XS_TOKEN_CALL_EXPRESSION 131072
166
167
static txTokenFlag gxTokenFlags[XS_TOKEN_COUNT] = {
168
  /* XS_NO_TOKEN */ 0,
169
  /* XS_TOKEN_ACCESS */ 0,
170
  /* XS_TOKEN_ADD */ XS_TOKEN_BEGIN_STATEMENT | XS_TOKEN_BEGIN_EXPRESSION | XS_TOKEN_ADDITIVE_EXPRESSION | XS_TOKEN_UNARY_EXPRESSION,
171
  /* XS_TOKEN_ADD_ASSIGN */ XS_TOKEN_ASSIGN_EXPRESSION,
172
  /* XS_TOKEN_AND */ 0,
173
  /* XS_TOKEN_AND_ASSIGN */ XS_TOKEN_ASSIGN_EXPRESSION,
174
  /* XS_TOKEN_ARG */ 0,
175
  /* XS_TOKEN_ARGUMENTS */ 0,
176
  /* XS_TOKEN_ARGUMENTS_SLOPPY */ 0,
177
  /* XS_TOKEN_ARGUMENTS_STRICT */ 0,
178
  /* XS_TOKEN_ARRAY */ 0,
179
  /* XS_TOKEN_ARRAY_BINDING */ 0,
180
  /* XS_TOKEN_ARROW */ 0,
181
  /* XS_TOKEN_ASSIGN */ XS_TOKEN_ASSIGN_EXPRESSION,
182
  /* XS_TOKEN_AWAIT */ XS_TOKEN_BEGIN_STATEMENT | XS_TOKEN_BEGIN_EXPRESSION | XS_TOKEN_UNARY_EXPRESSION | XS_TOKEN_IDENTIFIER_NAME,
183
  /* XS_TOKEN_BIGINT */ XS_TOKEN_BEGIN_STATEMENT | XS_TOKEN_BEGIN_EXPRESSION,
184
  /* XS_TOKEN_BINDING */ 0,
185
  /* XS_TOKEN_BIT_AND */ 0,
186
  /* XS_TOKEN_BIT_AND_ASSIGN */ XS_TOKEN_ASSIGN_EXPRESSION,
187
  /* XS_TOKEN_BIT_NOT */ XS_TOKEN_BEGIN_STATEMENT | XS_TOKEN_BEGIN_EXPRESSION | XS_TOKEN_UNARY_EXPRESSION,
188
  /* XS_TOKEN_BIT_OR */ 0,
189
  /* XS_TOKEN_BIT_OR_ASSIGN */ XS_TOKEN_ASSIGN_EXPRESSION,
190
  /* XS_TOKEN_BIT_XOR */ 0,
191
  /* XS_TOKEN_BIT_XOR_ASSIGN */ XS_TOKEN_ASSIGN_EXPRESSION,
192
  /* XS_TOKEN_BLOCK */ 0,
193
  /* XS_TOKEN_BODY */ 0,
194
  /* XS_TOKEN_BREAK */ XS_TOKEN_BEGIN_STATEMENT | XS_TOKEN_IDENTIFIER_NAME,
195
  /* XS_TOKEN_CALL */ 0,
196
  /* XS_TOKEN_CASE */ XS_TOKEN_IDENTIFIER_NAME,
197
  /* XS_TOKEN_CATCH */ XS_TOKEN_IDENTIFIER_NAME,
198
  /* XS_TOKEN_CHAIN */ XS_TOKEN_CALL_EXPRESSION,
199
  /* XS_TOKEN_CLASS */ XS_TOKEN_BEGIN_STATEMENT | XS_TOKEN_BEGIN_EXPRESSION | XS_TOKEN_IDENTIFIER_NAME,
200
  /* XS_TOKEN_COALESCE */ 0,
201
  /* XS_TOKEN_COALESCE_ASSIGN */ XS_TOKEN_ASSIGN_EXPRESSION,
202
  /* XS_TOKEN_COLON */ 0,
203
  /* XS_TOKEN_COMMA */ XS_TOKEN_END_STATEMENT,
204
  /* XS_TOKEN_CONST */ XS_TOKEN_BEGIN_STATEMENT | XS_TOKEN_IDENTIFIER_NAME,
205
  /* XS_TOKEN_CONTINUE */ XS_TOKEN_BEGIN_STATEMENT | XS_TOKEN_IDENTIFIER_NAME,
206
  /* XS_TOKEN_CURRENT */ 0,
207
  /* XS_TOKEN_DEBUGGER */ XS_TOKEN_BEGIN_STATEMENT | XS_TOKEN_IDENTIFIER_NAME,
208
  /* XS_TOKEN_DECREMENT */ XS_TOKEN_BEGIN_STATEMENT | XS_TOKEN_BEGIN_EXPRESSION | XS_TOKEN_PREFIX_EXPRESSION | XS_TOKEN_POSTFIX_EXPRESSION,
209
  /* XS_TOKEN_DEFAULT */ XS_TOKEN_IDENTIFIER_NAME,
210
  /* XS_TOKEN_DEFINE */ 0,
211
  /* XS_TOKEN_DELEGATE */ 0,
212
  /* XS_TOKEN_DELETE */ XS_TOKEN_BEGIN_STATEMENT | XS_TOKEN_BEGIN_EXPRESSION | XS_TOKEN_UNARY_EXPRESSION | XS_TOKEN_IDENTIFIER_NAME,
213
  /* XS_TOKEN_DIVIDE */ XS_TOKEN_BEGIN_EXPRESSION | XS_TOKEN_MULTIPLICATIVE_EXPRESSION,
214
  /* XS_TOKEN_DIVIDE_ASSIGN */ XS_TOKEN_BEGIN_EXPRESSION | XS_TOKEN_ASSIGN_EXPRESSION,
215
  /* XS_TOKEN_DO */ XS_TOKEN_BEGIN_STATEMENT | XS_TOKEN_IDENTIFIER_NAME,
216
  /* XS_TOKEN_DOT */ XS_TOKEN_CALL_EXPRESSION,
217
  /* XS_TOKEN_ELISION */ 0,
218
  /* XS_TOKEN_ELSE */ XS_TOKEN_IDENTIFIER_NAME,
219
  /* XS_TOKEN_ENUM */ XS_TOKEN_IDENTIFIER_NAME,
220
  /* XS_TOKEN_EOF */ XS_TOKEN_END_STATEMENT,
221
  /* XS_TOKEN_EQUAL */ XS_TOKEN_EQUAL_EXPRESSION,
222
  /* XS_TOKEN_EVAL */ 0,
223
  /* XS_TOKEN_EXPONENTIATION */ XS_TOKEN_EXPONENTIATION_EXPRESSION,
224
  /* XS_TOKEN_EXPONENTIATION_ASSIGN */ XS_TOKEN_ASSIGN_EXPRESSION,
225
  /* XS_TOKEN_EXPORT */ XS_TOKEN_IDENTIFIER_NAME,
226
  /* XS_TOKEN_EXPRESSIONS */ 0,
227
  /* XS_TOKEN_EXTENDS */ XS_TOKEN_IDENTIFIER_NAME,
228
  /* XS_TOKEN_FALSE */ XS_TOKEN_BEGIN_STATEMENT | XS_TOKEN_BEGIN_EXPRESSION | XS_TOKEN_IDENTIFIER_NAME,
229
  /* XS_TOKEN_FIELD */ 0,
230
  /* XS_TOKEN_FINALLY */ XS_TOKEN_IDENTIFIER_NAME | XS_TOKEN_IDENTIFIER_NAME,
231
  /* XS_TOKEN_FOR */ XS_TOKEN_BEGIN_STATEMENT | XS_TOKEN_IDENTIFIER_NAME,
232
  /* XS_TOKEN_FOR_AWAIT_OF */ 0,
233
  /* XS_TOKEN_FOR_IN */ 0,
234
  /* XS_TOKEN_FOR_OF */ 0,
235
  /* XS_TOKEN_FUNCTION */ XS_TOKEN_BEGIN_STATEMENT | XS_TOKEN_BEGIN_EXPRESSION | XS_TOKEN_IDENTIFIER_NAME,
236
  /* XS_TOKEN_GENERATOR */ 0,
237
  /* XS_TOKEN_GETTER */ 0,
238
  /* XS_TOKEN_HOST */ XS_TOKEN_BEGIN_EXPRESSION,
239
  /* XS_TOKEN_IDENTIFIER */ XS_TOKEN_BEGIN_STATEMENT | XS_TOKEN_BEGIN_EXPRESSION | XS_TOKEN_BEGIN_BINDING | XS_TOKEN_IDENTIFIER_NAME,
240
  /* XS_TOKEN_IF */ XS_TOKEN_BEGIN_STATEMENT | XS_TOKEN_IDENTIFIER_NAME,
241
  /* XS_TOKEN_IMPLEMENTS */ XS_TOKEN_IDENTIFIER_NAME,
242
  /* XS_TOKEN_IMPORT */ XS_TOKEN_BEGIN_EXPRESSION | XS_TOKEN_IDENTIFIER_NAME,
243
  /* XS_TOKEN_IMPORT_CALL */ 0,
244
  /* XS_TOKEN_IMPORT_META */ 0,
245
  /* XS_TOKEN_IN */ XS_TOKEN_RELATIONAL_EXPRESSION | XS_TOKEN_IDENTIFIER_NAME,
246
  /* XS_TOKEN_INCLUDE */ 0,
247
  /* XS_TOKEN_INCREMENT */ XS_TOKEN_BEGIN_STATEMENT | XS_TOKEN_BEGIN_EXPRESSION | XS_TOKEN_PREFIX_EXPRESSION | XS_TOKEN_POSTFIX_EXPRESSION,
248
  /* XS_TOKEN_INSTANCEOF */ XS_TOKEN_RELATIONAL_EXPRESSION | XS_TOKEN_IDENTIFIER_NAME,
249
  /* XS_TOKEN_INTEGER */ XS_TOKEN_BEGIN_STATEMENT | XS_TOKEN_BEGIN_EXPRESSION,
250
  /* XS_TOKEN_INTERFACE */ XS_TOKEN_IDENTIFIER_NAME,
251
  /* XS_TOKEN_ITEMS */ 0,
252
  /* XS_TOKEN_LABEL */ 0,
253
  /* XS_TOKEN_LEFT_BRACE */ XS_TOKEN_BEGIN_STATEMENT | XS_TOKEN_BEGIN_EXPRESSION | XS_TOKEN_BEGIN_BINDING,
254
  /* XS_TOKEN_LEFT_BRACKET */ XS_TOKEN_BEGIN_STATEMENT | XS_TOKEN_BEGIN_EXPRESSION | XS_TOKEN_BEGIN_BINDING | XS_TOKEN_CALL_EXPRESSION,
255
  /* XS_TOKEN_LEFT_PARENTHESIS */ XS_TOKEN_BEGIN_STATEMENT | XS_TOKEN_BEGIN_EXPRESSION | XS_TOKEN_CALL_EXPRESSION,
256
  /* XS_TOKEN_LEFT_SHIFT */ XS_TOKEN_SHIFT_EXPRESSION,
257
  /* XS_TOKEN_LEFT_SHIFT_ASSIGN */ XS_TOKEN_ASSIGN_EXPRESSION,
258
  /* XS_TOKEN_LESS */ XS_TOKEN_BEGIN_EXPRESSION | XS_TOKEN_RELATIONAL_EXPRESSION,
259
  /* XS_TOKEN_LESS_EQUAL */ XS_TOKEN_RELATIONAL_EXPRESSION,
260
  /* XS_TOKEN_LET */ XS_TOKEN_BEGIN_STATEMENT | XS_TOKEN_IDENTIFIER_NAME,
261
  /* XS_TOKEN_MEMBER */ 0,
262
  /* XS_TOKEN_MEMBER_AT */ 0,
263
  /* XS_TOKEN_MINUS */ 0,
264
  /* XS_TOKEN_MODULE */ 0,
265
  /* XS_TOKEN_MODULO */ XS_TOKEN_MULTIPLICATIVE_EXPRESSION,
266
  /* XS_TOKEN_MODULO_ASSIGN */ XS_TOKEN_ASSIGN_EXPRESSION,
267
  /* XS_TOKEN_MORE */ XS_TOKEN_RELATIONAL_EXPRESSION,
268
  /* XS_TOKEN_MORE_EQUAL */ XS_TOKEN_RELATIONAL_EXPRESSION,
269
  /* XS_TOKEN_MULTIPLY */ XS_TOKEN_MULTIPLICATIVE_EXPRESSION,
270
  /* XS_TOKEN_MULTIPLY_ASSIGN */ XS_TOKEN_ASSIGN_EXPRESSION,
271
  /* XS_TOKEN_NEW */ XS_TOKEN_BEGIN_STATEMENT | XS_TOKEN_BEGIN_EXPRESSION | XS_TOKEN_IDENTIFIER_NAME, 
272
  /* XS_TOKEN_NOT */ XS_TOKEN_BEGIN_STATEMENT | XS_TOKEN_BEGIN_EXPRESSION | XS_TOKEN_UNARY_EXPRESSION,
273
  /* XS_TOKEN_NOT_EQUAL */ XS_TOKEN_EQUAL_EXPRESSION,
274
  /* XS_TOKEN_NULL */ XS_TOKEN_BEGIN_STATEMENT | XS_TOKEN_BEGIN_EXPRESSION | XS_TOKEN_IDENTIFIER_NAME, 
275
  /* XS_TOKEN_NUMBER */ XS_TOKEN_BEGIN_STATEMENT | XS_TOKEN_BEGIN_EXPRESSION,
276
  /* XS_TOKEN_OBJECT */ 0,
277
  /* XS_TOKEN_OBJECT_BINDING */ 0,
278
  /* XS_TOKEN_OPTION */ 0,
279
  /* XS_TOKEN_OR */ 0,
280
  /* XS_TOKEN_OR_ASSIGN */ XS_TOKEN_ASSIGN_EXPRESSION,
281
  /* XS_TOKEN_PACKAGE */ XS_TOKEN_IDENTIFIER_NAME,
282
  /* XS_TOKEN_PARAMS */ 0,
283
  /* XS_TOKEN_PARAMS_BINDING */ 0,
284
  /* XS_TOKEN_PLUS */ 0,
285
  /* XS_TOKEN_PRIVATE */ XS_TOKEN_IDENTIFIER_NAME,
286
  /* XS_TOKEN_PRIVATE_IDENTIFIER */ XS_TOKEN_BEGIN_EXPRESSION,
287
  /* XS_TOKEN_PRIVATE_MEMBER */ 0,
288
  /* XS_TOKEN_PRIVATE_PROPERTY */ 0,
289
  /* XS_TOKEN_PROGRAM */ 0,
290
  /* XS_TOKEN_PROPERTY */ 0,
291
  /* XS_TOKEN_PROPERTY_AT */ 0,
292
  /* XS_TOKEN_PROPERTY_BINDING */ 0,
293
  /* XS_TOKEN_PROPERTY_BINDING_AT */ 0,
294
  /* XS_TOKEN_PROTECTED */ XS_TOKEN_IDENTIFIER_NAME,
295
  /* XS_TOKEN_PUBLIC */ XS_TOKEN_IDENTIFIER_NAME,
296
  /* XS_TOKEN_QUESTION_MARK */ 0,
297
  /* XS_TOKEN_REGEXP */ XS_TOKEN_BEGIN_STATEMENT | XS_TOKEN_BEGIN_EXPRESSION,
298
  /* XS_TOKEN_REST_BINDING */ 0,
299
  /* XS_TOKEN_RETURN */ XS_TOKEN_BEGIN_STATEMENT | XS_TOKEN_IDENTIFIER_NAME,
300
  /* XS_TOKEN_RIGHT_BRACE */ XS_TOKEN_END_STATEMENT,
301
  /* XS_TOKEN_RIGHT_BRACKET */ 0,
302
  /* XS_TOKEN_RIGHT_PARENTHESIS */ 0,
303
  /* XS_TOKEN_SEMICOLON */ XS_TOKEN_BEGIN_STATEMENT | XS_TOKEN_END_STATEMENT,
304
  /* XS_TOKEN_SETTER */ 0,
305
  /* XS_TOKEN_SHORT */ 0,
306
  /* XS_TOKEN_SIGNED_RIGHT_SHIFT */ XS_TOKEN_SHIFT_EXPRESSION,
307
  /* XS_TOKEN_SIGNED_RIGHT_SHIFT_ASSIGN */ XS_TOKEN_ASSIGN_EXPRESSION,
308
  /* XS_TOKEN_SKIP_BINDING */ 0,
309
  /* XS_TOKEN_SPECIFIER */ 0,
310
  /* XS_TOKEN_SPREAD */ XS_TOKEN_BEGIN_BINDING,
311
  /* XS_TOKEN_STATEMENT */ 0,
312
  /* XS_TOKEN_STATEMENTS */ 0,
313
  /* XS_TOKEN_STATIC */ XS_TOKEN_IDENTIFIER_NAME,
314
  /* XS_TOKEN_STRICT_EQUAL */ XS_TOKEN_EQUAL_EXPRESSION,
315
  /* XS_TOKEN_STRICT_NOT_EQUAL */ XS_TOKEN_EQUAL_EXPRESSION,
316
  /* XS_TOKEN_STRING */ XS_TOKEN_BEGIN_STATEMENT | XS_TOKEN_BEGIN_EXPRESSION,
317
  /* XS_TOKEN_SUBTRACT */ XS_TOKEN_BEGIN_STATEMENT | XS_TOKEN_BEGIN_EXPRESSION | XS_TOKEN_ADDITIVE_EXPRESSION | XS_TOKEN_UNARY_EXPRESSION,
318
  /* XS_TOKEN_SUBTRACT_ASSIGN */ XS_TOKEN_ASSIGN_EXPRESSION,
319
  /* XS_TOKEN_SUPER */ XS_TOKEN_BEGIN_STATEMENT | XS_TOKEN_BEGIN_EXPRESSION | XS_TOKEN_IDENTIFIER_NAME,
320
  /* XS_TOKEN_SWITCH */ XS_TOKEN_BEGIN_STATEMENT | XS_TOKEN_IDENTIFIER_NAME,
321
  /* XS_TOKEN_TARGET */ 0,
322
  /* XS_TOKEN_TEMPLATE */ XS_TOKEN_BEGIN_STATEMENT | XS_TOKEN_BEGIN_EXPRESSION | XS_TOKEN_CALL_EXPRESSION,
323
  /* XS_TOKEN_TEMPLATE_HEAD */ XS_TOKEN_BEGIN_STATEMENT | XS_TOKEN_BEGIN_EXPRESSION | XS_TOKEN_CALL_EXPRESSION,
324
  /* XS_TOKEN_TEMPLATE_MIDDLE */ 0,
325
  /* XS_TOKEN_TEMPLATE_TAIL */ 0,
326
  /* XS_TOKEN_THIS */ XS_TOKEN_BEGIN_STATEMENT | XS_TOKEN_BEGIN_EXPRESSION | XS_TOKEN_IDENTIFIER_NAME,
327
  /* XS_TOKEN_THROW */ XS_TOKEN_BEGIN_STATEMENT | XS_TOKEN_IDENTIFIER_NAME,
328
  /* XS_TOKEN_TRUE */ XS_TOKEN_BEGIN_STATEMENT | XS_TOKEN_BEGIN_EXPRESSION | XS_TOKEN_IDENTIFIER_NAME,
329
  /* XS_TOKEN_TRY */ XS_TOKEN_BEGIN_STATEMENT | XS_TOKEN_IDENTIFIER_NAME,
330
  /* XS_TOKEN_TYPEOF */ XS_TOKEN_BEGIN_STATEMENT | XS_TOKEN_BEGIN_EXPRESSION | XS_TOKEN_UNARY_EXPRESSION | XS_TOKEN_IDENTIFIER_NAME,
331
  /* XS_TOKEN_UNDEFINED */ 0,
332
  /* XS_TOKEN_UNSIGNED_RIGHT_SHIFT */ XS_TOKEN_SHIFT_EXPRESSION,
333
  /* XS_TOKEN_UNSIGNED_RIGHT_SHIFT_ASSIGN */ XS_TOKEN_ASSIGN_EXPRESSION,
334
  /* XS_TOKEN_USING */ XS_TOKEN_BEGIN_STATEMENT | XS_TOKEN_IDENTIFIER_NAME,
335
  /* XS_TOKEN_VAR */ XS_TOKEN_BEGIN_STATEMENT | XS_TOKEN_IDENTIFIER_NAME,
336
  /* XS_TOKEN_VOID */ XS_TOKEN_BEGIN_STATEMENT | XS_TOKEN_BEGIN_EXPRESSION | XS_TOKEN_UNARY_EXPRESSION | XS_TOKEN_IDENTIFIER_NAME,
337
  /* XS_TOKEN_WHILE */ XS_TOKEN_BEGIN_STATEMENT | XS_TOKEN_IDENTIFIER_NAME,
338
  /* XS_TOKEN_WITH */ XS_TOKEN_BEGIN_STATEMENT | XS_TOKEN_IDENTIFIER_NAME,
339
  /* XS_TOKEN_YIELD */ XS_TOKEN_BEGIN_STATEMENT | XS_TOKEN_BEGIN_EXPRESSION | XS_TOKEN_IDENTIFIER_NAME
340
};
341
342
static txString const gxTokenNames[XS_TOKEN_COUNT] ICACHE_FLASH_ATTR = {
343
  /* XS_NO_TOKEN */ "",
344
  /* XS_TOKEN_ACCESS */ "access",
345
  /* XS_TOKEN_ADD */ "+",
346
  /* XS_TOKEN_ADD_ASSIGN */ "+=",
347
  /* XS_TOKEN_AND */ "&&",
348
  /* XS_TOKEN_AND_ASSIGN */ "&&=",
349
  /* XS_TOKEN_ARG */ "arg",
350
  /* XS_TOKEN_ARGUMENTS */ "arguments",
351
  /* XS_TOKEN_ARGUMENTS_SLOPPY */ "arguments_sloppy",
352
  /* XS_TOKEN_ARGUMENTS_STRICT */ "arguments_strict",
353
  /* XS_TOKEN_ARRAY */ "array",
354
  /* XS_TOKEN_ARRAY_BINDING */ "array_binding",
355
  /* XS_TOKEN_ARROW */ "=>",
356
  /* XS_TOKEN_ASSIGN */ "=",
357
  /* XS_TOKEN_AWAIT */ "await",
358
  /* XS_TOKEN_BIGINT */ "bigint",
359
  /* XS_TOKEN_BINDING */ "binding",
360
  /* XS_TOKEN_BIT_AND */ "&",
361
  /* XS_TOKEN_BIT_AND_ASSIGN */ "&=",
362
  /* XS_TOKEN_BIT_NOT */ "~",
363
  /* XS_TOKEN_BIT_OR */ "|",
364
  /* XS_TOKEN_BIT_OR_ASSIGN */ "|=",
365
  /* XS_TOKEN_BIT_XOR */ "^",
366
  /* XS_TOKEN_BIT_XOR_ASSIGN */ "^=",
367
  /* XS_TOKEN_BLOCK */ "block",
368
  /* XS_TOKEN_BODY */ "body",
369
  /* XS_TOKEN_BREAK */ "break",
370
  /* XS_TOKEN_CALL */ "call",
371
  /* XS_TOKEN_CASE */ "case",
372
  /* XS_TOKEN_CATCH */ "catch",
373
  /* XS_TOKEN_CHAIN */ "?.",
374
  /* XS_TOKEN_CLASS */ "class",
375
  /* XS_TOKEN_COALESCE */ "??",
376
  /* XS_TOKEN_COALESCE_ASSIGN */ "\?\?=",
377
  /* XS_TOKEN_COLON */ ":",
378
  /* XS_TOKEN_COMMA */ ",",
379
  /* XS_TOKEN_CONST */ "const",
380
  /* XS_TOKEN_CONTINUE */ "continue",
381
  /* XS_TOKEN_CURRENT */ "current",
382
  /* XS_TOKEN_DEBUGGER */ "debugger",
383
  /* XS_TOKEN_DECREMENT */ "--",
384
  /* XS_TOKEN_DEFAULT */ "default",
385
  /* XS_TOKEN_DEFINE */ "define",
386
  /* XS_TOKEN_DELEGATE */ "delegate",
387
  /* XS_TOKEN_DELETE */ "delete",
388
  /* XS_TOKEN_DIVIDE */ "/",
389
  /* XS_TOKEN_DIVIDE_ASSIGN */ "/=",
390
  /* XS_TOKEN_DO */ "do",
391
  /* XS_TOKEN_DOT */ ".",
392
  /* XS_TOKEN_ELISION */ "elision",
393
  /* XS_TOKEN_ELSE */ "else",
394
  /* XS_TOKEN_ENUM */ "enum",
395
  /* XS_TOKEN_EOF */ "",
396
  /* XS_TOKEN_EQUAL */ "==",
397
  /* XS_TOKEN_EVAL */ "eval",
398
  /* XS_TOKEN_EXPONENTIATION */ "**",
399
  /* XS_TOKEN_EXPONENTIATION_ASSIGN */ "**=",
400
  /* XS_TOKEN_EXPORT */ "export",
401
  /* XS_TOKEN_EXPRESSIONS */ "expressions",
402
  /* XS_TOKEN_EXTENDS */ "extends",
403
  /* XS_TOKEN_FALSE */ "false",
404
  /* XS_TOKEN_FIELD */ "field",
405
  /* XS_TOKEN_FINALLY */ "finally",
406
  /* XS_TOKEN_FOR */ "for",
407
  /* XS_TOKEN_FOR_AWAIT_OF */ "for_await_of",
408
  /* XS_TOKEN_FOR_IN */ "for_in",
409
  /* XS_TOKEN_FOR_OF */ "for_of",
410
  /* XS_TOKEN_FUNCTION */ "function",
411
  /* XS_TOKEN_GENERATOR */ "generator",
412
  /* XS_TOKEN_GETTER */ "getter",
413
  /* XS_TOKEN_HOST */ "host", 
414
  /* XS_TOKEN_IDENTIFIER */ "identifier",
415
  /* XS_TOKEN_IF */ "if",
416
  /* XS_TOKEN_IMPLEMENTS */ "implements",
417
  /* XS_TOKEN_IMPORT */ "import",
418
  /* XS_TOKEN_IMPORT_CALL */ "import",
419
  /* XS_TOKEN_IMPORT_META */ "import.meta",
420
  /* XS_TOKEN_IN */ "in",
421
  /* XS_TOKEN_INCLUDE */ "include",
422
  /* XS_TOKEN_INCREMENT */ "++",
423
  /* XS_TOKEN_INSTANCEOF */ "instanceof",
424
  /* XS_TOKEN_INTEGER */ "integer",
425
  /* XS_TOKEN_INTERFACE */ "interface",
426
  /* XS_TOKEN_ITEMS */ "items",
427
  /* XS_TOKEN_LABEL */ "label",
428
  /* XS_TOKEN_LEFT_BRACE */ "{",
429
  /* XS_TOKEN_LEFT_BRACKET */ "[",
430
  /* XS_TOKEN_LEFT_PARENTHESIS */ "(",
431
  /* XS_TOKEN_LEFT_SHIFT */ "<<",
432
  /* XS_TOKEN_LEFT_SHIFT_ASSIGN */ "<<=",
433
  /* XS_TOKEN_LESS */ "<",
434
  /* XS_TOKEN_LESS_EQUAL */ "<=",
435
  /* XS_TOKEN_LET */ "let",
436
  /* XS_TOKEN_MEMBER */ "member",
437
  /* XS_TOKEN_MEMBER_AT */ "member_at",
438
  /* XS_TOKEN_MINUS */ "minus",
439
  /* XS_TOKEN_MODULE */ "module",
440
  /* XS_TOKEN_MODULO */ "%",
441
  /* XS_TOKEN_MODULO_ASSIGN */ "%=",
442
  /* XS_TOKEN_MORE */ ">",
443
  /* XS_TOKEN_MORE_EQUAL */ ">=",
444
  /* XS_TOKEN_MULTIPLY */ "*",
445
  /* XS_TOKEN_MULTIPLY_ASSIGN */ "*=",
446
  /* XS_TOKEN_NEW */ "new", 
447
  /* XS_TOKEN_NOT */ "!",
448
  /* XS_TOKEN_NOT_EQUAL */ "!=",
449
  /* XS_TOKEN_NULL */ "null", 
450
  /* XS_TOKEN_NUMBER */ "number",
451
  /* XS_TOKEN_OBJECT */ "object",
452
  /* XS_TOKEN_OBJECT_BINDING */ "object_binding",
453
  /* XS_TOKEN_OPTION */ "?.",
454
  /* XS_TOKEN_OR */ "||",
455
  /* XS_TOKEN_OR_ASSIGN */ "||=",
456
  /* XS_TOKEN_PACKAGE */ "package",
457
  /* XS_TOKEN_PARAMS */ "params",
458
  /* XS_TOKEN_PARAMS_BINDING */ "params_binding",
459
  /* XS_TOKEN_PLUS */ "plus",
460
  /* XS_TOKEN_PRIVATE */ "private",
461
  /* XS_TOKEN_PRIVATE_IDENTIFIER */ "private_identifier",
462
  /* XS_TOKEN_PRIVATE_MEMBER */ "private_member",
463
  /* XS_TOKEN_PRIVATE_PROPERTY */ "private_property",
464
  /* XS_TOKEN_PROGRAM */ "program",
465
  /* XS_TOKEN_PROPERTY */ "property",
466
  /* XS_TOKEN_PROPERTY_AT */ "property_at",
467
  /* XS_TOKEN_PROPERTY_BINDING */ "property_binding",
468
  /* XS_TOKEN_PROPERTY_BINDING_AT */ "property_binding_at",
469
  /* XS_TOKEN_PROTECTED */ "protected",
470
  /* XS_TOKEN_PUBLIC */ "public",
471
  /* XS_TOKEN_QUESTION_MARK */ "?",
472
  /* XS_TOKEN_REGEXP */ "regexp",
473
  /* XS_TOKEN_REST_BINDING */ "rest_binding",
474
  /* XS_TOKEN_RETURN */ "return",
475
  /* XS_TOKEN_RIGHT_BRACE */ "}",
476
  /* XS_TOKEN_RIGHT_BRACKET */ "]",
477
  /* XS_TOKEN_RIGHT_PARENTHESIS */ ")",
478
  /* XS_TOKEN_SEMICOLON */ ";",
479
  /* XS_TOKEN_SETTER */ "setter",
480
  /* XS_TOKEN_SHORT */ "short",
481
  /* XS_TOKEN_SIGNED_RIGHT_SHIFT */ ">>",
482
  /* XS_TOKEN_SIGNED_RIGHT_SHIFT_ASSIGN */ ">>=",
483
  /* XS_TOKEN_SKIP_BINDING */ "skip_binding",
484
  /* XS_TOKEN_SPECIFIER */ "specifier",
485
  /* XS_TOKEN_SPREAD */ "...",
486
  /* XS_TOKEN_STATEMENT */ "statement",
487
  /* XS_TOKEN_STATEMENTS */ "statements",
488
  /* XS_TOKEN_STATIC */ "static",
489
  /* XS_TOKEN_STRICT_EQUAL */ "===",
490
  /* XS_TOKEN_STRICT_NOT_EQUAL */ "!==",
491
  /* XS_TOKEN_STRING */ "string",
492
  /* XS_TOKEN_SUBTRACT */ "-",
493
  /* XS_TOKEN_SUBTRACT_ASSIGN */ "-=",
494
  /* XS_TOKEN_SUPER */ "super",
495
  /* XS_TOKEN_SWITCH */ "switch",
496
  /* XS_TOKEN_TARGET */ "target",
497
  /* XS_TOKEN_TEMPLATE */ "template",
498
  /* XS_TOKEN_TEMPLATE_HEAD */ "template_head",
499
  /* XS_TOKEN_TEMPLATE_MIDDLE */ "template_middle",
500
  /* XS_TOKEN_TEMPLATE_TAIL */ "template_tail",
501
  /* XS_TOKEN_THIS */ "this",
502
  /* XS_TOKEN_THROW */ "throw",
503
  /* XS_TOKEN_TRUE */ "true",
504
  /* XS_TOKEN_TRY */ "try",
505
  /* XS_TOKEN_TYPEOF */ "typeof",
506
  /* XS_TOKEN_UNDEFINED */ "undefined",
507
  /* XS_TOKEN_UNSIGNED_RIGHT_SHIFT */ ">>>",
508
  /* XS_TOKEN_UNSIGNED_RIGHT_SHIFT_ASSIGN */ ">>>=",
509
  /* XS_TOKEN_USIGN */ "using",
510
  /* XS_TOKEN_VAR */ "var",
511
  /* XS_TOKEN_VOID */ "void",
512
  /* XS_TOKEN_WHILE */ "while",
513
  /* XS_TOKEN_WITH */ "with",
514
  /* XS_TOKEN_YIELD */ "yield",
515
};
516
517
txBoolean fxIsKeyword(txParser* parser, txSymbol* keyword)
518
195k
{
519
195k
  txBoolean result = ((parser->states[0].token == XS_TOKEN_IDENTIFIER) && (parser->states[0].symbol == keyword)) ? 1 : 0;
520
195k
  if (result) {
521
32.0k
    if (parser->states[0].escaped)
522
0
      fxReportParserError(parser, parser->states[0].line, "escaped keyword");
523
32.0k
  }
524
195k
  return result;
525
195k
}
526
527
txBoolean fxIsToken(txParser* parser, txToken theToken)
528
60.5k
{
529
60.5k
  txBoolean result = (parser->states[0].token == theToken) ? 1 : 0;
530
60.5k
  if (result) {
531
22.2k
    if (parser->states[0].escaped)
532
0
      fxReportParserError(parser, parser->states[0].line, "escaped keyword");
533
22.2k
  }
534
60.5k
  return result;
535
60.5k
}
536
537
void fxMatchToken(txParser* parser, txToken theToken)
538
4.15M
{
539
4.15M
  if (parser->states[0].token == theToken) {
540
4.10M
    if (parser->states[0].escaped)
541
0
      fxReportParserError(parser, parser->states[0].line, "escaped keyword");
542
4.10M
    fxGetNextToken(parser);
543
4.10M
  }
544
53.2k
  else
545
53.2k
    fxReportParserError(parser, parser->states[0].line, "missing %s", gxTokenNames[theToken]);
546
4.15M
}
547
548
txNode* fxPopNode(txParser* parser)
549
52.4k
{
550
52.4k
  txNode* node = parser->root;
551
52.4k
  parser->root = node->next;
552
52.4k
  node->next = NULL;
553
52.4k
  parser->nodeCount--;
554
52.4k
  return node;
555
52.4k
}
556
557
void fxPushNode(txParser* parser, txNode* node)
558
38.9M
{
559
38.9M
  node->next = parser->root;
560
38.9M
  parser->root = (txNode*)node;
561
38.9M
  parser->nodeCount++;
562
38.9M
}
563
564
void fxPushBigIntNode(txParser* parser, txBigInt* value, txInteger line)
565
66.1k
{
566
66.1k
  txBigIntNode* node = fxNewParserChunk(parser, sizeof(txBigIntNode));
567
66.1k
  node->description = &gxTokenDescriptions[XS_TOKEN_BIGINT];
568
66.1k
  node->path = parser->path;
569
66.1k
  node->line = line;
570
66.1k
  node->flags = 0;
571
66.1k
  node->value = *value;
572
66.1k
  fxPushNode(parser, (txNode*)node);
573
66.1k
}
574
575
void fxPushIndexNode(txParser* parser, txIndex value, txInteger line)
576
19.0k
{
577
19.0k
  if (((txInteger)value) >= 0)
578
19.0k
    fxPushIntegerNode(parser, (txInteger)value, line);
579
82
  else
580
82
    fxPushNumberNode(parser, value, line);
581
19.0k
}
582
583
void fxPushIntegerNode(txParser* parser, txInteger value, txInteger line)
584
13.1M
{
585
13.1M
  txIntegerNode* node = fxNewParserChunk(parser, sizeof(txIntegerNode));
586
13.1M
  node->description = &gxTokenDescriptions[XS_TOKEN_INTEGER];
587
13.1M
  node->path = parser->path;
588
13.1M
  node->line = line;
589
13.1M
  node->flags = 0;
590
13.1M
  node->value = value;
591
13.1M
  fxPushNode(parser, (txNode*)node);
592
13.1M
}
593
594
void fxPushNodeStruct(txParser* parser, txInteger count, txToken token, txInteger line)
595
20.0M
{
596
20.0M
  const txNodeDescription* description = &gxTokenDescriptions[token];
597
20.0M
  txNode* node;
598
20.0M
  if ((count > parser->nodeCount) || ((sizeof(txNode) + (count * sizeof(txNode*))) > (size_t)(description->size))) {
599
0
    fxReportParserError(parser, parser->states[0].line, "invalid %s", gxTokenNames[token]);
600
0
  }
601
20.0M
    node = fxNewParserChunkClear(parser, description->size);
602
20.0M
  node->description = description;
603
20.0M
  node->flags |= parser->flags & (mxStrictFlag | mxGeneratorFlag | mxAsyncFlag);
604
20.0M
  node->path = parser->path;
605
20.0M
  node->line = line;
606
20.0M
    parser->nodeCount -= count;
607
20.0M
  if (count) {
608
19.7M
    txNode** dst = (txNode**)&node[1];
609
19.7M
    txNode* src = parser->root;
610
54.8M
    while (count) {
611
35.0M
      txNode* next = src->next;
612
35.0M
      src->next = NULL;
613
35.0M
      count--;
614
35.0M
      if (src->description)
615
32.1M
        dst[count] = src;
616
2.91M
      else if (src->path)
617
2.67M
        dst[count] = (txNode*)(src->path);
618
35.0M
      src = next;
619
35.0M
    }
620
19.7M
    parser->root = src;
621
19.7M
  }
622
20.0M
  fxPushNode(parser, node);
623
20.0M
}
624
625
void fxPushNodeList(txParser* parser, txInteger count)
626
1.39M
{
627
1.39M
  txNodeList* list = fxNewParserChunk(parser, sizeof(txNodeList));
628
1.39M
  txNode* previous = NULL;
629
1.39M
  txNode* current = parser->root;
630
1.39M
  txNode* next;
631
1.39M
    parser->nodeCount -= count;
632
1.39M
  list->length = count;
633
3.26M
  while (count) {
634
1.87M
    next = current->next;
635
1.87M
    current->next = previous;
636
1.87M
    previous = current;
637
1.87M
    current = next;
638
1.87M
    count--;
639
1.87M
  }
640
1.39M
  parser->root = current;
641
1.39M
  list->description = &gxTokenDescriptions[XS_NO_TOKEN];
642
1.39M
  list->first = previous;
643
1.39M
  fxPushNode(parser, (txNode*)list);
644
1.39M
}
645
646
void fxPushNULL(txParser* parser)
647
487k
{
648
487k
    txNodeLink* node = fxNewParserChunkClear(parser, sizeof(txNodeLink));
649
487k
  fxPushNode(parser, (txNode*)node);
650
487k
}
651
652
void fxPushNumberNode(txParser* parser, txNumber value, txInteger line)
653
37.1k
{
654
37.1k
  txNumberNode* node = fxNewParserChunk(parser, sizeof(txNumberNode));
655
37.1k
  node->description = &gxTokenDescriptions[XS_TOKEN_NUMBER];
656
37.1k
  node->path = parser->path;
657
37.1k
  node->line = line;
658
37.1k
  node->flags = 0;
659
37.1k
  node->value = value;
660
37.1k
  fxPushNode(parser, (txNode*)node);
661
37.1k
}
662
663
void fxPushRawNode(txParser* parser, txInteger length, txString value, txInteger line)
664
270k
{
665
270k
  txStringNode* node = fxNewParserChunk(parser, sizeof(txStringNode));
666
270k
  node->description = &gxTokenDescriptions[XS_TOKEN_STRING];
667
270k
  node->path = parser->path;
668
270k
  node->line = line;
669
270k
  node->flags = 0;
670
270k
  node->length = length;
671
270k
  node->value = value;
672
270k
  fxPushNode(parser, (txNode*)node);
673
270k
}
674
675
void fxPushStringNode(txParser* parser, txInteger length, txString value, txInteger line)
676
627k
{
677
627k
  txStringNode* node = fxNewParserChunk(parser, sizeof(txStringNode));
678
627k
  node->description = &gxTokenDescriptions[XS_TOKEN_STRING];
679
627k
  node->path = parser->path;
680
627k
  node->line = line;
681
627k
  node->flags = parser->states[0].escaped;
682
627k
  node->length = length;
683
627k
  node->value = value;
684
627k
  fxPushNode(parser, (txNode*)node);
685
627k
}
686
687
void fxPushSymbol(txParser* parser, txSymbol* symbol)
688
2.82M
{
689
2.82M
    txNodeLink* node = fxNewParserChunkClear(parser, sizeof(txNodeLink));
690
2.82M
  node->symbol = symbol;  
691
2.82M
  fxPushNode(parser, (txNode*)node);
692
2.82M
}
693
694
void fxSwapNodes(txParser* parser)
695
86.6k
{
696
86.6k
  txNode* previous = parser->root;
697
86.6k
  txNode* current = previous->next;
698
86.6k
  previous->next = current->next;
699
86.6k
  current->next = previous;
700
86.6k
  parser->root = current;
701
86.6k
}
702
703
void fxModule(txParser* parser)
704
12.0k
{
705
12.0k
  txInteger aCount = parser->nodeCount;
706
12.0k
  txInteger aLine = parser->states[0].line;
707
43.2k
  while ((parser->states[0].token != XS_TOKEN_EOF)) {
708
31.2k
    if (parser->states[0].token == XS_TOKEN_EXPORT)
709
9.95k
      fxExportDeclaration(parser);
710
21.2k
    else if (parser->states[0].token == XS_TOKEN_IMPORT) {
711
978
      fxLookAheadOnce(parser);
712
978
      if ((parser->states[1].token == XS_TOKEN_DOT) || (parser->states[1].token == XS_TOKEN_LEFT_PARENTHESIS))
713
99
        fxStatement(parser, 1);
714
879
      else
715
879
        fxImportDeclaration(parser);
716
978
    }
717
20.2k
    else if (parser->states[0].token == XS_TOKEN_RETURN) {
718
260
      fxReportParserError(parser, parser->states[0].line, "invalid return");
719
260
      fxGetNextToken(parser);
720
260
    }
721
20.0k
    else if (parser->states[0].token == XS_TOKEN_YIELD) {
722
1
      fxReportParserError(parser, parser->states[0].line, "invalid yield");
723
1
      fxGetNextToken(parser);
724
1
    }
725
20.0k
    else {
726
20.0k
      fxStatement(parser, 1);
727
20.0k
    }
728
31.2k
  }
729
12.0k
  aCount = parser->nodeCount - aCount;
730
12.0k
  if (aCount > 1) {
731
2.93k
    fxPushNodeList(parser, aCount);
732
2.93k
    fxPushNodeStruct(parser, 1, XS_TOKEN_STATEMENTS, aLine);
733
2.93k
  }
734
9.10k
  else if (aCount == 0) {
735
2
    fxPushNodeStruct(parser, 0, XS_TOKEN_UNDEFINED, aLine);
736
2
    fxPushNodeStruct(parser, 1, XS_TOKEN_STATEMENT, aLine);
737
2
  }
738
12.0k
  fxPushNodeStruct(parser, 1, XS_TOKEN_MODULE, aLine);
739
12.0k
  parser->root->flags = parser->flags & (mxStrictFlag | mxAwaitingFlag);
740
12.0k
}
741
742
void fxExportDeclaration(txParser* parser)
743
9.95k
{
744
9.95k
  txSymbol* symbol = C_NULL;
745
9.95k
  txInteger count;
746
9.95k
  txInteger line = parser->states[0].line;
747
9.95k
  txUnsigned flag = 0;
748
9.95k
  txToken aToken;
749
9.95k
  fxMatchToken(parser, XS_TOKEN_EXPORT);
750
9.95k
  switch (parser->states[0].token) {
751
1.66k
  case XS_TOKEN_MULTIPLY:
752
1.66k
    fxPushNULL(parser);
753
1.66k
    fxGetNextToken(parser);
754
1.66k
    if (fxIsKeyword(parser, parser->asSymbol)) {
755
25
      fxGetNextToken(parser);
756
25
      if (gxTokenFlags[parser->states[0].token] & XS_TOKEN_IDENTIFIER_NAME) {
757
24
        fxPushSymbol(parser, parser->states[0].symbol);
758
24
        fxGetNextToken(parser);
759
24
      }
760
1
      else {
761
1
        fxPushNULL(parser);
762
1
        fxReportParserError(parser, parser->states[0].line, "missing identifier");
763
1
      }
764
25
    }
765
1.63k
    else {
766
1.63k
      fxPushNULL(parser);
767
1.63k
    }
768
1.66k
    if (fxIsKeyword(parser, parser->fromSymbol)) {
769
394
      fxGetNextToken(parser);
770
394
      if (parser->states[0].token == XS_TOKEN_STRING) {
771
392
        fxPushNodeStruct(parser, 2, XS_TOKEN_SPECIFIER, line);
772
392
        fxPushNodeList(parser, 1);
773
392
        fxPushStringNode(parser, parser->states[0].stringLength, parser->states[0].string, line);
774
392
        fxGetNextToken(parser);
775
392
        if (!parser->states[0].crlf && (parser->states[0].token == XS_TOKEN_WITH)) {
776
1
          fxGetNextToken(parser);
777
1
          fxWithAttributes(parser);
778
1
        }
779
391
        else
780
391
          fxPushNULL(parser);
781
392
        fxPushNodeStruct(parser, 3, XS_TOKEN_EXPORT, line);
782
392
        fxSemicolon(parser);
783
392
      }
784
2
      else
785
2
        fxReportParserError(parser, parser->states[0].line, "missing module");
786
394
    }
787
1.26k
    else
788
1.26k
      fxReportParserError(parser, parser->states[0].line, "missing from");
789
1.66k
    break;
790
207
  case XS_TOKEN_DEFAULT:
791
207
    fxMatchToken(parser, XS_TOKEN_DEFAULT);
792
207
    if (parser->flags & mxDefaultFlag)
793
2
      fxReportParserError(parser, parser->states[0].line, "invalid default");
794
207
    parser->flags |= mxDefaultFlag;
795
207
    if (parser->states[0].token == XS_TOKEN_CLASS) {
796
0
      fxClassExpression(parser, line, &symbol);
797
0
      if (symbol)
798
0
        fxPushSymbol(parser, symbol);
799
0
      else
800
0
        fxPushSymbol(parser, parser->defaultSymbol);
801
0
      fxPushNodeStruct(parser, 1, XS_TOKEN_LET, line);
802
0
      fxSwapNodes(parser);
803
0
      fxPushNodeStruct(parser, 2, XS_TOKEN_BINDING, line);
804
0
    }
805
207
    else if (parser->states[0].token == XS_TOKEN_FUNCTION) {
806
0
  again:
807
0
      fxMatchToken(parser, XS_TOKEN_FUNCTION);
808
0
      if (parser->states[0].token == XS_TOKEN_MULTIPLY) {
809
0
        fxGetNextToken(parser);
810
0
        fxGeneratorExpression(parser, line, &symbol, flag);
811
0
      }
812
0
      else
813
0
        fxFunctionExpression(parser, line, &symbol, flag);
814
0
      if (symbol) {
815
0
        txDefineNode* node = fxDefineNodeNew(parser, XS_TOKEN_DEFINE, symbol);
816
0
        node->initializer = fxPopNode(parser);
817
0
        fxPushNode(parser, (txNode*)node);
818
0
      }
819
0
      else {
820
0
        txDefineNode* node = fxDefineNodeNew(parser, XS_TOKEN_DEFINE, parser->defaultSymbol);
821
0
        node->initializer = fxPopNode(parser);
822
0
        fxPushNode(parser, (txNode*)node);
823
0
      }
824
0
    }
825
207
    else {
826
207
      if ((parser->states[0].token == XS_TOKEN_IDENTIFIER) && (parser->states[0].symbol == parser->asyncSymbol) && (!parser->states[0].escaped)) {
827
0
        fxLookAheadOnce(parser);
828
0
        if ((!parser->states[1].crlf) && (parser->states[1].token == XS_TOKEN_FUNCTION)) {
829
0
          fxGetNextToken(parser);
830
0
          flag = mxAsyncFlag;
831
0
          goto again;         
832
0
        }
833
0
      }
834
207
      fxAssignmentExpression(parser);
835
207
      fxSemicolon(parser);
836
207
      fxPushSymbol(parser, parser->defaultSymbol);
837
207
      fxPushNULL(parser);
838
207
      fxPushNodeStruct(parser, 2, XS_TOKEN_CONST, line);
839
207
      fxSwapNodes(parser);
840
207
      fxPushNodeStruct(parser, 2, XS_TOKEN_ASSIGN, line);
841
207
      fxPushNodeStruct(parser, 1, XS_TOKEN_STATEMENT, line);
842
207
    }
843
207
    if (symbol) {
844
0
      fxPushSymbol(parser, symbol);
845
0
      fxPushSymbol(parser, parser->defaultSymbol);
846
0
    }
847
207
    else {
848
207
      fxPushSymbol(parser, parser->defaultSymbol);
849
207
      fxPushNULL(parser);
850
207
    }
851
207
    fxPushNodeStruct(parser, 2, XS_TOKEN_SPECIFIER, line);
852
207
    fxPushNodeList(parser, 1);
853
207
    fxPushNULL(parser);
854
207
    fxPushNULL(parser);
855
207
    fxPushNodeStruct(parser, 3, XS_TOKEN_EXPORT, line);
856
207
    break;
857
0
  case XS_TOKEN_CLASS:
858
0
    fxClassExpression(parser, line, &symbol);
859
0
    if (symbol) {
860
0
      fxPushSymbol(parser, symbol);
861
0
      fxPushNodeStruct(parser, 1, XS_TOKEN_LET, line);
862
0
      fxSwapNodes(parser);
863
0
      fxPushNodeStruct(parser, 2, XS_TOKEN_BINDING, line);
864
      
865
0
      fxPushSymbol(parser, symbol);
866
0
      fxPushNULL(parser);
867
0
      fxPushNodeStruct(parser, 2, XS_TOKEN_SPECIFIER, line);
868
0
      fxPushNodeList(parser, 1);
869
0
      fxPushNULL(parser);
870
0
      fxPushNULL(parser);
871
0
      fxPushNodeStruct(parser, 3, XS_TOKEN_EXPORT, line);
872
0
    }
873
0
    else
874
0
      fxReportParserError(parser, parser->states[0].line, "missing identifier");
875
0
    break;
876
3
  case XS_TOKEN_FUNCTION:
877
3
  again2:
878
3
    fxMatchToken(parser, XS_TOKEN_FUNCTION);
879
3
    if (parser->states[0].token == XS_TOKEN_MULTIPLY) {
880
1
      fxGetNextToken(parser);
881
1
      fxGeneratorExpression(parser, line, &symbol, flag);
882
1
    }
883
2
    else
884
2
      fxFunctionExpression(parser, line, &symbol, flag);
885
3
    if (symbol) {
886
0
      txDefineNode* node = fxDefineNodeNew(parser, XS_TOKEN_DEFINE, symbol);
887
0
      node->initializer = fxPopNode(parser);
888
0
      fxPushNode(parser, (txNode*)node);
889
0
      fxPushSymbol(parser, symbol);
890
0
      fxPushNULL(parser);
891
0
      fxPushNodeStruct(parser, 2, XS_TOKEN_SPECIFIER, line);
892
0
      fxPushNodeList(parser, 1);
893
0
      fxPushNULL(parser);
894
0
      fxPushNULL(parser);
895
0
      fxPushNodeStruct(parser, 3, XS_TOKEN_EXPORT, line);
896
0
    }
897
3
    else
898
3
      fxReportParserError(parser, parser->states[0].line, "missing identifier");
899
3
    break;
900
108
  case XS_TOKEN_CONST:
901
211
  case XS_TOKEN_LET:
902
269
  case XS_TOKEN_VAR:
903
269
    aToken = parser->states[0].token;
904
269
    fxVariableStatement(parser, aToken, 0);
905
269
    count = parser->nodeCount;
906
269
    fxExportBinding(parser, parser->root);
907
269
    fxPushNodeList(parser, parser->nodeCount - count);
908
269
    fxPushNULL(parser);
909
269
    fxPushNULL(parser);
910
269
    fxPushNodeStruct(parser, 3, XS_TOKEN_EXPORT, line);
911
269
    fxSemicolon(parser);
912
269
    break;
913
4.68k
  case XS_TOKEN_LEFT_BRACE:
914
4.68k
    count = parser->nodeCount;
915
4.68k
    fxSpecifiers(parser);
916
4.68k
    fxPushNodeList(parser, parser->nodeCount - count);
917
4.68k
    if (fxIsKeyword(parser, parser->fromSymbol)) {
918
65
      fxGetNextToken(parser);
919
65
      if (parser->states[0].token == XS_TOKEN_STRING) {
920
64
        fxPushStringNode(parser, parser->states[0].stringLength, parser->states[0].string, line);
921
64
        fxGetNextToken(parser);
922
64
      }
923
1
      else {
924
1
        fxPushNULL(parser);
925
1
        fxReportParserError(parser, parser->states[0].line, "missing module");
926
1
      }
927
65
      if (!parser->states[0].crlf && (parser->states[0].token == XS_TOKEN_WITH)) {
928
0
        fxGetNextToken(parser);
929
0
        fxWithAttributes(parser);
930
0
      }
931
65
      else
932
65
        fxPushNULL(parser);
933
65
    }
934
4.62k
    else {
935
4.62k
      fxPushNULL(parser);
936
4.62k
      fxPushNULL(parser);
937
4.62k
    }
938
4.68k
    fxPushNodeStruct(parser, 3, XS_TOKEN_EXPORT, line);
939
4.68k
    fxSemicolon(parser);
940
4.68k
    break;
941
3.11k
  default:
942
3.11k
    if ((parser->states[0].token == XS_TOKEN_IDENTIFIER) && (parser->states[0].symbol == parser->asyncSymbol) && (!parser->states[0].escaped)) {
943
1
      fxLookAheadOnce(parser);
944
1
      if ((!parser->states[1].crlf) && (parser->states[1].token == XS_TOKEN_FUNCTION)) {
945
0
        fxGetNextToken(parser);
946
0
        flag = mxAsyncFlag;
947
0
        goto again2;          
948
0
      }
949
1
    }
950
3.11k
    fxReportParserError(parser, parser->states[0].line, "invalid export %s", gxTokenNames[parser->states[0].token]);
951
3.11k
    fxGetNextToken(parser);
952
3.11k
    break;
953
9.95k
  }
954
9.95k
}
955
956
void fxExportBinding(txParser* parser, txNode* node)
957
523
{
958
523
  txToken token = node->description->token;
959
523
  if ((token == XS_TOKEN_CONST) || (token == XS_TOKEN_LET) || (token == XS_TOKEN_VAR)) {
960
294
    fxPushSymbol(parser, ((txDeclareNode*)node)->symbol);
961
294
    fxPushNULL(parser);
962
294
    fxPushNodeStruct(parser, 2, XS_TOKEN_SPECIFIER, node->line);
963
294
  }
964
229
  else if (token == XS_TOKEN_BINDING) {
965
201
    fxExportBinding(parser, ((txBindingNode*)node)->target);
966
201
  }
967
28
  else if (token == XS_TOKEN_ARRAY_BINDING) {
968
0
    node = ((txArrayBindingNode*)node)->items->first;
969
0
    while (node) {
970
0
      fxExportBinding(parser, node);
971
0
      node = node->next;
972
0
    }
973
0
  }
974
28
  else if (token == XS_TOKEN_OBJECT_BINDING) {
975
7
    node = ((txObjectBindingNode*)node)->items->first;
976
14
    while (node) {
977
7
      fxExportBinding(parser, node);
978
7
      node = node->next;
979
7
    }
980
7
  }
981
21
  else if (token == XS_TOKEN_PROPERTY_BINDING)
982
7
    fxExportBinding(parser, ((txPropertyBindingNode*)node)->binding);
983
14
  else if (token == XS_TOKEN_PROPERTY_BINDING_AT)
984
0
    fxExportBinding(parser, ((txPropertyBindingAtNode*)node)->binding);
985
14
  else if (token == XS_TOKEN_REST_BINDING)
986
0
    fxExportBinding(parser, ((txRestBindingNode*)node)->binding);
987
14
  else if (token == XS_TOKEN_STATEMENTS) {
988
14
    node = ((txStatementsNode*)node)->items->first;
989
53
    while (node) {
990
39
      fxExportBinding(parser, node);
991
39
      node = node->next;
992
39
    }
993
14
  }
994
523
}
995
996
997
void fxImportDeclaration(txParser* parser)
998
879
{
999
879
  txBoolean asFlag = 1;
1000
879
  txBoolean fromFlag = 0;
1001
879
  txInteger count = parser->nodeCount;
1002
879
  fxMatchToken(parser, XS_TOKEN_IMPORT);
1003
879
  if (parser->states[0].token == XS_TOKEN_IDENTIFIER) {
1004
99
    fxPushSymbol(parser, parser->defaultSymbol);
1005
99
    fxPushSymbol(parser, parser->states[0].symbol);
1006
99
    fxPushNodeStruct(parser, 2, XS_TOKEN_SPECIFIER, parser->states[0].line);
1007
99
    fxGetNextToken(parser);
1008
99
    if (parser->states[0].token == XS_TOKEN_COMMA)
1009
1
      fxGetNextToken(parser);
1010
98
    else
1011
98
      asFlag = 0;
1012
99
    fromFlag = 1;
1013
99
  }
1014
879
  if (asFlag) {
1015
781
    if (parser->states[0].token == XS_TOKEN_MULTIPLY) {
1016
650
      fxGetNextToken(parser);
1017
650
      if (fxIsKeyword(parser, parser->asSymbol)) {
1018
649
        fxGetNextToken(parser);
1019
649
        if (parser->states[0].token == XS_TOKEN_IDENTIFIER) {
1020
70
          fxPushNULL(parser);
1021
70
          fxPushSymbol(parser, parser->states[0].symbol);
1022
70
          fxPushNodeStruct(parser, 2, XS_TOKEN_SPECIFIER, parser->states[0].line);
1023
70
          fxGetNextToken(parser);
1024
70
        }
1025
579
        else {
1026
579
          fxReportParserError(parser, parser->states[0].line, "missing identifier");
1027
579
        }
1028
649
      }
1029
1
      else {
1030
1
        fxReportParserError(parser, parser->states[0].line, "missing as");
1031
1
      }
1032
650
      fromFlag = 1;
1033
650
    }
1034
131
    else if (parser->states[0].token == XS_TOKEN_LEFT_BRACE) {
1035
47
      fxSpecifiers(parser);
1036
47
      fromFlag = 1;
1037
47
    }
1038
781
  }
1039
879
  fxPushNodeList(parser, parser->nodeCount - count);
1040
879
  if (fromFlag) {
1041
213
    if (fxIsKeyword(parser, parser->fromSymbol)) {
1042
209
      fxGetNextToken(parser);
1043
209
      if (parser->states[0].token == XS_TOKEN_STRING) {
1044
206
        fxPushStringNode(parser, parser->states[0].stringLength, parser->states[0].string, parser->states[0].line);
1045
206
        fxGetNextToken(parser);
1046
206
      }
1047
3
      else {
1048
3
        fxPushNULL(parser);
1049
3
        fxReportParserError(parser, parser->states[0].line, "missing module");
1050
3
      }
1051
209
    }
1052
4
    else {
1053
4
      fxPushNULL(parser);
1054
4
      fxReportParserError(parser, parser->states[0].line, "missing from");
1055
4
    }
1056
213
  }
1057
666
  else if (parser->states[0].token == XS_TOKEN_STRING) {
1058
80
    fxPushStringNode(parser, parser->states[0].stringLength, parser->states[0].string, parser->states[0].line);
1059
80
    fxGetNextToken(parser);
1060
80
  }
1061
586
  else {
1062
586
    fxPushNULL(parser);
1063
586
    fxReportParserError(parser, parser->states[0].line, "missing module");
1064
586
  }
1065
879
  if (!parser->states[0].crlf && (parser->states[0].token == XS_TOKEN_WITH)) {
1066
1
    fxGetNextToken(parser);
1067
1
    fxWithAttributes(parser);
1068
1
  }
1069
878
  else
1070
878
    fxPushNULL(parser);
1071
879
  fxPushNodeStruct(parser, 3, XS_TOKEN_IMPORT, parser->states[0].line);
1072
879
  fxSemicolon(parser);
1073
879
}
1074
1075
void fxSpecifiers(txParser* parser)
1076
4.73k
{
1077
//  txInteger aCount = 0;
1078
4.73k
  fxMatchToken(parser, XS_TOKEN_LEFT_BRACE);
1079
6.63k
  while (gxTokenFlags[parser->states[0].token] & XS_TOKEN_IDENTIFIER_NAME) {
1080
4.44k
    fxPushSymbol(parser, parser->states[0].symbol);
1081
4.44k
    fxGetNextToken(parser);
1082
4.44k
    if (fxIsKeyword(parser, parser->asSymbol)) {
1083
3.09k
      fxGetNextToken(parser);
1084
3.09k
      if (gxTokenFlags[parser->states[0].token] & XS_TOKEN_IDENTIFIER_NAME) {
1085
1.95k
        fxPushSymbol(parser, parser->states[0].symbol);
1086
1.95k
        fxGetNextToken(parser);
1087
1.95k
      }
1088
1.14k
      else {
1089
1.14k
        fxPushNULL(parser);
1090
1.14k
        fxReportParserError(parser, parser->states[0].line, "missing identifier");
1091
1.14k
      }
1092
3.09k
    }
1093
1.34k
    else
1094
1.34k
      fxPushNULL(parser);
1095
4.44k
    fxPushNodeStruct(parser, 2, XS_TOKEN_SPECIFIER, parser->states[0].line);
1096
//    aCount++;
1097
4.44k
    if (parser->states[0].token != XS_TOKEN_COMMA) 
1098
2.54k
      break;
1099
1.90k
    fxGetNextToken(parser);
1100
1.90k
  }
1101
4.73k
  fxMatchToken(parser, XS_TOKEN_RIGHT_BRACE);
1102
4.73k
}
1103
1104
void fxWithAttributes(txParser* parser)
1105
1
{
1106
1
  txBoolean flag = 0;
1107
1
  txString string;
1108
1
  fxMatchToken(parser, XS_TOKEN_LEFT_BRACE);
1109
1
  while (parser->states[0].token != XS_TOKEN_RIGHT_BRACE) {
1110
0
    if ((gxTokenFlags[parser->states[0].token] & XS_TOKEN_IDENTIFIER_NAME))
1111
0
      string = parser->states[0].symbol->string;
1112
0
    else if (parser->states[0].token == XS_TOKEN_STRING)
1113
0
      string = parser->states[0].string;
1114
0
    else {
1115
0
      fxReportParserError(parser, parser->states[0].line, "missing attribute key");
1116
0
      break;
1117
0
    }
1118
0
    if (c_strcmp(string, "type"))
1119
0
      fxReportParserError(parser, parser->states[0].line, "invalid attribute key");
1120
0
    else if (flag)
1121
0
      fxReportParserError(parser, parser->states[0].line, "duplicate attribute");
1122
0
    fxGetNextToken(parser);
1123
0
    if (parser->states[0].token != XS_TOKEN_COLON) {
1124
0
      fxReportParserError(parser, parser->states[0].line, "missing :");
1125
0
      break;
1126
0
    }
1127
0
        fxGetNextToken(parser);
1128
0
    if (parser->states[0].token == XS_TOKEN_STRING)
1129
0
      string = parser->states[0].string;
1130
0
    else {
1131
0
      fxReportParserError(parser, parser->states[0].line, "missing attribute value");
1132
0
      break;
1133
0
    }
1134
0
    if (c_strcmp(string, "json"))
1135
0
      fxReportParserError(parser, parser->states[0].line, "invalid attribute value");
1136
0
    flag = 1;
1137
0
    fxGetNextToken(parser);
1138
0
    if (parser->states[0].token != XS_TOKEN_COMMA)
1139
0
      break;
1140
0
    fxGetNextToken(parser);
1141
0
  }
1142
1
  fxMatchToken(parser, XS_TOKEN_RIGHT_BRACE);
1143
1
  if (flag)
1144
0
    fxPushSymbol(parser, parser->jsonSymbol);
1145
1
  else
1146
1
    fxPushNULL(parser);
1147
1
}
1148
1149
void fxProgram(txParser* parser)
1150
538k
{
1151
538k
  txInteger count = parser->nodeCount;
1152
538k
  txInteger line = parser->states[0].line;
1153
538k
  txNode* node;
1154
755k
  while (parser->states[0].token != XS_TOKEN_EOF) {
1155
554k
    fxStatement(parser, -1);
1156
554k
    node = parser->root;
1157
554k
    if (!node || !node->description || (node->description->token != XS_TOKEN_STATEMENT))
1158
60.5k
      break;
1159
493k
    node = ((txStatementNode*)node)->expression;
1160
493k
    if (!node || !node->description || (node->description->token != XS_TOKEN_STRING))
1161
275k
      break;
1162
217k
    if (!(node->flags & mxStringEscapeFlag) && (c_strcmp(((txStringNode*)node)->value, "use strict") == 0)) {
1163
16.6k
      if (!(parser->flags & mxStrictFlag)) {
1164
8.70k
        parser->flags |= mxStrictFlag;
1165
8.70k
        if (parser->states[0].token == XS_TOKEN_IDENTIFIER)
1166
4.72k
          fxCheckStrictKeyword(parser);
1167
8.70k
      }
1168
16.6k
    }
1169
217k
  }
1170
1.14M
  while (parser->states[0].token != XS_TOKEN_EOF) {
1171
605k
    fxStatement(parser, -1);
1172
605k
  }
1173
538k
  count = parser->nodeCount - count;
1174
538k
  if (count > 1) {
1175
44.0k
    fxPushNodeList(parser, count);
1176
44.0k
    fxPushNodeStruct(parser, 1, XS_TOKEN_STATEMENTS, line);
1177
44.0k
  }
1178
494k
  else if (count == 0) {
1179
5.70k
    fxPushNodeStruct(parser, 0, XS_TOKEN_UNDEFINED, line);
1180
5.70k
    fxPushNodeStruct(parser, 1, XS_TOKEN_STATEMENT, line);
1181
5.70k
  }
1182
538k
  fxPushNodeStruct(parser, 1, XS_TOKEN_PROGRAM, line);
1183
538k
  if (parser->flags & mxFieldFlag)
1184
0
    if (parser->flags & mxArgumentsFlag)
1185
0
      fxReportParserError(parser, parser->states[0].line, "invalid arguments");
1186
538k
  parser->root->flags = parser->flags & mxStrictFlag;
1187
538k
}
1188
1189
void fxBody(txParser* parser)
1190
261k
{
1191
261k
  txInteger count = parser->nodeCount;
1192
261k
  txInteger line = parser->states[0].line;
1193
261k
  txNode* node;
1194
261k
    fxCheckParserStack(parser, line);
1195
340k
  while ((parser->states[0].token != XS_TOKEN_EOF) && (parser->states[0].token != XS_TOKEN_RIGHT_BRACE)) {
1196
220k
    fxStatement(parser, 1);
1197
220k
    node = parser->root;
1198
220k
    if (!node || !node->description || (node->description->token != XS_TOKEN_STATEMENT))
1199
35.6k
      break;
1200
184k
    node = ((txStatementNode*)node)->expression;
1201
184k
    if (!node || !node->description || (node->description->token != XS_TOKEN_STRING))
1202
105k
      break;
1203
79.1k
    if (!(node->flags & mxStringEscapeFlag) && (c_strcmp(((txStringNode*)node)->value, "use strict") == 0)) {
1204
3.07k
      if (parser->flags & mxNotSimpleParametersFlag)
1205
1
        fxReportParserError(parser, parser->states[0].line, "invalid directive");
1206
3.07k
      if (!(parser->flags & mxStrictFlag)) {
1207
2.73k
        parser->flags |= mxStrictFlag;
1208
2.73k
        if (parser->states[0].token == XS_TOKEN_IDENTIFIER)
1209
1.74k
          fxCheckStrictKeyword(parser);
1210
2.73k
      }
1211
3.07k
    }
1212
79.1k
  }
1213
475k
  while ((parser->states[0].token != XS_TOKEN_EOF) && (parser->states[0].token != XS_TOKEN_RIGHT_BRACE)) {
1214
213k
    fxStatement(parser, 1);
1215
213k
  }
1216
261k
  count = parser->nodeCount - count;
1217
261k
  if (count > 1) {
1218
29.1k
    fxPushNodeList(parser, count);
1219
29.1k
    fxPushNodeStruct(parser, 1, XS_TOKEN_STATEMENTS, line);
1220
29.1k
  }
1221
232k
  else if (count == 0) {
1222
45.1k
    fxPushNodeStruct(parser, 0, XS_TOKEN_UNDEFINED, line);
1223
45.1k
    fxPushNodeStruct(parser, 1, XS_TOKEN_STATEMENT, line);
1224
45.1k
  }
1225
261k
}
1226
1227
void fxBlock(txParser* parser)
1228
99.1k
{
1229
99.1k
  txInteger aLine = parser->states[0].line;
1230
99.1k
  fxCheckParserStack(parser, aLine);
1231
99.1k
  fxMatchToken(parser, XS_TOKEN_LEFT_BRACE);
1232
99.1k
  fxStatements(parser);
1233
99.1k
  fxMatchToken(parser, XS_TOKEN_RIGHT_BRACE);
1234
99.1k
  fxPushNodeStruct(parser, 1, XS_TOKEN_BLOCK, aLine);
1235
99.1k
}
1236
1237
void fxStatements(txParser* parser)
1238
163k
{
1239
163k
  txInteger count = parser->nodeCount;
1240
163k
  txInteger line = parser->states[0].line;
1241
335k
  while ((parser->states[0].token != XS_TOKEN_EOF) && (parser->states[0].token != XS_TOKEN_RIGHT_BRACE)) {
1242
172k
    fxStatement(parser, 1);
1243
172k
  }
1244
163k
  count = parser->nodeCount - count;
1245
163k
  fxPushNodeList(parser, count);
1246
163k
  fxPushNodeStruct(parser, 1, XS_TOKEN_STATEMENTS, line);
1247
163k
}
1248
1249
void fxStatement(txParser* parser, txInteger blockIt)
1250
1.94M
{
1251
1.94M
  txInteger line = parser->states[0].line;
1252
1.94M
  txSymbol* symbol = C_NULL;
1253
1.94M
  txUnsigned flag = 0;
1254
1.94M
  switch (parser->states[0].token) {
1255
//  case XS_TOKEN_COMMA:
1256
70.5k
  case XS_TOKEN_SEMICOLON:
1257
70.5k
    fxGetNextToken(parser);
1258
70.5k
    if (!blockIt) {
1259
409
      fxPushNodeStruct(parser, 0, XS_TOKEN_UNDEFINED, line);
1260
409
      fxPushNodeStruct(parser, 1, XS_TOKEN_STATEMENT, line);
1261
409
    }
1262
70.5k
    break;
1263
5.56k
  case XS_TOKEN_BREAK:
1264
5.56k
    fxBreakStatement(parser);
1265
5.56k
    fxSemicolon(parser);
1266
5.56k
    break;
1267
71.9k
  case XS_TOKEN_CLASS:
1268
71.9k
    if (!blockIt)
1269
1.56k
      fxReportParserError(parser, parser->states[0].line, "no block");
1270
71.9k
    fxClassExpression(parser, line, &symbol);
1271
71.9k
    if (symbol) {
1272
3.55k
      fxPushSymbol(parser, symbol);
1273
3.55k
      fxPushNodeStruct(parser, 1, XS_TOKEN_LET, line);
1274
3.55k
      fxSwapNodes(parser);
1275
3.55k
      fxPushNodeStruct(parser, 2, XS_TOKEN_BINDING, line);
1276
3.55k
    }
1277
68.4k
    else
1278
68.4k
      fxReportParserError(parser, parser->states[0].line, "missing identifier");
1279
71.9k
    break;
1280
19.5k
  case XS_TOKEN_CONST:
1281
19.5k
    if (!blockIt)
1282
382
      fxReportParserError(parser, parser->states[0].line, "no block");
1283
19.5k
    fxVariableStatement(parser, XS_TOKEN_CONST, 0);
1284
19.5k
    fxSemicolon(parser);
1285
19.5k
    break;
1286
4.10k
  case XS_TOKEN_CONTINUE:
1287
4.10k
    fxContinueStatement(parser);
1288
4.10k
    fxSemicolon(parser);
1289
4.10k
    break;
1290
1.14k
  case XS_TOKEN_DEBUGGER:
1291
1.14k
    fxDebuggerStatement(parser);
1292
1.14k
    fxSemicolon(parser);
1293
1.14k
    break;
1294
28.0k
  case XS_TOKEN_DO:
1295
28.0k
    fxDoStatement(parser);
1296
28.0k
    break;
1297
51.9k
  case XS_TOKEN_FOR:
1298
51.9k
    fxForStatement(parser);
1299
51.9k
    break;
1300
25.1k
  case XS_TOKEN_FUNCTION:
1301
    //if ((parser->flags & mxStrictFlag) && !blockIt) BROWSER
1302
25.7k
  again:
1303
25.7k
    if (!blockIt)
1304
37
      fxReportParserError(parser, parser->states[0].line, "no block (strict code)");
1305
25.7k
    fxMatchToken(parser, XS_TOKEN_FUNCTION);
1306
25.7k
    if (parser->states[0].token == XS_TOKEN_MULTIPLY) {
1307
20.4k
      fxGetNextToken(parser);
1308
20.4k
      fxGeneratorExpression(parser, line, &symbol, flag);
1309
20.4k
    }
1310
5.30k
    else
1311
5.30k
      fxFunctionExpression(parser, line, &symbol, flag);
1312
25.7k
    if (symbol) {
1313
16.2k
      txDefineNode* node = fxDefineNodeNew(parser, XS_TOKEN_DEFINE, symbol);
1314
16.2k
      node->initializer = fxPopNode(parser);
1315
16.2k
      fxPushNode(parser, (txNode*)node);
1316
16.2k
    }
1317
9.51k
    else
1318
9.51k
      fxReportParserError(parser, parser->states[0].line, "missing identifier");
1319
25.7k
    break;
1320
5.65k
  case XS_TOKEN_IF:
1321
5.65k
    fxIfStatement(parser);
1322
5.65k
    break;
1323
12.7k
  case XS_TOKEN_RETURN:
1324
12.7k
    if (!(parser->flags & (mxArrowFlag | mxFunctionFlag | mxGeneratorFlag)))
1325
1.71k
      fxReportParserError(parser, parser->states[0].line, "invalid return");
1326
12.7k
    fxReturnStatement(parser);
1327
12.7k
    fxSemicolon(parser);
1328
12.7k
    break;
1329
91.8k
  case XS_TOKEN_LEFT_BRACE:
1330
91.8k
    fxBlock(parser);
1331
91.8k
    break;
1332
6.03k
  case XS_TOKEN_LET:
1333
6.03k
    if (!blockIt)
1334
20
      fxReportParserError(parser, parser->states[0].line, "no block");
1335
6.03k
    fxVariableStatement(parser, XS_TOKEN_LET, 0);
1336
6.03k
    fxSemicolon(parser);
1337
6.03k
    break;
1338
8.91k
  case XS_TOKEN_SWITCH:
1339
8.91k
    fxSwitchStatement(parser);
1340
8.91k
    break;
1341
24.9k
  case XS_TOKEN_THROW:
1342
24.9k
    fxThrowStatement(parser);
1343
24.9k
    fxSemicolon(parser);
1344
24.9k
    break;
1345
7.25k
  case XS_TOKEN_TRY:
1346
7.25k
    fxTryStatement(parser);
1347
7.25k
    break;
1348
88.9k
  case XS_TOKEN_VAR:
1349
88.9k
    fxVariableStatement(parser, XS_TOKEN_VAR, 0);
1350
88.9k
    fxSemicolon(parser);
1351
88.9k
    break;
1352
547
  case XS_TOKEN_WHILE:
1353
547
    fxWhileStatement(parser);
1354
547
    break;
1355
3.87k
  case XS_TOKEN_WITH:
1356
3.87k
    if (parser->flags & mxStrictFlag)
1357
82
      fxReportParserError(parser, parser->states[0].line, "with (strict code)");
1358
3.87k
    fxWithStatement(parser);
1359
3.87k
    break;
1360
0
#if mxExplicitResourceManagement
1361
650
  case XS_TOKEN_AWAIT:
1362
650
    fxLookAheadOnce(parser);
1363
650
    if ((!parser->states[1].crlf) && (parser->states[1].token == XS_TOKEN_IDENTIFIER) && (parser->states[1].symbol == parser->usingSymbol) && (!parser->states[1].escaped)) {
1364
0
      fxLookAheadTwice(parser);
1365
0
      if ((!parser->states[2].crlf) && ((parser->states[2].token == XS_TOKEN_IDENTIFIER) || (parser->states[2].token == XS_TOKEN_AWAIT) || (parser->states[2].token == XS_TOKEN_YIELD))) {
1366
0
        fxGetNextToken(parser);
1367
0
        parser->states[0].token = XS_TOKEN_USING;
1368
0
        if (blockIt <= 0)
1369
0
          fxReportParserError(parser, parser->states[0].line, "no block");
1370
0
        fxVariableStatement(parser, XS_TOKEN_USING, mxAwaitingFlag);
1371
0
        parser->flags |= mxAwaitingFlag;
1372
0
        fxSemicolon(parser);
1373
0
        break;
1374
0
      }
1375
0
    }
1376
650
    fxCommaExpression(parser);
1377
650
    fxPushNodeStruct(parser, 1, XS_TOKEN_STATEMENT, line);
1378
650
    fxSemicolon(parser);
1379
650
    break;
1380
0
#endif
1381
954k
  case XS_TOKEN_IDENTIFIER:
1382
954k
    fxLookAheadOnce(parser);
1383
954k
    if (parser->states[1].token == XS_TOKEN_COLON) {
1384
88.2k
      fxPushSymbol(parser, parser->states[0].symbol);
1385
88.2k
      fxGetNextToken(parser);
1386
88.2k
      fxMatchToken(parser, XS_TOKEN_COLON);
1387
      //if ((parser->flags & mxStrictFlag) && (parser->states[0].token == XS_TOKEN_FUNCTION)) BROWSER
1388
      //  fxReportParserError(parser, parser->states[0].line, "labeled function (strict code)");
1389
88.2k
      if (parser->states[0].token == XS_TOKEN_FUNCTION)
1390
41
        fxReportParserError(parser, parser->states[0].line, "labeled function");
1391
88.2k
      fxCheckParserStack(parser, line);
1392
88.2k
      fxStatement(parser, 0);
1393
88.2k
      fxPushNodeStruct(parser, 2, XS_TOKEN_LABEL, line);
1394
88.2k
      break;
1395
88.2k
    }
1396
866k
    if ((parser->states[0].symbol == parser->asyncSymbol) && (!parser->states[0].escaped) 
1397
1.43k
        && (!parser->states[1].crlf) && (parser->states[1].token == XS_TOKEN_FUNCTION)) {
1398
528
      fxGetNextToken(parser);
1399
528
      flag = mxAsyncFlag;
1400
528
      goto again;
1401
528
    }
1402
865k
    if ((parser->states[0].symbol == parser->letSymbol) && (!parser->states[0].escaped) 
1403
35.2k
        && ((gxTokenFlags[parser->states[1].token] & XS_TOKEN_BEGIN_BINDING) || (parser->states[1].token == XS_TOKEN_AWAIT) || (parser->states[1].token == XS_TOKEN_YIELD))
1404
31.8k
        && (blockIt || (!parser->states[1].crlf) || (parser->states[1].token == XS_TOKEN_LEFT_BRACKET))) {
1405
31.7k
      parser->states[0].token = XS_TOKEN_LET;
1406
31.7k
      if (!blockIt)
1407
1.28k
        fxReportParserError(parser, parser->states[0].line, "no block");
1408
31.7k
      fxVariableStatement(parser, XS_TOKEN_LET, 0);
1409
31.7k
      fxSemicolon(parser);
1410
31.7k
      break;
1411
31.7k
    }
1412
834k
#if mxExplicitResourceManagement
1413
834k
    if ((parser->states[0].symbol == parser->usingSymbol) && (!parser->states[0].escaped)
1414
11.4k
        && (!parser->states[1].crlf) && ((parser->states[1].token == XS_TOKEN_IDENTIFIER) || (parser->states[1].token == XS_TOKEN_AWAIT) || (parser->states[1].token == XS_TOKEN_YIELD))) {
1415
5.34k
      parser->states[0].token = XS_TOKEN_USING;
1416
5.34k
      if (blockIt <= 0)
1417
5.16k
        fxReportParserError(parser, parser->states[0].line, "no block");
1418
5.34k
      fxVariableStatement(parser, XS_TOKEN_USING, 0);
1419
5.34k
      fxSemicolon(parser);
1420
5.34k
      break;
1421
5.34k
    }
1422
828k
#endif
1423
    /* continue */
1424
828k
    mxFallThrough;
1425
1.29M
  default:
1426
1.29M
    if (gxTokenFlags[parser->states[0].token] & XS_TOKEN_BEGIN_EXPRESSION) {
1427
1.23M
      fxCommaExpression(parser);
1428
1.23M
      fxPushNodeStruct(parser, 1, XS_TOKEN_STATEMENT, line);
1429
1.23M
      fxSemicolon(parser);
1430
1.23M
    }
1431
53.0k
    else {
1432
53.0k
      fxReportParserError(parser, parser->states[0].line, "invalid token %s", gxTokenNames[parser->states[0].token]);
1433
53.0k
      fxPushNULL(parser);
1434
53.0k
      fxGetNextToken(parser);
1435
53.0k
    }
1436
1.29M
    break;
1437
1.94M
  }
1438
1.94M
}
1439
1440
void fxSemicolon(txParser* parser)
1441
1.11M
{
1442
1.11M
  if ((parser->states[0].crlf) || (gxTokenFlags[parser->states[0].token] & XS_TOKEN_END_STATEMENT)) {
1443
1.07M
    if (parser->states[0].token == XS_TOKEN_SEMICOLON)
1444
361k
      fxGetNextToken(parser);
1445
1.07M
  }
1446
45.1k
  else
1447
45.1k
    fxReportParserError(parser, parser->states[0].line, "missing ;");
1448
1.11M
}
1449
1450
void fxBreakStatement(txParser* parser)
1451
5.56k
{
1452
5.56k
  txInteger aLine = parser->states[0].line;
1453
5.56k
  fxMatchToken(parser, XS_TOKEN_BREAK);
1454
5.56k
  if ((!parser->states[0].crlf) && (parser->states[0].token == XS_TOKEN_IDENTIFIER)) {
1455
292
    fxPushSymbol(parser, parser->states[0].symbol);
1456
292
    fxGetNextToken(parser);
1457
292
  }
1458
5.26k
  else {
1459
5.26k
    fxPushNULL(parser);
1460
5.26k
  }
1461
5.56k
  fxPushNodeStruct(parser, 1, XS_TOKEN_BREAK, aLine);
1462
5.56k
}
1463
1464
void fxContinueStatement(txParser* parser)
1465
4.10k
{
1466
4.10k
  txInteger aLine = parser->states[0].line;
1467
4.10k
  fxMatchToken(parser, XS_TOKEN_CONTINUE);
1468
4.10k
  if ((!parser->states[0].crlf) && (parser->states[0].token == XS_TOKEN_IDENTIFIER)) {
1469
463
    fxPushSymbol(parser, parser->states[0].symbol);
1470
463
    fxGetNextToken(parser);
1471
463
  }
1472
3.64k
  else {
1473
3.64k
    fxPushNULL(parser);
1474
3.64k
  }
1475
4.10k
  fxPushNodeStruct(parser, 1, XS_TOKEN_CONTINUE, aLine);
1476
4.10k
}
1477
1478
void fxDebuggerStatement(txParser* parser)
1479
1.14k
{
1480
1.14k
  txInteger aLine = parser->states[0].line;
1481
1.14k
  fxMatchToken(parser, XS_TOKEN_DEBUGGER);
1482
1.14k
  fxPushNodeStruct(parser, 0, XS_TOKEN_DEBUGGER, aLine);
1483
1.14k
}
1484
1485
void fxDoStatement(txParser* parser)
1486
28.0k
{
1487
28.0k
  txInteger aLine = parser->states[0].line;
1488
28.0k
  fxCheckParserStack(parser, aLine);
1489
28.0k
  fxPushNULL(parser);
1490
28.0k
  fxMatchToken(parser, XS_TOKEN_DO);
1491
28.0k
  fxStatement(parser, 0);
1492
28.0k
  fxMatchToken(parser, XS_TOKEN_WHILE);
1493
28.0k
  fxMatchToken(parser, XS_TOKEN_LEFT_PARENTHESIS);
1494
28.0k
  fxCommaExpression(parser);
1495
28.0k
  fxMatchToken(parser, XS_TOKEN_RIGHT_PARENTHESIS);
1496
28.0k
  if (parser->states[0].token == XS_TOKEN_SEMICOLON)
1497
206
    fxGetNextToken(parser);
1498
28.0k
  fxPushNodeStruct(parser, 2, XS_TOKEN_DO, aLine);
1499
28.0k
  fxPushNodeStruct(parser, 2, XS_TOKEN_LABEL, aLine);
1500
28.0k
}
1501
1502
void fxForStatement(txParser* parser)
1503
51.9k
{
1504
51.9k
  txInteger aLine = parser->states[0].line;
1505
51.9k
  txBoolean awaitFlag = 0;
1506
51.9k
  txBoolean expressionFlag = 0;
1507
51.9k
  txToken aToken;
1508
51.9k
  fxPushNULL(parser);
1509
51.9k
  fxMatchToken(parser, XS_TOKEN_FOR);
1510
51.9k
  if (parser->states[0].token == XS_TOKEN_AWAIT) {
1511
12
    awaitFlag = 1;
1512
12
    fxMatchToken(parser, XS_TOKEN_AWAIT);
1513
12
  }
1514
51.9k
  fxMatchToken(parser, XS_TOKEN_LEFT_PARENTHESIS);
1515
51.9k
  fxLookAheadOnce(parser);
1516
51.9k
  parser->flags |= mxForFlag;
1517
51.9k
  if (parser->states[0].token == XS_TOKEN_SEMICOLON) {
1518
513
    fxPushNULL(parser);
1519
513
  }
1520
51.4k
  else if (parser->states[0].token == XS_TOKEN_CONST) {
1521
1.63k
    fxVariableStatement(parser, XS_TOKEN_CONST, 0);
1522
1.63k
  }
1523
49.8k
  else if (parser->states[0].token == XS_TOKEN_LET) {
1524
1.19k
    fxVariableStatement(parser, XS_TOKEN_LET, 0);
1525
1.19k
  }
1526
48.6k
  else if (fxIsKeyword(parser, parser->letSymbol) && (gxTokenFlags[parser->states[1].token] & XS_TOKEN_BEGIN_BINDING)) {
1527
11.2k
    parser->states[0].token = XS_TOKEN_LET;
1528
11.2k
    fxVariableStatement(parser, XS_TOKEN_LET, 0);
1529
11.2k
  }
1530
37.4k
#if mxExplicitResourceManagement
1531
37.4k
  else if ((parser->states[0].token == XS_TOKEN_IDENTIFIER) && (parser->states[0].symbol == parser->usingSymbol) && (!parser->states[0].escaped)
1532
6
        && (!parser->states[1].crlf) && ((parser->states[1].token == XS_TOKEN_IDENTIFIER) || (parser->states[1].token == XS_TOKEN_AWAIT) || (parser->states[1].token == XS_TOKEN_YIELD))) {
1533
3
    fxLookAheadTwice(parser);
1534
3
    if ((parser->states[1].symbol == parser->ofSymbol) && (!parser->states[1].escaped) && (parser->states[2].token != XS_TOKEN_ASSIGN)) {
1535
0
      fxCommaExpression(parser);
1536
0
      expressionFlag = 1;
1537
0
    }
1538
3
    else {
1539
3
      parser->states[0].token = XS_TOKEN_USING;
1540
3
      fxVariableStatement(parser, XS_TOKEN_USING, 0);
1541
3
    }
1542
3
  }
1543
37.4k
  else if ((parser->states[0].token == XS_TOKEN_AWAIT)
1544
95
        && (!parser->states[1].crlf) && (parser->states[1].token == XS_TOKEN_IDENTIFIER) && (parser->states[1].symbol == parser->usingSymbol) && (!parser->states[1].escaped)) {
1545
0
    fxLookAheadTwice(parser);
1546
0
    if ((!parser->states[2].crlf) && ((parser->states[2].token == XS_TOKEN_IDENTIFIER) || (parser->states[2].token == XS_TOKEN_AWAIT) || (parser->states[2].token == XS_TOKEN_YIELD))) {
1547
0
      fxGetNextToken(parser);
1548
0
      parser->states[0].token = XS_TOKEN_USING;
1549
0
      fxVariableStatement(parser, XS_TOKEN_USING, mxAwaitingFlag);
1550
0
      parser->flags |= mxAwaitingFlag;
1551
0
    }
1552
0
    else {
1553
0
      fxCommaExpression(parser);
1554
0
      expressionFlag = 1;
1555
0
    }
1556
0
  }
1557
37.4k
#endif
1558
37.4k
  else if (parser->states[0].token == XS_TOKEN_VAR) {
1559
15.2k
    fxVariableStatement(parser, XS_TOKEN_VAR, 0);
1560
15.2k
  }
1561
22.1k
  else {
1562
22.1k
    fxCommaExpression(parser);
1563
22.1k
    expressionFlag = 1;
1564
22.1k
  }
1565
51.9k
  parser->flags &= ~mxForFlag;
1566
51.9k
  if (awaitFlag && !fxIsKeyword(parser, parser->ofSymbol))
1567
1
    fxReportParserError(parser, parser->states[0].line, "invalid for await");
1568
51.9k
  if (fxIsToken(parser, XS_TOKEN_IN) || fxIsKeyword(parser, parser->ofSymbol)) {
1569
19.0k
    if (expressionFlag) {
1570
967
      if (!fxCheckReference(parser, XS_TOKEN_ASSIGN)) {
1571
3
        fxReportParserError(parser, parser->states[0].line, "no reference");
1572
3
      }
1573
967
    }
1574
18.1k
    else {
1575
18.1k
      aToken = parser->root->description->token;
1576
18.1k
      if (aToken == XS_TOKEN_BINDING) {
1577
1
        if (((txBindingNode*)(parser->root))->initializer)
1578
1
          fxReportParserError(parser, parser->states[0].line, "invalid binding initializer");
1579
1
      }
1580
18.1k
      if (fxIsToken(parser, XS_TOKEN_IN) && (aToken == XS_TOKEN_USING))
1581
0
        fxReportParserError(parser, parser->states[0].line, "invalid using in");
1582
      
1583
//      else if (aToken == XS_TOKEN_ARRAY_BINDING) {
1584
//        if (((txArrayBindingNode*)(parser->root))->initializer)
1585
//          fxReportParserError(parser, parser->states[0].line, "invalid array binding initializer");
1586
//      }
1587
//      else if (aToken == XS_TOKEN_OBJECT_BINDING) {
1588
//        if (((txObjectBindingNode*)(parser->root))->initializer)
1589
//          fxReportParserError(parser, parser->states[0].line, "invalid object binding initializer");
1590
//      }
1591
//      else
1592
//        fxReportParserError(parser, parser->states[0].line, "no reference %s", gxTokenNames[aToken]);
1593
18.1k
    }
1594
19.0k
    aToken = parser->states[0].token;
1595
19.0k
    fxGetNextToken(parser);
1596
19.0k
    if (aToken == XS_TOKEN_IN)
1597
11.4k
      fxCommaExpression(parser);
1598
7.65k
    else
1599
7.65k
      fxAssignmentExpression(parser);
1600
19.0k
    fxMatchToken(parser, XS_TOKEN_RIGHT_PARENTHESIS);
1601
19.0k
    fxStatement(parser, 0);
1602
19.0k
    if (awaitFlag) {
1603
10
      fxPushNodeStruct(parser, 3, XS_TOKEN_FOR_AWAIT_OF, aLine);
1604
10
      parser->flags |= mxAwaitingFlag;
1605
10
    }
1606
19.0k
    else if (aToken == XS_TOKEN_IN)
1607
11.1k
      fxPushNodeStruct(parser, 3, XS_TOKEN_FOR_IN, aLine);
1608
7.86k
    else
1609
7.86k
      fxPushNodeStruct(parser, 3, XS_TOKEN_FOR_OF, aLine);
1610
19.0k
  }
1611
32.8k
  else {
1612
32.8k
    if (expressionFlag)
1613
18.0k
      fxPushNodeStruct(parser, 1, XS_TOKEN_STATEMENT, aLine);
1614
32.8k
    fxMatchToken(parser, XS_TOKEN_SEMICOLON);
1615
32.8k
    if (gxTokenFlags[parser->states[0].token] & XS_TOKEN_BEGIN_EXPRESSION) {
1616
21.1k
      fxCommaExpression(parser);
1617
21.1k
    }
1618
11.7k
    else {
1619
11.7k
      fxPushNULL(parser);
1620
11.7k
    }
1621
32.8k
    fxMatchToken(parser, XS_TOKEN_SEMICOLON);
1622
32.8k
    if (gxTokenFlags[parser->states[0].token] & XS_TOKEN_BEGIN_EXPRESSION) {
1623
20.8k
      fxCommaExpression(parser);
1624
20.8k
    }
1625
12.0k
    else {
1626
12.0k
      fxPushNULL(parser);
1627
12.0k
    }
1628
32.8k
    fxMatchToken(parser, XS_TOKEN_RIGHT_PARENTHESIS);
1629
32.8k
    fxCheckParserStack(parser, aLine);
1630
32.8k
    fxStatement(parser, 0);
1631
32.8k
    fxPushNodeStruct(parser, 4, XS_TOKEN_FOR, aLine);
1632
32.8k
  }
1633
51.9k
  fxPushNodeStruct(parser, 2, XS_TOKEN_LABEL, aLine);
1634
51.9k
}
1635
1636
void fxIfStatement(txParser* parser)
1637
5.65k
{
1638
5.65k
  txInteger aLine = parser->states[0].line;
1639
5.65k
  fxMatchToken(parser, XS_TOKEN_IF);
1640
5.65k
  fxMatchToken(parser, XS_TOKEN_LEFT_PARENTHESIS);
1641
5.65k
  fxCommaExpression(parser);
1642
5.65k
  fxMatchToken(parser, XS_TOKEN_RIGHT_PARENTHESIS);
1643
5.65k
  fxStatement(parser, 0);
1644
5.65k
  if (parser->states[0].token == XS_TOKEN_ELSE) {
1645
808
    fxMatchToken(parser, XS_TOKEN_ELSE);
1646
808
    fxStatement(parser, 0);
1647
808
  }
1648
4.84k
  else {
1649
4.84k
    fxPushNULL(parser);
1650
4.84k
  }
1651
5.65k
  fxPushNodeStruct(parser, 3, XS_TOKEN_IF, aLine);
1652
5.65k
}
1653
1654
void fxReturnStatement(txParser* parser)
1655
11.0k
{
1656
11.0k
  txInteger aLine = parser->states[0].line;
1657
11.0k
  fxMatchToken(parser, XS_TOKEN_RETURN);
1658
11.0k
  if ((!parser->states[0].crlf) && (gxTokenFlags[parser->states[0].token] & XS_TOKEN_BEGIN_EXPRESSION)) {
1659
9.57k
    fxCommaExpression(parser);
1660
9.57k
  }
1661
1.45k
  else {
1662
1.45k
    fxPushNULL(parser);
1663
1.45k
  }
1664
11.0k
  fxPushNodeStruct(parser, 1, XS_TOKEN_RETURN, aLine);
1665
11.0k
}
1666
1667
void fxSwitchStatement(txParser* parser)
1668
8.91k
{
1669
8.91k
  txInteger aCount = 0;
1670
8.91k
  txBoolean aDefaultFlag = 0;
1671
8.91k
  txInteger aLine = parser->states[0].line;
1672
8.91k
  fxMatchToken(parser, XS_TOKEN_SWITCH);
1673
8.91k
  fxMatchToken(parser, XS_TOKEN_LEFT_PARENTHESIS);
1674
8.91k
  fxCommaExpression(parser);
1675
8.91k
  fxMatchToken(parser, XS_TOKEN_RIGHT_PARENTHESIS);
1676
8.91k
  fxMatchToken(parser, XS_TOKEN_LEFT_BRACE);
1677
15.8k
  while ((parser->states[0].token == XS_TOKEN_CASE) || (parser->states[0].token == XS_TOKEN_DEFAULT)) {
1678
6.92k
    txInteger aCaseCount;
1679
6.92k
    txInteger aCaseLine = parser->states[0].line;
1680
6.92k
    if (parser->states[0].token == XS_TOKEN_CASE) {
1681
6.29k
      fxMatchToken(parser, XS_TOKEN_CASE);
1682
6.29k
      fxCommaExpression(parser);
1683
6.29k
      fxMatchToken(parser, XS_TOKEN_COLON);
1684
6.29k
      aCaseCount = parser->nodeCount;
1685
10.9k
      while (gxTokenFlags[parser->states[0].token] & XS_TOKEN_BEGIN_STATEMENT)
1686
4.65k
        fxStatement(parser, -1);
1687
6.29k
      aCaseCount = parser->nodeCount - aCaseCount;
1688
6.29k
      if (aCaseCount > 1) {
1689
1.23k
        fxPushNodeList(parser, aCaseCount);
1690
1.23k
        fxPushNodeStruct(parser, 1, XS_TOKEN_STATEMENTS, aCaseLine);
1691
1.23k
      }
1692
5.05k
      else if (aCaseCount == 0) {
1693
2.96k
        fxPushNULL(parser);
1694
2.96k
      }
1695
6.29k
      fxPushNodeStruct(parser, 2, XS_TOKEN_CASE, aCaseLine);
1696
6.29k
    }
1697
635
    else {
1698
635
      fxMatchToken(parser, XS_TOKEN_DEFAULT);
1699
635
      if (aDefaultFlag) 
1700
1
        fxReportParserError(parser, parser->states[0].line, "invalid default");
1701
635
      fxPushNULL(parser);
1702
635
      fxMatchToken(parser, XS_TOKEN_COLON);
1703
635
      aCaseCount = parser->nodeCount;
1704
778
      while (gxTokenFlags[parser->states[0].token] & XS_TOKEN_BEGIN_STATEMENT)
1705
143
        fxStatement(parser, -1);
1706
635
      aCaseCount = parser->nodeCount - aCaseCount;
1707
635
      if (aCaseCount > 1) {
1708
11
        fxPushNodeList(parser, aCaseCount);
1709
11
        fxPushNodeStruct(parser, 1, XS_TOKEN_STATEMENTS, aLine);
1710
11
      }
1711
624
      else if (aCaseCount == 0) {
1712
2
        fxPushNULL(parser);
1713
2
      }
1714
635
      fxPushNodeStruct(parser, 2, XS_TOKEN_CASE, aCaseLine);
1715
635
      aDefaultFlag = 1;
1716
635
    }
1717
6.92k
    aCount++;
1718
6.92k
  }
1719
8.91k
  fxMatchToken(parser, XS_TOKEN_RIGHT_BRACE);
1720
8.91k
  fxPushNodeList(parser, aCount);
1721
8.91k
  fxPushNodeStruct(parser, 2, XS_TOKEN_SWITCH, aLine);
1722
8.91k
}
1723
1724
void fxThrowStatement(txParser* parser)
1725
24.9k
{
1726
24.9k
  txInteger aLine = parser->states[0].line;
1727
24.9k
  fxMatchToken(parser, XS_TOKEN_THROW);
1728
24.9k
  if ((!parser->states[0].crlf) && (gxTokenFlags[parser->states[0].token] & XS_TOKEN_BEGIN_EXPRESSION)) {
1729
23.6k
    fxCommaExpression(parser);
1730
23.6k
  }
1731
1.29k
  else {
1732
1.29k
    fxReportParserError(parser, parser->states[0].line, "missing expression");
1733
1.29k
    fxPushNodeStruct(parser, 0, XS_TOKEN_UNDEFINED, aLine);
1734
1.29k
  }
1735
24.9k
  fxPushNodeStruct(parser, 1, XS_TOKEN_THROW, aLine);
1736
24.9k
}
1737
1738
void fxTryStatement(txParser* parser)
1739
7.25k
{
1740
7.25k
  txInteger aLine = parser->states[0].line;
1741
7.25k
  txBoolean ok = 0;
1742
7.25k
  fxMatchToken(parser, XS_TOKEN_TRY);
1743
7.25k
  fxBlock(parser);
1744
7.25k
  if (parser->states[0].token == XS_TOKEN_CATCH) {
1745
3.88k
    txInteger aCatchLine = parser->states[0].line;
1746
3.88k
    fxMatchToken(parser, XS_TOKEN_CATCH);
1747
3.88k
    if (parser->states[0].token == XS_TOKEN_LEFT_PARENTHESIS) {
1748
3.07k
      fxMatchToken(parser, XS_TOKEN_LEFT_PARENTHESIS);
1749
3.07k
      fxBinding(parser, XS_TOKEN_LET, 1);
1750
3.07k
      fxMatchToken(parser, XS_TOKEN_RIGHT_PARENTHESIS);
1751
3.07k
    }
1752
813
    else
1753
813
      fxPushNULL(parser);
1754
3.88k
    fxMatchToken(parser, XS_TOKEN_LEFT_BRACE);
1755
3.88k
    fxStatements(parser);
1756
3.88k
    fxMatchToken(parser, XS_TOKEN_RIGHT_BRACE);
1757
3.88k
    fxPushNodeStruct(parser, 2, XS_TOKEN_CATCH, aCatchLine);
1758
3.88k
    ok = 1;
1759
3.88k
  }
1760
3.37k
  else {
1761
3.37k
    fxPushNULL(parser);
1762
3.37k
  }
1763
7.25k
  if (parser->states[0].token == XS_TOKEN_FINALLY) {
1764
95
    fxMatchToken(parser, XS_TOKEN_FINALLY);
1765
95
    fxBlock(parser);
1766
95
    ok = 1;
1767
95
  }
1768
7.16k
  else {
1769
7.16k
    fxPushNULL(parser);
1770
7.16k
  }
1771
7.25k
  if (!ok)
1772
1.29k
    fxReportParserError(parser, parser->states[0].line, "missing catch or finally");
1773
7.25k
  fxPushNodeStruct(parser, 3, XS_TOKEN_TRY, aLine);
1774
7.25k
}
1775
1776
void fxVariableStatement(txParser* parser, txToken theToken, txUnsigned flags)
1777
174k
{
1778
174k
  txBoolean commaFlag = 0;
1779
174k
  txInteger aCount = 0;
1780
174k
  txInteger aLine = parser->states[0].line;
1781
174k
  fxMatchToken(parser, theToken);
1782
177k
  while (gxTokenFlags[parser->states[0].token] & XS_TOKEN_BEGIN_BINDING) {
1783
174k
    commaFlag = 0;
1784
174k
    fxBinding(parser, theToken, 1 | flags);
1785
//    if (parser->states[0].token == XS_TOKEN_ASSIGN) {
1786
//      parser->flags &= ~mxForFlag;
1787
//      fxGetNextToken(parser);
1788
//      fxAssignmentExpression(parser);
1789
//      fxPushNodeStruct(parser, 2, XS_TOKEN_ASSIGN, aLine);
1790
//      fxPushNodeStruct(parser, 1, XS_TOKEN_STATEMENT, aLine);
1791
//    }
1792
174k
    aCount++;
1793
174k
    if (parser->states[0].token == XS_TOKEN_COMMA) {
1794
3.20k
      parser->flags &= ~mxForFlag;
1795
3.20k
      fxGetNextToken(parser);
1796
3.20k
      commaFlag = 1;
1797
3.20k
    }
1798
170k
    else
1799
170k
      break;
1800
174k
  }
1801
174k
    if ((aCount == 0) || commaFlag) {
1802
1.99k
    fxPushNULL(parser);
1803
1.99k
    fxPushNULL(parser);
1804
1.99k
    fxPushNodeStruct(parser, 2, theToken, aLine);
1805
1.99k
    fxReportParserError(parser, parser->states[0].line, "missing identifier");
1806
1.99k
  }
1807
174k
  if (aCount > 1) {
1808
1.99k
    fxPushNodeList(parser, aCount);
1809
1.99k
    fxPushNodeStruct(parser, 1, XS_TOKEN_STATEMENTS, aLine);
1810
1.99k
  }
1811
174k
}
1812
1813
void fxWhileStatement(txParser* parser)
1814
547
{
1815
547
  txInteger aLine = parser->states[0].line;
1816
547
  fxPushNULL(parser);
1817
547
  fxMatchToken(parser, XS_TOKEN_WHILE);
1818
547
  fxMatchToken(parser, XS_TOKEN_LEFT_PARENTHESIS);
1819
547
  fxCommaExpression(parser);
1820
547
  fxMatchToken(parser, XS_TOKEN_RIGHT_PARENTHESIS);
1821
547
  fxStatement(parser, 0);
1822
547
  fxPushNodeStruct(parser, 2, XS_TOKEN_WHILE, aLine);
1823
547
  fxPushNodeStruct(parser, 2, XS_TOKEN_LABEL, aLine);
1824
547
}
1825
1826
void fxWithStatement(txParser* parser)
1827
3.78k
{
1828
3.78k
  txInteger aLine = parser->states[0].line;
1829
3.78k
  fxMatchToken(parser, XS_TOKEN_WITH);
1830
3.78k
  fxMatchToken(parser, XS_TOKEN_LEFT_PARENTHESIS);
1831
3.78k
  fxCommaExpression(parser);
1832
3.78k
  fxMatchToken(parser, XS_TOKEN_RIGHT_PARENTHESIS);
1833
3.78k
  fxStatement(parser, 0);
1834
3.78k
  fxPushNodeStruct(parser, 2, XS_TOKEN_WITH, aLine);
1835
3.78k
}
1836
1837
void fxCommaExpression(txParser* parser)
1838
1.39M
{
1839
1.39M
  txInteger aCount = 0;
1840
1.39M
  txInteger aLine = parser->states[0].line;
1841
1.39M
  if (gxTokenFlags[parser->states[0].token] & XS_TOKEN_BEGIN_EXPRESSION) {
1842
1.39M
    fxAssignmentExpression(parser);
1843
1.39M
    aCount++;
1844
1.46M
    while (parser->states[0].token == XS_TOKEN_COMMA) {
1845
62.8k
      fxGetNextToken(parser);
1846
62.8k
      fxAssignmentExpression(parser);
1847
62.8k
      aCount++;
1848
62.8k
    }
1849
1.39M
  }
1850
1.39M
  if (aCount > 1) {
1851
40.6k
    fxPushNodeList(parser, aCount);
1852
40.6k
    fxPushNodeStruct(parser, 1, XS_TOKEN_EXPRESSIONS, aLine);
1853
40.6k
  }
1854
1.35M
  else if (aCount == 0) {
1855
2.35k
    fxPushNULL(parser);
1856
2.35k
    fxReportParserError(parser, parser->states[0].line, "missing expression");
1857
2.35k
  }
1858
1.39M
}
1859
1860
void fxAssignmentExpression(txParser* parser)
1861
2.91M
{
1862
2.91M
  fxCheckParserStack(parser, parser->states[0].line);
1863
2.91M
  if (parser->states[0].token == XS_TOKEN_YIELD)
1864
31.0k
    fxYieldExpression(parser);
1865
2.87M
  else {
1866
2.87M
    fxConditionalExpression(parser);
1867
3.02M
    while (gxTokenFlags[parser->states[0].token] & XS_TOKEN_ASSIGN_EXPRESSION) {
1868
149k
      txToken aToken = parser->states[0].token;
1869
149k
      txInteger aLine = parser->states[0].line;
1870
149k
      if (!fxCheckReference(parser, aToken)) 
1871
7.23k
        fxReportParserError(parser, parser->states[0].line, "no reference");
1872
149k
      fxGetNextToken(parser);
1873
149k
      fxAssignmentExpression(parser);
1874
149k
      fxPushNodeStruct(parser, 2, aToken, aLine);
1875
149k
    }
1876
2.87M
  }
1877
2.91M
}
1878
1879
void fxConditionalExpression(txParser* parser)
1880
2.87M
{
1881
2.87M
  fxCoalesceExpression(parser);
1882
2.87M
  if (parser->states[0].token == XS_TOKEN_QUESTION_MARK) {
1883
7.57k
    txInteger aLine = parser->states[0].line;
1884
7.57k
    txUnsigned flags;
1885
7.57k
    fxCheckArrowFunction(parser, 1);
1886
7.57k
    fxGetNextToken(parser);
1887
7.57k
    flags = parser->flags & mxForFlag;
1888
7.57k
    parser->flags &= ~mxForFlag;
1889
7.57k
    fxAssignmentExpression(parser);
1890
7.57k
    parser->flags |= flags;
1891
7.57k
    fxMatchToken(parser, XS_TOKEN_COLON);
1892
7.57k
    fxAssignmentExpression(parser);
1893
7.57k
    fxPushNodeStruct(parser, 3, XS_TOKEN_QUESTION_MARK, aLine);
1894
7.57k
  }
1895
2.87M
}
1896
1897
void fxCoalesceExpression(txParser* parser)
1898
2.87M
{
1899
2.87M
  fxOrExpression(parser);
1900
2.88M
  while (parser->states[0].token == XS_TOKEN_COALESCE) {
1901
4.25k
    txInteger aLine = parser->states[0].line;
1902
4.25k
    fxGetNextToken(parser);
1903
4.25k
    fxOrExpression(parser);
1904
4.25k
    fxCheckArrowFunction(parser, 2);
1905
4.25k
    fxPushNodeStruct(parser, 2, XS_TOKEN_COALESCE, aLine);
1906
4.25k
  }
1907
2.87M
}
1908
1909
void fxOrExpression(txParser* parser)
1910
2.88M
{
1911
2.88M
  fxAndExpression(parser);
1912
2.89M
  while (parser->states[0].token == XS_TOKEN_OR) {
1913
7.65k
    txInteger aLine = parser->states[0].line;
1914
7.65k
    fxGetNextToken(parser);
1915
7.65k
    fxAndExpression(parser);
1916
7.65k
    fxCheckArrowFunction(parser, 2);
1917
7.65k
    fxPushNodeStruct(parser, 2, XS_TOKEN_OR, aLine);
1918
7.65k
  }
1919
2.88M
}
1920
1921
void fxAndExpression(txParser* parser)
1922
2.89M
{
1923
2.89M
  fxBitOrExpression(parser);
1924
2.89M
  while (parser->states[0].token == XS_TOKEN_AND) {
1925
5.59k
    txInteger aLine = parser->states[0].line;
1926
5.59k
    fxGetNextToken(parser);
1927
5.59k
    fxBitOrExpression(parser);
1928
5.59k
    fxCheckArrowFunction(parser, 2);
1929
5.59k
    fxPushNodeStruct(parser, 2, XS_TOKEN_AND, aLine);
1930
5.59k
  }
1931
2.89M
}
1932
1933
void fxBitOrExpression(txParser* parser)
1934
2.89M
{
1935
2.89M
  fxBitXorExpression(parser);
1936
2.90M
  while (parser->states[0].token == XS_TOKEN_BIT_OR) {
1937
10.1k
    txInteger aLine = parser->states[0].line;
1938
10.1k
    fxGetNextToken(parser);
1939
10.1k
    fxBitXorExpression(parser);
1940
10.1k
    fxCheckArrowFunction(parser, 2);
1941
10.1k
    fxPushNodeStruct(parser, 2, XS_TOKEN_BIT_OR, aLine);
1942
10.1k
  }
1943
2.89M
}
1944
1945
void fxBitXorExpression(txParser* parser)
1946
2.90M
{
1947
2.90M
  fxBitAndExpression(parser);
1948
2.90M
  while (parser->states[0].token == XS_TOKEN_BIT_XOR) {
1949
3.60k
    txInteger aLine = parser->states[0].line;
1950
3.60k
    fxGetNextToken(parser);
1951
3.60k
    fxBitAndExpression(parser);
1952
3.60k
    fxCheckArrowFunction(parser, 2);
1953
3.60k
    fxPushNodeStruct(parser, 2, XS_TOKEN_BIT_XOR, aLine);
1954
3.60k
  }
1955
2.90M
}
1956
1957
void fxBitAndExpression(txParser* parser)
1958
2.90M
{
1959
2.90M
  fxEqualExpression(parser);
1960
2.92M
  while (parser->states[0].token == XS_TOKEN_BIT_AND) {
1961
19.5k
    txInteger aLine = parser->states[0].line;
1962
19.5k
    fxGetNextToken(parser);
1963
19.5k
    fxEqualExpression(parser);
1964
19.5k
    fxCheckArrowFunction(parser, 2);
1965
19.5k
    fxPushNodeStruct(parser, 2, XS_TOKEN_BIT_AND, aLine);
1966
19.5k
  }
1967
2.90M
}
1968
1969
void fxEqualExpression(txParser* parser)
1970
2.92M
{
1971
2.92M
  fxRelationalExpression(parser);
1972
2.93M
  while (gxTokenFlags[parser->states[0].token] & XS_TOKEN_EQUAL_EXPRESSION) {
1973
7.67k
    txToken aToken = parser->states[0].token;
1974
7.67k
    txInteger aLine = parser->states[0].line;
1975
7.67k
    fxGetNextToken(parser);
1976
7.67k
    fxRelationalExpression(parser);
1977
7.67k
    fxCheckArrowFunction(parser, 2);
1978
7.67k
    fxPushNodeStruct(parser, 2, aToken, aLine);
1979
7.67k
  }
1980
2.92M
}
1981
1982
void fxRelationalExpression(txParser* parser)
1983
2.93M
{
1984
2.93M
  if (parser->states[0].token == XS_TOKEN_PRIVATE_IDENTIFIER) {
1985
2.64k
    txInteger aLine = parser->states[0].line;
1986
2.64k
    fxPushSymbol(parser, parser->states[0].symbol);
1987
2.64k
    fxGetNextToken(parser);
1988
2.64k
    fxMatchToken(parser, XS_TOKEN_IN);
1989
2.64k
    if (parser->flags & mxForFlag)
1990
1
      fxReportParserError(parser, parser->states[0].line, "invalid %s", gxTokenNames[XS_TOKEN_IN]);
1991
2.64k
    fxShiftExpression(parser);
1992
2.64k
    fxCheckArrowFunction(parser, 2);
1993
2.64k
    fxPushNodeStruct(parser, 2, XS_TOKEN_PRIVATE_IDENTIFIER, aLine);
1994
2.64k
  }
1995
2.93M
  else {
1996
2.93M
    fxShiftExpression(parser);
1997
2.93M
    if ((parser->flags & mxForFlag) && ((parser->states[0].token == XS_TOKEN_IN) || fxIsKeyword(parser, parser->ofSymbol)))
1998
967
      return;
1999
2.99M
    while (gxTokenFlags[parser->states[0].token] & XS_TOKEN_RELATIONAL_EXPRESSION) {
2000
66.9k
      txToken aToken = parser->states[0].token;
2001
66.9k
      txInteger aLine = parser->states[0].line;
2002
66.9k
      fxMatchToken(parser, aToken);
2003
66.9k
      fxShiftExpression(parser);
2004
66.9k
      fxCheckArrowFunction(parser, 2);
2005
66.9k
      fxPushNodeStruct(parser, 2, aToken, aLine);
2006
66.9k
    }
2007
2.93M
  }
2008
2.93M
}
2009
2010
void fxShiftExpression(txParser* parser)
2011
2.99M
{
2012
2.99M
  fxAdditiveExpression(parser);
2013
3.02M
  while (gxTokenFlags[parser->states[0].token] & XS_TOKEN_SHIFT_EXPRESSION) {
2014
24.2k
    txToken aToken = parser->states[0].token;
2015
24.2k
    txInteger aLine = parser->states[0].line;
2016
24.2k
    fxGetNextToken(parser);
2017
24.2k
    fxAdditiveExpression(parser);
2018
24.2k
    fxCheckArrowFunction(parser, 2);
2019
24.2k
    fxPushNodeStruct(parser, 2, aToken, aLine);
2020
24.2k
  }
2021
2.99M
}
2022
2023
void fxAdditiveExpression(txParser* parser)
2024
3.02M
{
2025
3.02M
  fxMultiplicativeExpression(parser);
2026
15.8M
  while (gxTokenFlags[parser->states[0].token] & XS_TOKEN_ADDITIVE_EXPRESSION) {
2027
12.8M
    txToken aToken = parser->states[0].token;
2028
12.8M
    txInteger aLine = parser->states[0].line;
2029
12.8M
    fxGetNextToken(parser);
2030
12.8M
    fxMultiplicativeExpression(parser);
2031
12.8M
    fxCheckArrowFunction(parser, 2);
2032
12.8M
    fxPushNodeStruct(parser, 2, aToken, aLine);
2033
12.8M
  }
2034
3.02M
}
2035
2036
void fxMultiplicativeExpression(txParser* parser)
2037
15.8M
{
2038
15.8M
  fxExponentiationExpression(parser);
2039
15.9M
  while (gxTokenFlags[parser->states[0].token] & XS_TOKEN_MULTIPLICATIVE_EXPRESSION) {
2040
120k
    txToken aToken = parser->states[0].token;
2041
120k
    txInteger aLine = parser->states[0].line;
2042
120k
    fxGetNextToken(parser);
2043
120k
    fxExponentiationExpression(parser);
2044
120k
    fxCheckArrowFunction(parser, 2);
2045
120k
    fxPushNodeStruct(parser, 2, aToken, aLine);
2046
120k
  }
2047
15.8M
}
2048
2049
void fxExponentiationExpression(txParser* parser)
2050
15.9M
{
2051
15.9M
  if (gxTokenFlags[parser->states[0].token] & XS_TOKEN_UNARY_EXPRESSION)
2052
111k
    fxUnaryExpression(parser);
2053
15.8M
  else {
2054
15.8M
    fxPrefixExpression(parser);
2055
15.8M
    if (gxTokenFlags[parser->states[0].token] & XS_TOKEN_EXPONENTIATION_EXPRESSION) {
2056
2.87k
      txToken aToken = parser->states[0].token;
2057
2.87k
      txInteger aLine = parser->states[0].line;
2058
2.87k
      fxGetNextToken(parser);
2059
2.87k
            fxExponentiationExpression(parser);
2060
2.87k
      fxCheckArrowFunction(parser, 2);
2061
2.87k
      fxPushNodeStruct(parser, 2, aToken, aLine);
2062
2.87k
    }
2063
15.8M
  }
2064
15.9M
}
2065
2066
void fxUnaryExpression(txParser* parser)
2067
395k
{
2068
395k
  if (gxTokenFlags[parser->states[0].token] & XS_TOKEN_UNARY_EXPRESSION) {
2069
285k
    txToken aToken = parser->states[0].token;
2070
285k
    txInteger aLine = parser->states[0].line;
2071
285k
    fxCheckParserStack(parser, aLine);
2072
285k
    fxMatchToken(parser, aToken);
2073
285k
    fxUnaryExpression(parser);
2074
285k
    fxCheckArrowFunction(parser, 1);
2075
285k
    if (aToken == XS_TOKEN_ADD)
2076
9.77k
      fxPushNodeStruct(parser, 1, XS_TOKEN_PLUS, aLine);
2077
276k
    else if (aToken == XS_TOKEN_SUBTRACT)
2078
50.2k
      fxPushNodeStruct(parser, 1, XS_TOKEN_MINUS, aLine);
2079
225k
    else if (aToken == XS_TOKEN_DELETE) {
2080
      //if ((parser->flags & mxStrictFlag) && (parser->root->description->token == XS_TOKEN_ACCESS)) {
2081
      //  fxReportParserError(parser, parser->states[0].line, "no reference (strict mode)");
2082
      //}
2083
15.8k
      if (!fxCheckReference(parser, aToken)) 
2084
0
        fxReportParserError(parser, parser->states[0].line, "no reference");
2085
15.8k
      fxPushNodeStruct(parser, 1, aToken, aLine);
2086
15.8k
    }
2087
210k
    else if (aToken == XS_TOKEN_AWAIT) {
2088
1.11k
      if ((parser->flags & mxGeneratorFlag) && !(parser->flags & mxYieldFlag))
2089
3
        fxReportParserError(parser, parser->states[0].line, "invalid await");
2090
1.11k
      else
2091
1.11k
        parser->flags |= mxAwaitingFlag;
2092
1.11k
      fxPushNodeStruct(parser, 1, aToken, aLine);
2093
1.11k
    }
2094
208k
    else
2095
208k
      fxPushNodeStruct(parser, 1, aToken, aLine);
2096
      
2097
285k
  }
2098
109k
  else
2099
109k
    fxPrefixExpression(parser);
2100
395k
}
2101
2102
void fxPrefixExpression(txParser* parser)
2103
16.1M
{
2104
16.1M
  if (gxTokenFlags[parser->states[0].token] & XS_TOKEN_PREFIX_EXPRESSION) {
2105
219k
    txToken aToken = parser->states[0].token;
2106
219k
    txInteger aLine = parser->states[0].line;
2107
219k
    fxCheckParserStack(parser, aLine);
2108
219k
    fxGetNextToken(parser);
2109
219k
    fxPrefixExpression(parser);
2110
219k
    fxCheckArrowFunction(parser, 1);
2111
219k
    if (!fxCheckReference(parser, aToken)) 
2112
898
      fxReportParserError(parser, parser->states[0].line, "no reference");
2113
219k
    fxPushNodeStruct(parser, 1, aToken, aLine);
2114
219k
    parser->root->flags = mxExpressionNoValue;
2115
219k
  }
2116
15.9M
  else
2117
15.9M
    fxPostfixExpression(parser);
2118
16.1M
}
2119
2120
void fxPostfixExpression(txParser* parser)
2121
15.9M
{
2122
15.9M
  fxCallExpression(parser);
2123
15.9M
  if ((!parser->states[0].crlf) && (gxTokenFlags[parser->states[0].token] & XS_TOKEN_POSTFIX_EXPRESSION)) {
2124
21.7k
    fxCheckArrowFunction(parser, 1);
2125
21.7k
    if (!fxCheckReference(parser, parser->states[0].token)) 
2126
427
      fxReportParserError(parser, parser->states[0].line, "no reference");
2127
21.7k
    fxPushNodeStruct(parser, 1, parser->states[0].token, parser->states[0].line);
2128
21.7k
    fxGetNextToken(parser);
2129
21.7k
  }
2130
15.9M
}
2131
2132
void fxCallExpression(txParser* parser)
2133
15.9M
{
2134
15.9M
  txInteger chainLine = parser->states[0].line;
2135
15.9M
  fxLiteralExpression(parser, 0);
2136
15.9M
  if (gxTokenFlags[parser->states[0].token] & XS_TOKEN_CALL_EXPRESSION) {
2137
474k
    txBoolean chainFlag = 0;
2138
474k
    fxCheckArrowFunction(parser, 1);
2139
1.36M
    for (;;) {
2140
1.36M
      txInteger aLine = parser->states[0].line;
2141
1.36M
      if (parser->states[0].token == XS_TOKEN_DOT) {
2142
376k
        fxGetNextToken(parser);
2143
376k
        if (parser->states[0].token == XS_TOKEN_IDENTIFIER) {
2144
357k
          fxPushSymbol(parser, parser->states[0].symbol);
2145
357k
          fxPushNodeStruct(parser, 2, XS_TOKEN_MEMBER, aLine);
2146
357k
          fxGetNextToken(parser);
2147
357k
        }
2148
18.5k
        else if (parser->states[0].token == XS_TOKEN_PRIVATE_IDENTIFIER) {
2149
17.4k
          if (parser->root->flags & mxSuperFlag)
2150
0
            fxReportParserError(parser, parser->states[0].line, "invalid super");
2151
17.4k
          fxPushSymbol(parser, parser->states[0].symbol);
2152
17.4k
          fxSwapNodes(parser);
2153
17.4k
          fxPushNodeStruct(parser, 2, XS_TOKEN_PRIVATE_MEMBER, aLine);
2154
17.4k
          fxGetNextToken(parser);
2155
17.4k
        }
2156
1.09k
        else
2157
1.09k
          fxReportParserError(parser, parser->states[0].line, "missing property");
2158
376k
      }
2159
      //else if (parser->states[0].crlf)
2160
      //  break;
2161
987k
      else if (parser->states[0].token == XS_TOKEN_LEFT_BRACKET) {
2162
18.9k
        fxGetNextToken(parser);
2163
18.9k
        fxCommaExpression(parser);
2164
18.9k
        fxPushNodeStruct(parser, 2, XS_TOKEN_MEMBER_AT, aLine);
2165
18.9k
        fxMatchToken(parser, XS_TOKEN_RIGHT_BRACKET);
2166
18.9k
      }
2167
968k
      else if (parser->states[0].token == XS_TOKEN_LEFT_PARENTHESIS) {
2168
324k
        txUnsigned nativeFlags = 0;
2169
324k
        txAccessNode* access = NULL;
2170
324k
        if (parser->root->description && (parser->root->description->token == XS_TOKEN_ACCESS)) {
2171
90.7k
          access = (txAccessNode*)parser->root;
2172
90.7k
          if (access->symbol == parser->evalSymbol) {
2173
4.49k
            parser->flags |= mxEvalFlag;
2174
4.49k
          }
2175
86.2k
          else if (parser->flags & mxCFlag) {
2176
0
            if (access->symbol == parser->NativeSymbol) {
2177
0
              nativeFlags = mxNativeConstructorFlag;
2178
0
            }
2179
0
            else if (access->symbol == parser->nativeSymbol) {
2180
0
              nativeFlags = mxNativeFunctionFlag;
2181
0
              parser->flags |= mxNativeFlag;
2182
0
            }
2183
0
          }
2184
90.7k
        }
2185
324k
        fxParameters(parser);
2186
324k
        if (nativeFlags) {
2187
0
          txParamsNode* params = (txParamsNode*)parser->root;
2188
0
          if (params->items->length == 0)
2189
0
             fxReportParserError(parser, aLine, "%s: no argument", access->symbol->string);
2190
0
          if (params->items->length > 1)
2191
0
             fxReportParserError(parser, aLine, "%s: too many arguments", access->symbol->string);
2192
0
          txStringNode* param = (txStringNode*)(params->items->first);
2193
0
          if (param->description->token != XS_TOKEN_STRING)
2194
0
             fxReportParserError(parser, aLine, "%s: argument is no string literal", access->symbol->string);
2195
0
          fxPopNode(parser);
2196
0
          fxPopNode(parser);
2197
0
          if (nativeFlags & mxNativeFunctionFlag) {
2198
0
            fxPushNULL(parser);
2199
0
            fxPushNodeList(parser, 0);
2200
0
            fxPushNodeStruct(parser, 1, XS_TOKEN_PARAMS_BINDING, aLine);
2201
0
            fxPushStringNode(parser, param->length, param->value, aLine);
2202
0
            fxPushNodeStruct(parser, 3, XS_TOKEN_HOST, aLine);
2203
0
          }
2204
0
          else {
2205
0
            fxPushNULL(parser);
2206
2207
0
            fxPushNULL(parser);
2208
0
            fxPushNULL(parser);
2209
0
            fxPushStringNode(parser, param->length, param->value, aLine);
2210
0
            fxPushNodeStruct(parser, 3, XS_TOKEN_HOST, aLine);
2211
            
2212
0
            fxPushNodeList(parser, 0);
2213
            
2214
0
            fxPushNULL(parser);
2215
0
            fxPushNULL(parser);
2216
            
2217
0
            fxPushNULL(parser);
2218
0
            fxPushNodeList(parser, 0);
2219
0
            fxPushNodeStruct(parser, 1, XS_TOKEN_PARAMS_BINDING, aLine);
2220
0
            fxPushNodeStruct(parser, 0, XS_TOKEN_UNDEFINED, aLine);
2221
0
            fxPushNodeStruct(parser, 1, XS_TOKEN_STATEMENT, aLine);
2222
0
            fxPushNodeStruct(parser, 1, XS_TOKEN_BODY, aLine);
2223
0
            fxPushNodeStruct(parser, 3, XS_TOKEN_FUNCTION, aLine);
2224
0
            parser->root->flags = mxStrictFlag | mxBaseFlag | mxMethodFlag | mxTargetFlag;
2225
            
2226
0
            fxPushNodeStruct(parser, 6, XS_TOKEN_CLASS, aLine);
2227
0
          }
2228
0
        }
2229
324k
        else
2230
324k
          fxPushNodeStruct(parser, 2, XS_TOKEN_CALL, aLine);
2231
324k
      }
2232
643k
      else if (parser->states[0].token == XS_TOKEN_TEMPLATE) {
2233
236k
        if (chainFlag)
2234
1
          fxReportParserError(parser, parser->states[0].line, "invalid template");
2235
236k
        fxPushStringNode(parser, parser->states[0].stringLength, parser->states[0].string, aLine);
2236
236k
        fxPushRawNode(parser, parser->states[0].rawLength, parser->states[0].raw, aLine);
2237
236k
        fxPushNodeStruct(parser, 2, XS_TOKEN_TEMPLATE_MIDDLE, aLine);
2238
236k
        fxGetNextToken(parser);
2239
236k
        fxPushNodeList(parser, 1);
2240
236k
        fxPushNodeStruct(parser, 2, XS_TOKEN_TEMPLATE, aLine);
2241
236k
      }
2242
407k
      else if (parser->states[0].token == XS_TOKEN_TEMPLATE_HEAD) {
2243
334
        if (chainFlag)
2244
1
          fxReportParserError(parser, parser->states[0].line, "invalid template");
2245
334
        fxTemplateExpression(parser);
2246
334
        fxPushNodeStruct(parser, 2, XS_TOKEN_TEMPLATE, aLine);
2247
334
      }
2248
406k
      else if (parser->states[0].token == XS_TOKEN_CHAIN) {
2249
13.6k
        fxGetNextToken(parser);
2250
13.6k
        chainFlag = 1;
2251
13.6k
        if (parser->states[0].token == XS_TOKEN_IDENTIFIER) {
2252
8.74k
          fxPushNodeStruct(parser, 1, XS_TOKEN_OPTION, aLine);
2253
8.74k
          fxPushSymbol(parser, parser->states[0].symbol);
2254
8.74k
          fxPushNodeStruct(parser, 2, XS_TOKEN_MEMBER, aLine);
2255
8.74k
          fxGetNextToken(parser);
2256
8.74k
        }
2257
4.87k
        else if (parser->states[0].token == XS_TOKEN_PRIVATE_IDENTIFIER) {
2258
759
          fxPushNodeStruct(parser, 1, XS_TOKEN_OPTION, aLine);
2259
759
          fxPushSymbol(parser, parser->states[0].symbol);
2260
759
          fxSwapNodes(parser);
2261
759
          fxPushNodeStruct(parser, 2, XS_TOKEN_PRIVATE_MEMBER, aLine);
2262
759
          fxGetNextToken(parser);
2263
759
        }
2264
4.11k
        else if (parser->states[0].token == XS_TOKEN_LEFT_BRACKET) {
2265
378
          fxPushNodeStruct(parser, 1, XS_TOKEN_OPTION, aLine);
2266
378
          fxGetNextToken(parser);
2267
378
          fxCommaExpression(parser);
2268
378
          fxPushNodeStruct(parser, 2, XS_TOKEN_MEMBER_AT, aLine);
2269
378
          fxMatchToken(parser, XS_TOKEN_RIGHT_BRACKET);
2270
378
        }
2271
3.74k
        else if (parser->states[0].token == XS_TOKEN_LEFT_PARENTHESIS) {
2272
2.45k
          fxPushNodeStruct(parser, 1, XS_TOKEN_OPTION, aLine);
2273
2.45k
          fxParameters(parser);
2274
2.45k
          fxPushNodeStruct(parser, 2, XS_TOKEN_CALL, aLine);
2275
2.45k
        }
2276
1.28k
        else
2277
1.28k
          fxReportParserError(parser, parser->states[0].line, "invalid ?.");
2278
13.6k
      }
2279
393k
      else
2280
393k
        break;
2281
1.36M
    } 
2282
474k
    if (chainFlag)
2283
12.0k
      fxPushNodeStruct(parser, 1, XS_TOKEN_CHAIN, chainLine);
2284
474k
  } 
2285
15.9M
}
2286
2287
void fxLiteralExpression(txParser* parser, txUnsigned flag)
2288
15.9M
{
2289
15.9M
  int escaped;
2290
15.9M
  txSymbol* aSymbol;
2291
15.9M
  txInteger aLine = parser->states[0].line;
2292
15.9M
  txUnsigned flags = 0;
2293
15.9M
  char c = 0;
2294
15.9M
  fxCheckParserStack(parser, aLine);
2295
15.9M
  switch (parser->states[0].token) {
2296
10.9k
  case XS_TOKEN_NULL:
2297
19.8k
  case XS_TOKEN_TRUE:
2298
25.8k
  case XS_TOKEN_FALSE:
2299
25.8k
    fxPushNodeStruct(parser, 0, parser->states[0].token, aLine);
2300
25.8k
    fxMatchToken(parser, parser->states[0].token);
2301
25.8k
    break;
2302
7.98k
  case XS_TOKEN_IMPORT:
2303
7.98k
    fxMatchToken(parser, XS_TOKEN_IMPORT);
2304
7.98k
    if (!flag && (parser->states[0].token == XS_TOKEN_LEFT_PARENTHESIS)) {
2305
3.67k
      txUnsigned flags = parser->flags & mxForFlag;
2306
3.67k
      fxGetNextToken(parser);
2307
3.67k
      parser->flags &= ~mxForFlag;
2308
3.67k
      fxAssignmentExpression(parser);
2309
3.67k
      if (parser->states[0].token == XS_TOKEN_COMMA) {
2310
188
        fxGetNextToken(parser);
2311
188
        if (gxTokenFlags[parser->states[0].token] & XS_TOKEN_BEGIN_EXPRESSION) {
2312
170
          fxAssignmentExpression(parser);
2313
170
          if (parser->states[0].token == XS_TOKEN_COMMA)
2314
31
            fxGetNextToken(parser);
2315
170
        }
2316
18
        else
2317
18
          fxPushNULL(parser);
2318
188
      }
2319
3.48k
      else
2320
3.48k
        fxPushNULL(parser);
2321
3.67k
      parser->flags |= flags;
2322
3.67k
      fxMatchToken(parser, XS_TOKEN_RIGHT_PARENTHESIS);
2323
3.67k
      fxPushNodeStruct(parser, 2, XS_TOKEN_IMPORT_CALL, aLine);
2324
3.67k
    }
2325
4.31k
    else if (parser->states[0].token == XS_TOKEN_DOT) {
2326
3.44k
      fxGetNextToken(parser);
2327
3.44k
      if ((parser->states[0].token == XS_TOKEN_IDENTIFIER) && (parser->states[0].symbol == parser->metaSymbol) && (!parser->states[0].escaped)) { 
2328
419
        fxGetNextToken(parser);
2329
419
        if (parser->flags & mxProgramFlag)
2330
322
          fxReportParserError(parser, parser->states[0].line, "invalid import.meta");
2331
97
        else
2332
97
          fxPushNodeStruct(parser, 0, XS_TOKEN_IMPORT_META, aLine);
2333
419
      }
2334
3.02k
      else
2335
3.02k
        fxReportParserError(parser, parser->states[0].line, "invalid import.");
2336
3.44k
    }
2337
872
    else
2338
872
      fxReportParserError(parser, parser->states[0].line, "invalid import");
2339
7.98k
    break;
2340
1.74k
  case XS_TOKEN_SUPER:
2341
1.74k
    fxMatchToken(parser, XS_TOKEN_SUPER);
2342
1.74k
    if (parser->states[0].token == XS_TOKEN_LEFT_PARENTHESIS) {
2343
29
      if (parser->flags & mxDerivedFlag) {
2344
19
        fxParameters(parser);
2345
19
        fxPushNodeStruct(parser, 1, XS_TOKEN_SUPER, aLine);
2346
19
      }
2347
10
      else {
2348
10
        fxPushNodeStruct(parser, 0, XS_TOKEN_UNDEFINED, aLine);
2349
10
        fxReportParserError(parser, parser->states[0].line, "invalid super");
2350
10
      }
2351
29
    }
2352
1.71k
    else if ((parser->states[0].token == XS_TOKEN_DOT) || (parser->states[0].token == XS_TOKEN_LEFT_BRACKET)) {
2353
679
      if (parser->flags & mxSuperFlag) {
2354
573
        fxPushNodeStruct(parser, 0, XS_TOKEN_THIS, aLine);
2355
573
        parser->root->flags |= parser->flags & (mxDerivedFlag | mxSuperFlag);
2356
573
      }
2357
106
      else {
2358
106
        fxPushNodeStruct(parser, 0, XS_TOKEN_UNDEFINED, aLine);
2359
106
        fxReportParserError(parser, parser->states[0].line, "invalid super");
2360
106
      }
2361
679
    }
2362
1.03k
    else
2363
1.03k
      fxReportParserError(parser, parser->states[0].line, "invalid super");
2364
1.74k
    parser->flags |= mxSuperFlag;
2365
1.74k
    break;
2366
15.6k
  case XS_TOKEN_THIS:
2367
15.6k
    fxPushNodeStruct(parser, 0, parser->states[0].token, aLine);
2368
15.6k
    parser->root->flags |= parser->flags & mxDerivedFlag;
2369
15.6k
    fxMatchToken(parser, XS_TOKEN_THIS);
2370
15.6k
    break;
2371
13.1M
  case XS_TOKEN_INTEGER:
2372
13.1M
    fxPushIntegerNode(parser, parser->states[0].integer, aLine);
2373
13.1M
    fxGetNextToken(parser);
2374
13.1M
    break;
2375
37.0k
  case XS_TOKEN_NUMBER:
2376
37.0k
    fxPushNumberNode(parser, parser->states[0].number, aLine);
2377
37.0k
    fxGetNextToken(parser);
2378
37.0k
    break;
2379
66.1k
  case XS_TOKEN_BIGINT:
2380
66.1k
    fxPushBigIntNode(parser, &parser->states[0].bigint, aLine);
2381
66.1k
    fxGetNextToken(parser);
2382
66.1k
    break;
2383
744
  case XS_TOKEN_DIVIDE_ASSIGN:
2384
744
    c = '=';
2385
    // continue
2386
744
    mxFallThrough;
2387
33.6k
  case XS_TOKEN_DIVIDE:
2388
33.6k
    fxGetNextRegExp(parser, c);
2389
33.6k
    fxPushStringNode(parser, parser->states[0].modifierLength, parser->states[0].modifier, aLine);
2390
33.6k
    fxPushStringNode(parser, parser->states[0].stringLength, parser->states[0].string, aLine);
2391
33.6k
    fxPushNodeStruct(parser, 2, XS_TOKEN_REGEXP, aLine);
2392
33.6k
    fxGetNextToken(parser);
2393
33.6k
    break;
2394
285k
  case XS_TOKEN_STRING:
2395
285k
    fxPushStringNode(parser, parser->states[0].stringLength, parser->states[0].string, aLine);
2396
285k
    fxGetNextToken(parser);
2397
285k
    break;
2398
1.55M
  case XS_TOKEN_IDENTIFIER:
2399
1.55M
    escaped = parser->states[0].escaped;
2400
1.55M
    aSymbol = parser->states[0].symbol;
2401
1.55M
    fxGetNextToken(parser);
2402
//    if (aSymbol == parser->undefinedSymbol) {
2403
//      fxPushNodeStruct(parser, 0, XS_TOKEN_UNDEFINED, aLine);
2404
//      break;
2405
//    }
2406
1.55M
    flags = 0;
2407
1.55M
    if ((aSymbol == parser->asyncSymbol) && (!escaped) && (!parser->states[0].crlf)) {
2408
5.54k
      if (parser->states[0].token == XS_TOKEN_FUNCTION) {
2409
961
        fxMatchToken(parser, XS_TOKEN_FUNCTION);
2410
961
        if (parser->states[0].token == XS_TOKEN_MULTIPLY) {
2411
530
          fxGetNextToken(parser);
2412
530
          fxGeneratorExpression(parser, aLine, C_NULL, mxAsyncFlag);
2413
530
        }
2414
431
        else
2415
431
          fxFunctionExpression(parser, aLine, C_NULL, mxAsyncFlag);
2416
961
        break;
2417
961
      }
2418
4.57k
      if (parser->states[0].token == XS_TOKEN_LEFT_PARENTHESIS) {
2419
486
        fxGroupExpression(parser, mxAsyncFlag);
2420
486
        break;
2421
486
      }
2422
4.09k
      if (parser->states[0].token == XS_TOKEN_IDENTIFIER) {
2423
//        if (!(parser->flags & mxForFlag) || !fxIsKeyword(parser, parser->ofSymbol)) {
2424
3.08k
          aSymbol = parser->states[0].symbol;
2425
3.08k
          fxGetNextToken(parser);
2426
3.08k
          flags = mxAsyncFlag;
2427
//        }
2428
3.08k
      }
2429
4.09k
    }
2430
1.55M
    if (aSymbol == parser->awaitSymbol)
2431
632
      parser->flags |= mxAwaitingFlag;
2432
1.55M
    if ((!parser->states[0].crlf) && (parser->states[0].token == XS_TOKEN_ARROW)) {
2433
21.4k
      fxCheckStrictSymbol(parser, aSymbol);
2434
21.4k
      if (flags && (aSymbol == parser->awaitSymbol))
2435
0
        fxReportParserError(parser, parser->states[0].line, "invalid await");
2436
21.4k
      fxPushSymbol(parser, aSymbol);
2437
21.4k
      fxPushNULL(parser);
2438
21.4k
      fxPushNodeStruct(parser, 2, XS_TOKEN_ARG, aLine);
2439
21.4k
      fxPushNodeList(parser, 1);
2440
21.4k
      fxPushNodeStruct(parser, 1, XS_TOKEN_PARAMS_BINDING, aLine);
2441
21.4k
      fxArrowExpression(parser, flags);
2442
21.4k
      break;
2443
21.4k
    }
2444
1.53M
    if (aSymbol == parser->argumentsSymbol)
2445
1.57k
      parser->flags |= mxArgumentsFlag;
2446
1.53M
    fxPushSymbol(parser, aSymbol);
2447
1.53M
    fxPushNodeStruct(parser, 1, XS_TOKEN_ACCESS, aLine);
2448
1.53M
    break;
2449
9.91k
  case XS_TOKEN_CLASS:
2450
9.91k
    flags = parser->flags & mxForFlag;
2451
9.91k
    parser->flags &= ~mxForFlag;
2452
9.91k
    fxClassExpression(parser, aLine, C_NULL);
2453
9.91k
    parser->flags |= flags;
2454
9.91k
    break;
2455
194k
  case XS_TOKEN_FUNCTION:
2456
194k
    fxMatchToken(parser, XS_TOKEN_FUNCTION);
2457
194k
    if (parser->states[0].token == XS_TOKEN_MULTIPLY) {
2458
8.76k
      fxGetNextToken(parser);
2459
8.76k
      fxGeneratorExpression(parser, aLine, C_NULL, 0);
2460
8.76k
    }
2461
185k
    else
2462
185k
      fxFunctionExpression(parser, aLine, C_NULL, 0);
2463
194k
    break;
2464
48.2k
  case XS_TOKEN_NEW:
2465
48.2k
    fxNewExpression(parser);
2466
48.2k
    break;
2467
98.5k
  case XS_TOKEN_LEFT_BRACE:
2468
98.5k
    flags = parser->flags & mxForFlag;
2469
98.5k
    parser->flags &= ~mxForFlag;
2470
98.5k
    fxObjectExpression(parser);
2471
98.5k
    parser->flags |= flags;
2472
98.5k
    break;
2473
135k
  case XS_TOKEN_LEFT_BRACKET:
2474
135k
    flags = parser->flags & mxForFlag;
2475
135k
    parser->flags &= ~mxForFlag;
2476
135k
    fxArrayExpression(parser);
2477
135k
    parser->flags |= flags;
2478
135k
    break;
2479
236k
  case XS_TOKEN_LEFT_PARENTHESIS:
2480
236k
    fxGroupExpression(parser, 0);
2481
236k
    break;
2482
28.5k
  case XS_TOKEN_TEMPLATE:
2483
28.5k
    fxPushNULL(parser);
2484
28.5k
    fxPushStringNode(parser, parser->states[0].stringLength, parser->states[0].string, aLine);
2485
28.5k
    fxPushRawNode(parser, parser->states[0].rawLength, parser->states[0].raw, aLine);
2486
28.5k
    fxPushNodeStruct(parser, 2, XS_TOKEN_TEMPLATE_MIDDLE, aLine);
2487
28.5k
    fxGetNextToken(parser);
2488
28.5k
    fxPushNodeList(parser, 1);
2489
28.5k
    fxPushNodeStruct(parser, 2, XS_TOKEN_TEMPLATE, aLine);
2490
28.5k
    break;
2491
779
  case XS_TOKEN_TEMPLATE_HEAD:
2492
779
    fxPushNULL(parser);
2493
779
    fxTemplateExpression(parser);
2494
779
    fxPushNodeStruct(parser, 2, XS_TOKEN_TEMPLATE, aLine);
2495
779
    break;
2496
0
  case XS_TOKEN_HOST:
2497
0
    fxGetNextToken(parser);
2498
0
    fxPushNULL(parser);
2499
0
    fxPushNULL(parser);
2500
0
    if (parser->states[0].token == XS_TOKEN_STRING) {
2501
0
      fxPushStringNode(parser, parser->states[0].stringLength, parser->states[0].string, aLine);
2502
0
      fxGetNextToken(parser);
2503
0
    }
2504
0
    else {
2505
0
      fxReportParserError(parser, parser->states[0].line, "invalid host object");
2506
0
      fxPushNULL(parser);
2507
0
    }
2508
0
    fxPushNodeStruct(parser, 3, XS_TOKEN_HOST, aLine);
2509
0
    break;
2510
37.7k
  case XS_TOKEN_LESS:
2511
37.7k
    fxGetNextToken(parser);
2512
37.7k
    fxJSXElement(parser);
2513
37.7k
    fxGetNextToken(parser);
2514
37.7k
    break;
2515
11.1k
  default:
2516
11.1k
    fxPushNodeStruct(parser, 0, XS_TOKEN_UNDEFINED, aLine);
2517
11.1k
    fxReportParserError(parser, parser->states[0].line, "missing expression");
2518
11.1k
    break;
2519
15.9M
  }
2520
15.9M
}
2521
2522
void fxArrayExpression(txParser* parser)
2523
135k
{
2524
135k
  txInteger aCount = 0;
2525
135k
  int elision = 1;
2526
135k
  txInteger aLine = parser->states[0].line;
2527
135k
  txBoolean aSpreadFlag = 0;
2528
135k
  fxMatchToken(parser, XS_TOKEN_LEFT_BRACKET);
2529
657k
  while ((parser->states[0].token == XS_TOKEN_COMMA) || (parser->states[0].token == XS_TOKEN_SPREAD) || (gxTokenFlags[parser->states[0].token] & XS_TOKEN_BEGIN_EXPRESSION)) {
2530
521k
    txInteger anItemLine = parser->states[0].line;
2531
521k
    if (parser->states[0].token == XS_TOKEN_COMMA) {
2532
224k
      fxGetNextToken(parser);
2533
224k
      if (elision) {
2534
53.8k
        fxPushNodeStruct(parser, 0, XS_TOKEN_ELISION, anItemLine);
2535
53.8k
        aCount++;
2536
53.8k
      }
2537
170k
      else
2538
170k
        elision = 1;
2539
224k
    }
2540
296k
    else if (parser->states[0].token == XS_TOKEN_SPREAD) {
2541
1.40k
      fxGetNextToken(parser);
2542
1.40k
      if (!elision)
2543
1
        fxReportParserError(parser, parser->states[0].line, "missing ,");
2544
1.40k
      fxAssignmentExpression(parser);
2545
1.40k
      fxPushNodeStruct(parser, 1, XS_TOKEN_SPREAD, anItemLine);
2546
1.40k
      aCount++;
2547
1.40k
      elision = 0;
2548
1.40k
      aSpreadFlag = 1;
2549
1.40k
    }
2550
295k
    else {
2551
295k
      if (!elision)
2552
2.11k
        fxReportParserError(parser, parser->states[0].line, "missing ,");
2553
295k
      fxAssignmentExpression(parser);
2554
295k
      aCount++;
2555
295k
      elision = 0;
2556
295k
    }
2557
521k
  }
2558
135k
  fxMatchToken(parser, XS_TOKEN_RIGHT_BRACKET);
2559
135k
  fxPushNodeList(parser, aCount);
2560
135k
  fxPushNodeStruct(parser, 1, XS_TOKEN_ARRAY, aLine);
2561
135k
  if (aCount && elision)
2562
2.48k
    parser->root->flags |= mxElisionFlag;
2563
135k
  if (aSpreadFlag)
2564
869
    parser->root->flags |= mxSpreadFlag;
2565
135k
}
2566
2567
void fxArrowExpression(txParser* parser, txUnsigned flag)
2568
65.6k
{
2569
65.6k
  txInteger aLine = parser->states[0].line;
2570
65.6k
  txUnsigned flags = parser->flags;
2571
65.6k
  parser->flags &= ~(mxAsyncFlag | mxGeneratorFlag);
2572
65.6k
  parser->flags |= mxArrowFlag | flag;
2573
65.6k
  fxMatchToken(parser, XS_TOKEN_ARROW);
2574
65.6k
  fxPushNULL(parser);
2575
65.6k
  fxSwapNodes(parser);  
2576
65.6k
  if (parser->states[0].token == XS_TOKEN_LEFT_BRACE) {
2577
39.8k
    fxMatchToken(parser, XS_TOKEN_LEFT_BRACE);
2578
39.8k
    fxBody(parser);
2579
39.8k
    fxPushNodeStruct(parser, 1, XS_TOKEN_BODY, aLine);
2580
39.8k
    fxMatchToken(parser, XS_TOKEN_RIGHT_BRACE);
2581
39.8k
  }
2582
25.7k
  else {
2583
25.7k
    fxAssignmentExpression(parser);
2584
25.7k
    fxPushNodeStruct(parser, 1, XS_TOKEN_RETURN, aLine);
2585
25.7k
    fxPushNodeStruct(parser, 1, XS_TOKEN_BODY, aLine);
2586
25.7k
    if (!(flags & mxAsyncFlag) && (flag & mxAsyncFlag)) {
2587
1.52k
      if (parser->states[0].token == XS_TOKEN_AWAIT) {
2588
1
        parser->states[0].token = XS_TOKEN_IDENTIFIER;
2589
1
      }
2590
1.52k
    }
2591
25.7k
  }
2592
65.6k
  fxPushNodeStruct(parser, 3, XS_TOKEN_FUNCTION, aLine);
2593
65.6k
  parser->root->flags = parser->flags & (mxStrictFlag | mxFieldFlag | mxNotSimpleParametersFlag | mxArrowFlag | mxSuperFlag | flag);
2594
65.6k
  if (!(flags & mxStrictFlag) && (parser->flags & mxStrictFlag))
2595
602
    fxCheckStrictFunction(parser, (txFunctionNode*)parser->root);
2596
65.6k
  parser->flags = flags | (parser->flags & (mxArgumentsFlag | mxEvalFlag));
2597
65.6k
}
2598
2599
void fxClassExpression(txParser* parser, txInteger theLine, txSymbol** theSymbol)
2600
80.3k
{
2601
80.3k
  txBoolean heritageFlag = 0;
2602
//  txBoolean hostFlag = 0;
2603
80.3k
  txNode* constructor = NULL;
2604
80.3k
  txInteger aCount = 0;
2605
80.3k
  txInteger aLine = parser->states[0].line;
2606
80.3k
  txUnsigned flags = parser->flags;
2607
80.3k
  txUnsigned constructorFlags = mxSuperFlag;
2608
80.3k
  txInteger constructorInitCount = 0;
2609
80.3k
  txInteger instanceInitCount = 0;
2610
80.3k
  parser->flags |= mxStrictFlag;
2611
80.3k
  fxMatchToken(parser, XS_TOKEN_CLASS);
2612
80.3k
  if (parser->states[0].token == XS_TOKEN_IDENTIFIER) {
2613
10.8k
    fxPushSymbol(parser, parser->states[0].symbol);
2614
10.8k
    if (theSymbol)
2615
8.90k
      *theSymbol = parser->states[0].symbol;
2616
10.8k
    fxGetNextToken(parser);
2617
10.8k
  }
2618
69.4k
  else
2619
69.4k
    fxPushNULL(parser);
2620
80.3k
  if (parser->states[0].token == XS_TOKEN_EXTENDS) {
2621
432
    fxMatchToken(parser, XS_TOKEN_EXTENDS);
2622
432
    fxCallExpression(parser);
2623
432
    fxCheckArrowFunction(parser, 1);
2624
432
    fxCheckNativeConstructor(parser);
2625
432
    flags |= parser->flags & mxAwaitingFlag;
2626
432
    constructorFlags |= mxDerivedFlag;
2627
432
    if (parser->root->description->token == XS_TOKEN_HOST)
2628
0
      constructorFlags |= mxHostFlag;
2629
432
    heritageFlag = 1;
2630
432
  }
2631
79.9k
  else if (parser->states[0].token == XS_TOKEN_HOST) {
2632
0
    fxGetNextToken(parser);
2633
0
    fxPushNULL(parser);
2634
0
    fxPushNULL(parser);
2635
0
    if (parser->states[0].token == XS_TOKEN_STRING) {
2636
0
      fxPushStringNode(parser, parser->states[0].stringLength, parser->states[0].string, aLine);
2637
0
      fxGetNextToken(parser);
2638
0
    }
2639
0
    else {
2640
0
      fxReportParserError(parser, parser->states[0].line, "invalid host class");
2641
0
      fxPushNULL(parser);
2642
0
    }
2643
0
    fxPushNodeStruct(parser, 3, XS_TOKEN_HOST, aLine);
2644
0
    constructorFlags |= mxBaseFlag | mxHostFlag;
2645
//    hostFlag = 1;
2646
0
  }
2647
79.9k
  else {
2648
79.9k
    fxPushNULL(parser);
2649
79.9k
    constructorFlags |= mxBaseFlag;
2650
79.9k
  }
2651
80.3k
  if (parser->states[0].token == XS_TOKEN_LEFT_BRACE) {
2652
79.1k
    fxMatchToken(parser, XS_TOKEN_LEFT_BRACE);
2653
107k
    for (;;) {
2654
107k
      txBoolean aStaticFlag;
2655
107k
      txInteger aPropertyLine = parser->states[0].line;
2656
107k
      txSymbol* aSymbol;
2657
107k
      txToken aToken0;
2658
107k
      txToken aToken1;
2659
107k
      txToken aToken2;
2660
107k
      txUnsigned flag;
2661
121k
      while (parser->states[0].token == XS_TOKEN_SEMICOLON)
2662
13.7k
        fxGetNextToken(parser);
2663
107k
      if (parser->states[0].token == XS_TOKEN_RIGHT_BRACE)
2664
6.53k
        break;
2665
100k
      aStaticFlag = 0;
2666
100k
      if ((parser->states[0].token == XS_TOKEN_STATIC) && (!parser->states[0].escaped)) {
2667
69.0k
        fxGetNextToken(parser);
2668
69.0k
        if ((parser->states[0].token == XS_TOKEN_ASSIGN) || parser->states[0].token == XS_TOKEN_SEMICOLON) {
2669
934
          fxPushSymbol(parser, parser->staticSymbol);
2670
934
          aToken1 = XS_TOKEN_PROPERTY;
2671
934
          goto field;
2672
934
        }
2673
68.1k
        if (parser->states[0].token == XS_TOKEN_LEFT_BRACE) {
2674
61.7k
          txUnsigned flags = parser->flags;
2675
61.7k
          parser->flags = (flags & (mxParserFlags | mxStrictFlag)) | mxSuperFlag | mxTargetFlag | mxFieldFlag | mxAsyncFlag;
2676
61.7k
          fxCheckParserStack(parser, aPropertyLine);
2677
61.7k
          fxGetNextToken(parser);
2678
61.7k
          fxStatements(parser);
2679
61.7k
          fxMatchToken(parser, XS_TOKEN_RIGHT_BRACE);
2680
61.7k
          fxPushNodeStruct(parser, 1, XS_TOKEN_BODY, aPropertyLine);
2681
61.7k
          if (parser->flags & mxArgumentsFlag)
2682
0
            fxReportParserError(parser, parser->states[0].line, "invalid arguments");
2683
61.7k
          if (parser->flags & mxAwaitingFlag)
2684
0
            fxReportParserError(parser, parser->states[0].line, "invalid await");
2685
61.7k
          parser->flags = flags;
2686
61.7k
          parser->root->flags |= mxStaticFlag;
2687
61.7k
          constructorInitCount++;
2688
61.7k
          aCount++;
2689
61.7k
          continue;
2690
61.7k
        }
2691
6.38k
        aStaticFlag = 1;
2692
6.38k
      }
2693
38.1k
      fxPropertyName(parser, &aSymbol, &aToken0, &aToken1, &aToken2, &flag);
2694
38.1k
      if ((aStaticFlag == 0) && (aSymbol == parser->constructorSymbol)) {
2695
250
        fxPopNode(parser); // symbol
2696
250
        if (constructor || (aToken2 == XS_TOKEN_GENERATOR) || (aToken2 == XS_TOKEN_GETTER) || (aToken2 == XS_TOKEN_SETTER) || (flag & mxAsyncFlag)) 
2697
2
          fxReportParserError(parser, parser->states[0].line, "invalid constructor");
2698
250
        fxFunctionExpression(parser, aPropertyLine, C_NULL, constructorFlags);
2699
250
        constructor = fxPopNode(parser);
2700
250
      }
2701
37.9k
      else if (parser->states[0].token == XS_TOKEN_LEFT_PARENTHESIS) {
2702
6.04k
        if ((aToken1 == XS_TOKEN_PRIVATE_PROPERTY) && (aSymbol == parser->privateConstructorSymbol))
2703
1
          fxReportParserError(parser, parser->states[0].line, "invalid method: #constructor");
2704
6.04k
        if (aStaticFlag && (aSymbol == parser->prototypeSymbol))
2705
0
          fxReportParserError(parser, parser->states[0].line, "invalid static method: prototype");
2706
6.04k
        if (aStaticFlag)
2707
2.87k
          flag |= mxStaticFlag;
2708
6.04k
        if (aToken2 == XS_TOKEN_GETTER) 
2709
153
          flag |= mxGetterFlag;
2710
5.89k
        else if (aToken2 == XS_TOKEN_SETTER) 
2711
266
          flag |= mxSetterFlag;
2712
5.63k
        else
2713
5.63k
          flag |= mxMethodFlag;
2714
6.04k
        if (aToken2 == XS_TOKEN_GENERATOR)
2715
1.92k
          fxGeneratorExpression(parser, aPropertyLine, C_NULL, mxSuperFlag | flag);
2716
4.12k
        else
2717
4.12k
          fxFunctionExpression(parser, aPropertyLine, C_NULL, mxSuperFlag | flag);
2718
6.04k
        fxPushNodeStruct(parser, 2, aToken1, aPropertyLine);
2719
6.04k
        parser->root->flags |= flag & (mxStaticFlag | mxGetterFlag | mxSetterFlag | mxMethodFlag);
2720
6.04k
        if (aToken1 == XS_TOKEN_PRIVATE_PROPERTY) {
2721
1.07k
          if (aStaticFlag)
2722
115
            constructorInitCount++;
2723
959
          else
2724
959
            instanceInitCount++;
2725
1.07k
        }
2726
6.04k
        aCount++;
2727
6.04k
      }
2728
31.8k
      else {
2729
31.8k
        if ((aToken1 == XS_TOKEN_PRIVATE_PROPERTY) && (aSymbol == parser->privateConstructorSymbol))
2730
1
          fxReportParserError(parser, parser->states[0].line, "invalid field: #constructor");
2731
31.8k
        if (aSymbol == parser->constructorSymbol)
2732
1
          fxReportParserError(parser, parser->states[0].line, "invalid field: constructor");
2733
31.8k
        if (aSymbol == parser->prototypeSymbol)
2734
1
          fxReportParserError(parser, parser->states[0].line, "invalid field: prototype");
2735
31.8k
      field:
2736
28.3k
        if (parser->states[0].token == XS_TOKEN_ASSIGN) {
2737
5.81k
          txUnsigned flags = parser->flags;
2738
5.81k
          parser->flags = (flags & (mxParserFlags | mxStrictFlag)) | mxSuperFlag | mxTargetFlag | mxFieldFlag;
2739
5.81k
          fxGetNextToken(parser);
2740
5.81k
          fxAssignmentExpression(parser);
2741
5.81k
          if (parser->flags & mxArgumentsFlag)
2742
77
            fxReportParserError(parser, parser->states[0].line, "invalid arguments");
2743
5.81k
          parser->flags = flags;
2744
5.81k
        }
2745
22.4k
        else {
2746
22.4k
          fxPushNodeStruct(parser, 0, XS_TOKEN_UNDEFINED, aLine);
2747
22.4k
        }
2748
28.3k
        fxPushNodeStruct(parser, 2, aToken1, aPropertyLine);
2749
28.3k
        if (aStaticFlag) {
2750
1.73k
          parser->root->flags |= mxStaticFlag;
2751
1.73k
          constructorInitCount++;
2752
1.73k
        }
2753
26.5k
        else
2754
26.5k
          instanceInitCount++;
2755
28.3k
        fxSemicolon(parser);
2756
28.3k
        aCount++;
2757
28.3k
      }
2758
38.1k
    }
2759
79.1k
  }
2760
75.8k
  fxMatchToken(parser, XS_TOKEN_RIGHT_BRACE);
2761
75.8k
  fxPushNodeList(parser, aCount);
2762
  
2763
75.8k
  if (constructorInitCount || instanceInitCount) {
2764
4.09k
    txNodeList* itemsList = (txNodeList*)(parser->root);
2765
4.09k
    txNodeList* constructorInitList = C_NULL;
2766
4.09k
    txNode** constructorInitAddress = C_NULL;
2767
4.09k
    txNodeList* instanceInitList = C_NULL;
2768
4.09k
    txNode** instanceInitAddress = C_NULL;
2769
4.09k
    txNode** address;
2770
4.09k
    txNode* item;
2771
4.09k
    if (constructorInitCount) {
2772
1.36k
      fxPushNULL(parser);
2773
1.36k
      fxPushNodeList(parser, 0);
2774
1.36k
      fxPushNodeStruct(parser, 1, XS_TOKEN_PARAMS_BINDING, aLine);
2775
1.36k
      fxPushNodeList(parser, 0);
2776
1.36k
      constructorInitList = (txNodeList*)(parser->root);
2777
1.36k
      constructorInitList->length = constructorInitCount;
2778
1.36k
      constructorInitAddress = &(((txNodeList*)(parser->root))->first);
2779
1.36k
      fxPushNodeStruct(parser, 1, XS_TOKEN_STATEMENTS, aLine);
2780
1.36k
      fxPushNodeStruct(parser, 1, XS_TOKEN_BODY, aLine);
2781
1.36k
      fxPushNodeStruct(parser, 3, XS_TOKEN_FUNCTION, aLine);
2782
1.36k
      parser->root->flags = mxStrictFlag | mxSuperFlag | mxFieldFlag;
2783
1.36k
    }
2784
2.72k
    else 
2785
2.72k
      fxPushNULL(parser);
2786
4.09k
    if (instanceInitCount) {
2787
3.19k
      fxPushNULL(parser);
2788
3.19k
      fxPushNodeList(parser, 0);
2789
3.19k
      fxPushNodeStruct(parser, 1, XS_TOKEN_PARAMS_BINDING, aLine);
2790
3.19k
      fxPushNodeList(parser, 0);
2791
3.19k
      instanceInitList = (txNodeList*)(parser->root);
2792
3.19k
      instanceInitList->length = instanceInitCount;
2793
3.19k
      instanceInitAddress = &(((txNodeList*)(parser->root))->first);
2794
3.19k
      fxPushNodeStruct(parser, 1, XS_TOKEN_STATEMENTS, aLine);
2795
3.19k
      fxPushNodeStruct(parser, 1, XS_TOKEN_BODY, aLine);
2796
3.19k
      fxPushNodeStruct(parser, 3, XS_TOKEN_FUNCTION, aLine);
2797
3.19k
      parser->root->flags = mxStrictFlag | mxSuperFlag | mxFieldFlag;
2798
3.19k
    }
2799
891
    else 
2800
891
      fxPushNULL(parser);
2801
4.09k
    address = &(itemsList->first);
2802
20.4k
    while ((item = *address)) {
2803
16.3k
      if (item->flags & (mxMethodFlag | mxGetterFlag | mxSetterFlag)) {
2804
1.97k
        if (item->description->token == XS_TOKEN_PRIVATE_PROPERTY) {
2805
1.06k
          txFieldNode* field = fxFieldNodeNew(parser, XS_TOKEN_FIELD);
2806
1.06k
          field->item = item;
2807
1.06k
          if (item->flags & mxStaticFlag) {
2808
113
            *constructorInitAddress = (txNode*)field;
2809
113
            constructorInitAddress = &field->next;
2810
113
          }
2811
950
          else {
2812
950
            *instanceInitAddress = (txNode*)field;
2813
950
            instanceInitAddress = &field->next;
2814
950
          }
2815
1.06k
        }
2816
1.97k
      }
2817
16.3k
      address = &(item->next);
2818
16.3k
    }
2819
4.09k
    address = &(itemsList->first);
2820
20.4k
    while ((item = *address)) {
2821
16.3k
      if (item->description->token == XS_TOKEN_BODY) {
2822
732
        *address = item->next;
2823
732
        item->next = C_NULL;
2824
732
        itemsList->length--;
2825
732
        *constructorInitAddress = (txNode*)item;
2826
732
        constructorInitAddress = &item->next;
2827
732
      }
2828
15.6k
      else if (item->flags & (mxMethodFlag | mxGetterFlag | mxSetterFlag)) {
2829
1.97k
        address = &(item->next);
2830
1.97k
      }
2831
13.6k
      else {
2832
13.6k
        txFieldNode* field = fxFieldNodeNew(parser, XS_TOKEN_FIELD);
2833
13.6k
        field->item = item;
2834
13.6k
        if (item->description->token == XS_TOKEN_PROPERTY) {
2835
5.01k
          field->value = ((txPropertyNode*)item)->value;
2836
5.01k
          ((txPropertyNode*)item)->value = C_NULL;
2837
5.01k
        }
2838
8.63k
        else if (item->description->token == XS_TOKEN_PROPERTY_AT) {
2839
5.55k
          field->value = ((txPropertyAtNode*)item)->value;
2840
5.55k
          ((txPropertyAtNode*)item)->value = C_NULL;
2841
5.55k
        }
2842
3.08k
        else {
2843
3.08k
          field->value = ((txPrivatePropertyNode*)item)->value;
2844
3.08k
          ((txPrivatePropertyNode*)item)->value = C_NULL;
2845
3.08k
        }
2846
13.6k
        if (item->flags & mxStaticFlag) {
2847
520
          *constructorInitAddress = (txNode*)field;
2848
520
          constructorInitAddress = &field->next;
2849
520
        }
2850
13.1k
        else {
2851
13.1k
          *instanceInitAddress = (txNode*)field;
2852
13.1k
          instanceInitAddress = &field->next;
2853
13.1k
        }
2854
13.6k
        address = &(item->next);
2855
13.6k
      }
2856
16.3k
    }
2857
4.09k
  }
2858
71.7k
  else {
2859
71.7k
    fxPushNULL(parser);
2860
71.7k
    fxPushNULL(parser);
2861
71.7k
  }
2862
75.8k
  if (constructor) {
2863
203
    fxPushNode(parser, constructor);
2864
203
  }
2865
75.6k
  else {
2866
75.6k
    if (heritageFlag) {
2867
367
      fxPushNULL(parser);
2868
    
2869
367
      fxPushSymbol(parser, parser->argsSymbol);
2870
367
      fxPushNULL(parser);
2871
367
      fxPushNodeStruct(parser, 2, XS_TOKEN_ARG, aLine);
2872
367
      fxPushNodeStruct(parser, 1, XS_TOKEN_REST_BINDING, aLine);
2873
367
      fxPushNodeList(parser, 1);
2874
367
      fxPushNodeStruct(parser, 1, XS_TOKEN_PARAMS_BINDING, aLine);
2875
      
2876
367
      fxPushSymbol(parser, parser->argsSymbol);
2877
367
      fxPushNodeStruct(parser, 1, XS_TOKEN_ACCESS, aLine);
2878
367
      fxPushNodeStruct(parser, 1, XS_TOKEN_SPREAD, aLine);
2879
367
      fxPushNodeList(parser, 1);
2880
367
      fxPushNodeStruct(parser, 1, XS_TOKEN_PARAMS, aLine);
2881
367
      parser->root->flags |= mxSpreadFlag;
2882
367
      fxPushNodeStruct(parser, 1, XS_TOKEN_SUPER, aLine);
2883
367
      fxPushNodeStruct(parser, 1, XS_TOKEN_STATEMENT, aLine);
2884
367
      fxPushNodeStruct(parser, 1, XS_TOKEN_BODY, aLine);
2885
      
2886
367
      fxPushNodeStruct(parser, 3, XS_TOKEN_FUNCTION, aLine);
2887
367
      parser->root->flags = mxStrictFlag | mxDerivedFlag | mxMethodFlag | mxTargetFlag | mxSuperFlag;
2888
367
    }
2889
75.2k
    else {
2890
75.2k
      fxPushNULL(parser);
2891
    
2892
75.2k
      fxPushNodeList(parser, 0);
2893
75.2k
      fxPushNodeStruct(parser, 1, XS_TOKEN_PARAMS_BINDING, aLine);
2894
      
2895
75.2k
      fxPushNodeStruct(parser, 0, XS_TOKEN_UNDEFINED, aLine);
2896
75.2k
      fxPushNodeStruct(parser, 1, XS_TOKEN_STATEMENT, aLine);
2897
75.2k
      fxPushNodeStruct(parser, 1, XS_TOKEN_BODY, aLine);
2898
      
2899
75.2k
      fxPushNodeStruct(parser, 3, XS_TOKEN_FUNCTION, aLine);
2900
75.2k
      parser->root->flags = mxStrictFlag | mxBaseFlag | mxMethodFlag | mxTargetFlag;
2901
75.2k
    }
2902
75.6k
  }
2903
75.8k
  fxPushNodeStruct(parser, 6, XS_TOKEN_CLASS, aLine);
2904
75.8k
  parser->flags = flags | (parser->flags & (mxArgumentsFlag));
2905
75.8k
}
2906
2907
void fxFunctionExpression(txParser* parser, txInteger theLine, txSymbol** theSymbol, txUnsigned flag)
2908
200k
{
2909
200k
  txUnsigned flags = parser->flags;
2910
200k
  parser->flags = (flags & (mxParserFlags | mxStrictFlag)) | mxFunctionFlag | mxTargetFlag | flag;
2911
200k
  if ((parser->states[0].token == XS_TOKEN_IDENTIFIER)
2912
64.7k
      || ((flags & mxGeneratorFlag) && !(flags & mxStrictFlag) && (parser->states[0].token == XS_TOKEN_YIELD))
2913
136k
      || ((theSymbol == C_NULL) && (parser->states[0].token == XS_TOKEN_AWAIT))) {
2914
136k
    fxPushSymbol(parser, parser->states[0].symbol);
2915
136k
    if (theSymbol)
2916
4.76k
      *theSymbol = parser->states[0].symbol;
2917
136k
    fxCheckStrictSymbol(parser, parser->states[0].symbol);
2918
136k
    fxGetNextToken(parser);
2919
136k
  }
2920
64.6k
  else
2921
64.6k
    fxPushNULL(parser);
2922
200k
  fxParametersBinding(parser);
2923
200k
  if (parser->states[0].token == XS_TOKEN_HOST) {
2924
0
    fxGetNextToken(parser);
2925
0
    if (parser->states[0].token == XS_TOKEN_STRING) {
2926
0
      fxPushStringNode(parser, parser->states[0].stringLength, parser->states[0].string, theLine);
2927
0
      fxGetNextToken(parser);
2928
0
    }
2929
0
    else {
2930
0
      fxReportParserError(parser, parser->states[0].line, "invalid host function");
2931
0
      fxPushNULL(parser);
2932
0
    }
2933
0
    fxPushNodeStruct(parser, 3, XS_TOKEN_HOST, theLine);
2934
0
        parser->root->flags = parser->flags & (mxStrictFlag | mxNotSimpleParametersFlag | mxTargetFlag | mxArgumentsFlag | mxEvalFlag | flag);
2935
0
        if (!(flags & mxStrictFlag) && (parser->flags & mxStrictFlag))
2936
0
            fxCheckStrictFunction(parser, (txFunctionNode*)parser->root);
2937
0
        parser->flags = flags;
2938
0
  }
2939
200k
  else {
2940
200k
    fxMatchToken(parser, XS_TOKEN_LEFT_BRACE);
2941
200k
    fxBody(parser);
2942
200k
    fxPushNodeStruct(parser, 1, XS_TOKEN_BODY, theLine);
2943
200k
    fxPushNodeStruct(parser, 3, XS_TOKEN_FUNCTION, theLine);
2944
200k
        parser->root->flags = parser->flags & (mxStrictFlag | mxNotSimpleParametersFlag | mxTargetFlag | mxArgumentsFlag | mxEvalFlag | flag);
2945
200k
        if (!(flags & mxStrictFlag) && (parser->flags & mxStrictFlag))
2946
698
            fxCheckStrictFunction(parser, (txFunctionNode*)parser->root);
2947
200k
        if (parser->flags & mxNativeFlag) {
2948
0
          fxCheckNativeFunction(parser);
2949
0
        }     
2950
200k
        parser->flags = flags;
2951
200k
        fxMatchToken(parser, XS_TOKEN_RIGHT_BRACE);
2952
200k
  }
2953
200k
}
2954
2955
void fxGeneratorExpression(txParser* parser, txInteger theLine, txSymbol** theSymbol, txUnsigned flag)
2956
34.1k
{
2957
34.1k
  txUnsigned flags = parser->flags;
2958
34.1k
  parser->flags = (flags & (mxParserFlags | mxStrictFlag)) | mxGeneratorFlag | mxTargetFlag | flag;
2959
34.1k
  if ((parser->states[0].token == XS_TOKEN_IDENTIFIER)
2960
23.6k
      || ((theSymbol == C_NULL) && (parser->states[0].token == XS_TOKEN_AWAIT))) {
2961
23.6k
    fxPushSymbol(parser, parser->states[0].symbol);
2962
23.6k
    if (theSymbol)
2963
18.7k
      *theSymbol = parser->states[0].symbol;
2964
4.87k
    else if (parser->states[0].symbol == parser->yieldSymbol)
2965
128
      fxReportParserError(parser, parser->states[0].line, "invalid yield");
2966
4.74k
    else if ((parser->flags & mxAsyncFlag) && (parser->states[0].symbol == parser->awaitSymbol))
2967
0
      fxReportParserError(parser, parser->states[0].line, "invalid await");
2968
23.6k
    fxCheckStrictSymbol(parser, parser->states[0].symbol);
2969
23.6k
    fxGetNextToken(parser);
2970
23.6k
  }
2971
10.4k
  else
2972
10.4k
    fxPushNULL(parser);
2973
34.1k
  fxParametersBinding(parser);
2974
34.1k
  fxMatchToken(parser, XS_TOKEN_LEFT_BRACE);
2975
34.1k
  parser->flags |= mxYieldFlag;
2976
34.1k
    fxBody(parser);
2977
34.1k
  parser->flags &= ~mxYieldFlag;
2978
34.1k
  fxPushNodeStruct(parser, 1, XS_TOKEN_BODY, theLine);
2979
34.1k
  fxPushNodeStruct(parser, 3, XS_TOKEN_GENERATOR, theLine);
2980
34.1k
  parser->root->flags = parser->flags & (mxStrictFlag | mxNotSimpleParametersFlag | mxGeneratorFlag | mxArgumentsFlag | mxEvalFlag | flag);
2981
34.1k
  if (!(flags & mxStrictFlag) && (parser->flags & mxStrictFlag))
2982
181
    fxCheckStrictFunction(parser, (txFunctionNode*)parser->root);
2983
34.1k
  parser->flags = flags;
2984
34.1k
    fxMatchToken(parser, XS_TOKEN_RIGHT_BRACE);
2985
34.1k
}
2986
2987
void fxGroupExpression(txParser* parser, txUnsigned flag)
2988
236k
{
2989
236k
  txBoolean commaFlag = 0;
2990
236k
  txBoolean spreadFlag = 0;
2991
236k
  txInteger aCount = 0;
2992
236k
  txInteger aLine;
2993
236k
  txUnsigned formerAwaitingYieldingFlags = parser->flags & (mxAwaitingFlag | mxYieldingFlag);
2994
236k
  parser->flags &= ~(mxAwaitingFlag | mxYieldingFlag);
2995
236k
  fxMatchToken(parser, XS_TOKEN_LEFT_PARENTHESIS);
2996
356k
  while ((parser->states[0].token == XS_TOKEN_SPREAD) || (gxTokenFlags[parser->states[0].token] & XS_TOKEN_BEGIN_EXPRESSION)) {
2997
204k
    aLine = parser->states[0].line;
2998
204k
    commaFlag = 0;
2999
204k
    if (parser->states[0].token == XS_TOKEN_SPREAD) {
3000
82
      fxGetNextToken(parser);
3001
82
      fxAssignmentExpression(parser);
3002
82
      fxPushNodeStruct(parser, 1, XS_TOKEN_SPREAD, aLine);
3003
82
      spreadFlag = 1;
3004
82
    }
3005
204k
    else
3006
204k
      fxAssignmentExpression(parser);
3007
204k
    aCount++;
3008
204k
    if (parser->states[0].token != XS_TOKEN_COMMA) 
3009
84.9k
      break;
3010
119k
    fxGetNextToken(parser);
3011
119k
    commaFlag = 1;
3012
119k
  }
3013
236k
  aLine = parser->states[0].line;
3014
236k
  fxMatchToken(parser, XS_TOKEN_RIGHT_PARENTHESIS);
3015
236k
  if ((!parser->states[0].crlf) && (parser->states[0].token == XS_TOKEN_ARROW)) {
3016
44.4k
    fxPushNodeList(parser, aCount);
3017
44.4k
    fxPushNodeStruct(parser, 1, XS_TOKEN_EXPRESSIONS, aLine);
3018
44.4k
    if (commaFlag && spreadFlag)
3019
0
      fxReportParserError(parser, parser->states[0].line, "invalid parameters");
3020
44.4k
    if (!fxParametersBindingFromExpressions(parser, parser->root))
3021
284
      fxReportParserError(parser, parser->states[0].line, "no parameters");
3022
44.4k
    fxCheckStrictBinding(parser, parser->root);
3023
44.4k
    parser->root->flags |= flag;
3024
44.4k
    if (parser->flags & mxAwaitingFlag) {
3025
97
      if (flag || (parser->flags & mxAsyncFlag))
3026
0
        fxReportParserError(parser, parser->states[0].line, "invalid await");
3027
97
      else
3028
97
        formerAwaitingYieldingFlags |= mxAwaitingFlag;
3029
97
    }
3030
44.4k
    if (parser->flags & mxYieldingFlag)
3031
0
      fxReportParserError(parser, parser->states[0].line, "invalid yield");
3032
44.4k
    fxArrowExpression(parser, flag);
3033
44.4k
  }
3034
192k
  else if (flag) {
3035
154
    fxPushNodeList(parser, aCount);
3036
154
    fxPushNodeStruct(parser, 1, XS_TOKEN_PARAMS, aLine);
3037
154
    if (spreadFlag)
3038
1
      parser->root->flags |= mxSpreadFlag;
3039
    
3040
154
    fxPushSymbol(parser, parser->asyncSymbol);
3041
154
    fxPushNodeStruct(parser, 1, XS_TOKEN_ACCESS, aLine);
3042
154
    fxSwapNodes(parser);
3043
154
    fxPushNodeStruct(parser, 2, XS_TOKEN_CALL, aLine);
3044
154
  }
3045
192k
  else {
3046
192k
        if ((aCount == 0) || commaFlag) {
3047
2.93k
            fxPushNULL(parser);
3048
2.93k
      fxReportParserError(parser, parser->states[0].line, "missing expression");
3049
2.93k
        }
3050
189k
    else /*if (aCount > 1)*/ {
3051
189k
      fxPushNodeList(parser, aCount);
3052
189k
      fxPushNodeStruct(parser, 1, XS_TOKEN_EXPRESSIONS, aLine);
3053
189k
    }
3054
192k
  }
3055
236k
  parser->flags |= formerAwaitingYieldingFlags;
3056
236k
}
3057
3058
void fxNewExpression(txParser* parser)
3059
48.2k
{
3060
48.2k
  txInteger aLine = parser->states[0].line;
3061
48.2k
  fxMatchToken(parser, XS_TOKEN_NEW);
3062
48.2k
  if (parser->states[0].token == XS_TOKEN_DOT) {
3063
741
    fxGetNextToken(parser);
3064
741
    if (fxIsKeyword(parser, parser->targetSymbol)) {
3065
233
      if (!(parser->flags & mxTargetFlag))
3066
148
        fxReportParserError(parser, parser->states[0].line, "invalid new.target");
3067
233
      fxGetNextToken(parser);
3068
233
      fxPushNodeStruct(parser, 0, XS_TOKEN_TARGET, aLine);
3069
233
    }
3070
508
    else
3071
508
      fxReportParserError(parser, parser->states[0].line, "missing target");
3072
741
    return;
3073
741
  }
3074
47.5k
  fxLiteralExpression(parser, 1);
3075
47.5k
  fxCheckArrowFunction(parser, 1);
3076
51.9k
  for (;;) {
3077
51.9k
    txInteger aMemberLine = parser->states[0].line;
3078
51.9k
    if (parser->states[0].token == XS_TOKEN_DOT) {
3079
5.35k
      fxGetNextToken(parser);
3080
5.35k
      if (parser->states[0].token == XS_TOKEN_IDENTIFIER) {
3081
5.34k
        fxPushSymbol(parser, parser->states[0].symbol);
3082
5.34k
        fxPushNodeStruct(parser, 2, XS_TOKEN_MEMBER, aMemberLine);
3083
5.34k
        fxGetNextToken(parser);
3084
5.34k
      }
3085
11
      else if (parser->states[0].token == XS_TOKEN_PRIVATE_IDENTIFIER) {
3086
10
        fxPushSymbol(parser, parser->states[0].symbol);
3087
10
        fxSwapNodes(parser);
3088
10
        fxPushNodeStruct(parser, 2, XS_TOKEN_PRIVATE_MEMBER, aMemberLine);
3089
10
        fxGetNextToken(parser);
3090
10
      }
3091
1
      else
3092
1
        fxReportParserError(parser, parser->states[0].line, "missing property");
3093
5.35k
    }
3094
46.6k
    else if (parser->states[0].token == XS_TOKEN_LEFT_BRACKET) {
3095
1.22k
      fxGetNextToken(parser);
3096
1.22k
      fxCommaExpression(parser);
3097
1.22k
      fxPushNodeStruct(parser, 2, XS_TOKEN_MEMBER_AT, aMemberLine);
3098
1.22k
      fxMatchToken(parser, XS_TOKEN_RIGHT_BRACKET);
3099
1.22k
    }
3100
45.3k
    else if (parser->states[0].token == XS_TOKEN_TEMPLATE) {
3101
219
      fxPushStringNode(parser, parser->states[0].stringLength, parser->states[0].string, aLine);
3102
219
      fxPushRawNode(parser, parser->states[0].rawLength, parser->states[0].raw, aLine);
3103
219
      fxPushNodeStruct(parser, 2, XS_TOKEN_TEMPLATE_MIDDLE, aLine);
3104
219
      fxGetNextToken(parser);
3105
219
      fxPushNodeList(parser, 1);
3106
219
      fxPushNodeStruct(parser, 2, XS_TOKEN_TEMPLATE, aLine);
3107
219
    }
3108
45.1k
    else if (parser->states[0].token == XS_TOKEN_TEMPLATE_HEAD) {
3109
7
      fxTemplateExpression(parser);
3110
7
      fxPushNodeStruct(parser, 2, XS_TOKEN_TEMPLATE, aLine);
3111
7
    }
3112
45.1k
    else
3113
45.1k
      break;
3114
51.9k
  } 
3115
47.5k
  if (parser->states[0].token == XS_TOKEN_LEFT_PARENTHESIS)
3116
34.0k
    fxParameters(parser);
3117
13.4k
  else {
3118
13.4k
    fxPushNodeList(parser, 0);
3119
13.4k
    fxPushNodeStruct(parser, 1, XS_TOKEN_PARAMS, aLine);
3120
13.4k
  }
3121
47.5k
  fxPushNodeStruct(parser, 2, XS_TOKEN_NEW, aLine);
3122
47.5k
}
3123
3124
void fxObjectExpression(txParser* parser)
3125
98.5k
{
3126
98.5k
  txInteger aCount = 0;
3127
98.5k
  txSymbol* aSymbol;
3128
98.5k
  txToken aToken0;
3129
98.5k
  txToken aToken1;
3130
98.5k
  txToken aToken2;
3131
98.5k
  txInteger aLine = parser->states[0].line;
3132
98.5k
  txNode* base = parser->root;
3133
98.5k
  fxMatchToken(parser, XS_TOKEN_LEFT_BRACE);
3134
169k
  for (;;) {
3135
169k
    txInteger aPropertyLine = parser->states[0].line;
3136
169k
    txUnsigned flags = 0;
3137
169k
        if (parser->states[0].token == XS_TOKEN_RIGHT_BRACE)
3138
35.1k
            break;
3139
134k
        if (parser->states[0].token == XS_TOKEN_SPREAD) {
3140
1.65k
      fxGetNextToken(parser);
3141
1.65k
      fxAssignmentExpression(parser);
3142
1.65k
      fxPushNodeStruct(parser, 1, XS_TOKEN_SPREAD, aPropertyLine);
3143
1.65k
        }
3144
132k
        else {
3145
132k
      fxPropertyName(parser, &aSymbol, &aToken0, &aToken1, &aToken2, &flags);
3146
132k
      if (aToken1 == XS_TOKEN_PRIVATE_PROPERTY) {
3147
191
        fxReportParserError(parser, parser->states[0].line, "invalid private property");
3148
191
      }
3149
132k
      else if ((aToken2 == XS_TOKEN_GETTER) || (aToken2 == XS_TOKEN_SETTER)) {
3150
1.41k
        flags |= mxShorthandFlag;
3151
1.41k
        if (aToken2 == XS_TOKEN_GETTER)
3152
1.32k
          flags |= mxGetterFlag;
3153
90
        else if (aToken2 == XS_TOKEN_SETTER)
3154
90
          flags |= mxSetterFlag;
3155
1.41k
        if (parser->states[0].token == XS_TOKEN_LEFT_PARENTHESIS)
3156
1.41k
          fxFunctionExpression(parser, aPropertyLine, C_NULL, mxSuperFlag);
3157
3
        else
3158
3
          fxReportParserError(parser, parser->states[0].line, "missing (");
3159
1.41k
      }
3160
131k
      else if (aToken2 == XS_TOKEN_GENERATOR) {
3161
3.09k
        flags |= mxShorthandFlag | mxMethodFlag;
3162
3.09k
        if (parser->states[0].token == XS_TOKEN_LEFT_PARENTHESIS)
3163
2.46k
          fxGeneratorExpression(parser, aPropertyLine, C_NULL, mxSuperFlag | flags);
3164
633
        else
3165
633
          fxReportParserError(parser, parser->states[0].line, "missing (");
3166
3.09k
      }
3167
127k
      else if (aToken2 == XS_TOKEN_FUNCTION) {
3168
125
        flags |= mxShorthandFlag | mxMethodFlag;
3169
125
        if (parser->states[0].token == XS_TOKEN_LEFT_PARENTHESIS)
3170
116
          fxFunctionExpression(parser, aPropertyLine, C_NULL, mxSuperFlag | flags);
3171
9
        else
3172
9
          fxReportParserError(parser, parser->states[0].line, "missing (");
3173
125
      }
3174
127k
      else if (parser->states[0].token == XS_TOKEN_LEFT_PARENTHESIS) {
3175
3.27k
        flags |= mxShorthandFlag | mxMethodFlag;
3176
3.27k
        fxFunctionExpression(parser, aPropertyLine, C_NULL, mxSuperFlag | flags);
3177
3.27k
      }
3178
124k
      else if (parser->states[0].token == XS_TOKEN_COLON) {
3179
118k
        fxGetNextToken(parser);
3180
118k
        fxAssignmentExpression(parser);
3181
118k
      }
3182
6.10k
      else if (aToken1 == XS_TOKEN_PROPERTY) {
3183
5.06k
        flags |= mxShorthandFlag;
3184
5.06k
        fxPushSymbol(parser, aSymbol);
3185
5.06k
        if (parser->states[0].token == XS_TOKEN_ASSIGN) {
3186
3.46k
          fxPushNodeStruct(parser, 1, XS_TOKEN_ACCESS, aPropertyLine);
3187
3.46k
          fxGetNextToken(parser);
3188
3.46k
          fxAssignmentExpression(parser);
3189
3.46k
          fxPushNodeStruct(parser, 2, XS_TOKEN_BINDING, aPropertyLine);
3190
3.46k
        }
3191
1.60k
        else if (aToken0 == XS_TOKEN_IDENTIFIER) {
3192
1.02k
          fxPushNodeStruct(parser, 1, XS_TOKEN_ACCESS, aPropertyLine);
3193
1.02k
        }
3194
574
        else {
3195
574
          fxReportParserError(parser, parser->states[0].line, "invalid identifier");
3196
574
          fxPushNodeStruct(parser, 0, XS_TOKEN_UNDEFINED, aPropertyLine);
3197
574
        }
3198
5.06k
      }
3199
1.04k
      else {
3200
1.04k
        fxReportParserError(parser, parser->states[0].line, "missing :");
3201
1.04k
        fxPushNodeStruct(parser, 0, XS_TOKEN_UNDEFINED, aPropertyLine);
3202
1.04k
      }
3203
132k
      fxPushNodeStruct(parser, 2, aToken1, aPropertyLine);
3204
132k
      parser->root->flags |= flags;
3205
132k
      fxCheckUniqueProperty(parser, base, parser->root); 
3206
132k
    }
3207
134k
    aCount++;
3208
134k
        if (parser->states[0].token == XS_TOKEN_RIGHT_BRACE)
3209
39.0k
            break;
3210
95.2k
    fxMatchToken(parser, XS_TOKEN_COMMA);
3211
95.2k
  }
3212
98.5k
  fxMatchToken(parser, XS_TOKEN_RIGHT_BRACE);
3213
98.5k
  fxPushNodeList(parser, aCount);
3214
98.5k
  fxPushNodeStruct(parser, 1, XS_TOKEN_OBJECT, aLine);
3215
98.5k
}
3216
3217
void fxTemplateExpression(txParser* parser)
3218
1.11k
{
3219
1.11k
  txInteger aCount = 0;
3220
1.11k
  txInteger aLine = parser->states[0].line;
3221
1.11k
  fxPushStringNode(parser, parser->states[0].stringLength, parser->states[0].string, aLine);
3222
1.11k
  fxPushRawNode(parser, parser->states[0].rawLength, parser->states[0].raw, aLine);
3223
1.11k
  fxPushNodeStruct(parser, 2, XS_TOKEN_TEMPLATE_MIDDLE, aLine);
3224
1.11k
  aCount++;
3225
4.10k
  for (;;) {
3226
4.10k
    fxGetNextToken(parser);
3227
4.10k
        if (parser->states[0].token != XS_TOKEN_RIGHT_BRACE) {
3228
2.97k
            fxCommaExpression(parser);
3229
2.97k
            aCount++;
3230
2.97k
        }
3231
4.10k
    if (parser->states[0].token != XS_TOKEN_RIGHT_BRACE) {
3232
1
      fxReportParserError(parser, parser->states[0].line, "missing }");
3233
1
    }
3234
4.10k
    fxGetNextTokenTemplate(parser);
3235
4.10k
    fxPushStringNode(parser, parser->states[0].stringLength, parser->states[0].string, aLine);
3236
4.10k
    fxPushRawNode(parser, parser->states[0].rawLength, parser->states[0].raw, aLine);
3237
4.10k
    fxPushNodeStruct(parser, 2, XS_TOKEN_TEMPLATE_MIDDLE, aLine);
3238
4.10k
    aCount++;
3239
4.10k
    if (parser->states[0].token == XS_TOKEN_TEMPLATE_TAIL) {
3240
1.09k
      fxGetNextToken(parser);
3241
1.09k
      break;
3242
1.09k
    }
3243
4.10k
  }
3244
1.11k
  fxPushNodeList(parser, aCount);
3245
1.11k
}
3246
3247
void fxYieldExpression(txParser* parser)
3248
31.0k
{
3249
31.0k
  txInteger aLine = parser->states[0].line;
3250
31.0k
  if (!(parser->flags & mxYieldFlag))
3251
34
    fxReportParserError(parser, parser->states[0].line, "invalid yield");
3252
30.9k
  else
3253
30.9k
    parser->flags |= mxYieldingFlag;
3254
31.0k
  fxMatchToken(parser, XS_TOKEN_YIELD);
3255
31.0k
  if ((!parser->states[0].crlf) && (parser->states[0].token == XS_TOKEN_MULTIPLY)) {
3256
2.44k
    fxGetNextToken(parser);
3257
2.44k
    fxAssignmentExpression(parser);
3258
2.44k
    fxPushNodeStruct(parser, 1, XS_TOKEN_DELEGATE, aLine);
3259
2.44k
    return;
3260
2.44k
  }
3261
28.5k
  if ((!parser->states[0].crlf) && (gxTokenFlags[parser->states[0].token] & XS_TOKEN_BEGIN_EXPRESSION)) {
3262
28.0k
    fxAssignmentExpression(parser);
3263
28.0k
  }
3264
545
  else {
3265
545
    fxPushNodeStruct(parser, 0, XS_TOKEN_UNDEFINED, aLine);
3266
545
  }
3267
28.5k
  fxPushNodeStruct(parser, 1, XS_TOKEN_YIELD, aLine);
3268
28.5k
}
3269
3270
void fxParameters(txParser* parser)
3271
361k
{
3272
361k
  txInteger aCount = 0;
3273
361k
  txInteger aLine = parser->states[0].line;
3274
361k
  txBoolean aSpreadFlag = 0;
3275
361k
  fxMatchToken(parser, XS_TOKEN_LEFT_PARENTHESIS);
3276
869k
  while ((parser->states[0].token == XS_TOKEN_SPREAD) || (gxTokenFlags[parser->states[0].token] & XS_TOKEN_BEGIN_EXPRESSION)) {
3277
507k
    txInteger aParamLine = parser->states[0].line;
3278
507k
    if (parser->states[0].token == XS_TOKEN_SPREAD) {
3279
672
      fxGetNextToken(parser);
3280
672
      fxAssignmentExpression(parser);
3281
672
      fxPushNodeStruct(parser, 1, XS_TOKEN_SPREAD, aParamLine);
3282
672
      aSpreadFlag = 1;
3283
672
    }
3284
507k
    else
3285
507k
      fxAssignmentExpression(parser);
3286
507k
    aCount++;
3287
507k
    if (parser->states[0].token != XS_TOKEN_RIGHT_PARENTHESIS)
3288
211k
      fxMatchToken(parser, XS_TOKEN_COMMA);
3289
507k
  }
3290
361k
  fxMatchToken(parser, XS_TOKEN_RIGHT_PARENTHESIS);
3291
361k
  fxPushNodeList(parser, aCount);
3292
361k
  fxPushNodeStruct(parser, 1, XS_TOKEN_PARAMS, aLine);
3293
361k
  if (aSpreadFlag)
3294
506
    parser->root->flags |= mxSpreadFlag;
3295
361k
}
3296
3297
void fxPropertyName(txParser* parser, txSymbol** theSymbol, txToken* theToken0, txToken* theToken1, txToken* theToken2, txUnsigned* flag)
3298
169k
{
3299
169k
  txSymbol* aSymbol = C_NULL;
3300
169k
  txToken aToken0 = XS_NO_TOKEN;
3301
169k
  txToken aToken1 = XS_NO_TOKEN;
3302
169k
  txToken aToken2 = XS_NO_TOKEN;
3303
169k
  txInteger aLine = parser->states[0].line;
3304
169k
  txIndex index;
3305
169k
  *flag = 0;
3306
169k
  fxLookAheadOnce(parser);
3307
169k
  aToken0 = parser->states[0].token;
3308
169k
  if ((gxTokenFlags[aToken0] & XS_TOKEN_IDENTIFIER_NAME)) {
3309
124k
    aSymbol = parser->states[0].symbol;
3310
124k
    if (parser->states[1].token == XS_TOKEN_COLON) {
3311
98.7k
      fxPushSymbol(parser, aSymbol);
3312
98.7k
      aToken1 = XS_TOKEN_PROPERTY;
3313
98.7k
    }
3314
25.5k
    else if (fxIsKeyword(parser, parser->asyncSymbol) && (!parser->states[1].crlf)) {
3315
3.98k
      *flag = mxAsyncFlag;
3316
3.98k
      fxGetNextToken(parser);
3317
3.98k
      if (parser->states[0].token == XS_TOKEN_MULTIPLY) {
3318
2.50k
        aToken2 = XS_TOKEN_GENERATOR;
3319
2.50k
        fxGetNextToken(parser);
3320
2.50k
      }
3321
1.47k
      else
3322
1.47k
        aToken2 = XS_TOKEN_FUNCTION;
3323
3.98k
    }
3324
21.5k
    else if (fxIsKeyword(parser, parser->getSymbol)) {
3325
2.88k
      aToken2 = XS_TOKEN_GETTER;
3326
2.88k
      fxGetNextToken(parser);
3327
2.88k
    }
3328
18.6k
    else if (fxIsKeyword(parser, parser->setSymbol)) {
3329
746
      aToken2 = XS_TOKEN_SETTER;
3330
746
      fxGetNextToken(parser);
3331
746
    }
3332
17.8k
    else {
3333
17.8k
      fxPushSymbol(parser, aSymbol);
3334
17.8k
      aToken1 = XS_TOKEN_PROPERTY;
3335
17.8k
    }
3336
124k
  }
3337
45.3k
  else if (parser->states[0].token == XS_TOKEN_MULTIPLY) {
3338
4.10k
    aToken2 = XS_TOKEN_GENERATOR;
3339
4.10k
    fxGetNextToken(parser);
3340
4.10k
  }
3341
41.2k
  else if (parser->states[0].token == XS_TOKEN_PRIVATE_IDENTIFIER) {
3342
6.84k
    aSymbol = parser->states[0].symbol;
3343
6.84k
    fxPushSymbol(parser, aSymbol);
3344
6.84k
    aToken1 = XS_TOKEN_PRIVATE_PROPERTY;
3345
6.84k
  }
3346
34.3k
  else if (parser->states[0].token == XS_TOKEN_INTEGER) {
3347
11.7k
    if (fxIntegerToIndex(parser->console, parser->states[0].integer, &index)) {
3348
11.7k
      fxPushIndexNode(parser, index, aLine);
3349
11.7k
      aToken1 = XS_TOKEN_PROPERTY_AT;
3350
11.7k
    }
3351
0
    else {
3352
0
      aSymbol = fxNewParserSymbol(parser, fxIntegerToString(parser->console, parser->states[0].integer, parser->buffer, parser->bufferSize));
3353
0
      fxPushSymbol(parser, aSymbol);
3354
0
      aToken1 = XS_TOKEN_PROPERTY;
3355
0
    }
3356
11.7k
  }
3357
22.5k
  else if (parser->states[0].token == XS_TOKEN_NUMBER) {
3358
467
    if (fxNumberToIndex(parser->console, parser->states[0].number, &index)) {
3359
97
      fxPushIndexNode(parser, index, aLine);
3360
97
      aToken1 = XS_TOKEN_PROPERTY_AT;
3361
97
    }
3362
370
    else {
3363
370
      aSymbol = fxNewParserSymbol(parser, fxNumberToString(parser->console, parser->states[0].number, parser->buffer, parser->bufferSize, 0, 0));
3364
370
      fxPushSymbol(parser, aSymbol);
3365
370
      aToken1 = XS_TOKEN_PROPERTY;
3366
370
    }
3367
467
  }
3368
22.1k
  else if (parser->states[0].token == XS_TOKEN_STRING) {
3369
16.0k
    if (fxStringToIndex(parser->console, parser->states[0].string, &index)) {
3370
4.07k
      fxPushIndexNode(parser, index, aLine);
3371
4.07k
      aToken1 = XS_TOKEN_PROPERTY_AT;
3372
4.07k
    }
3373
11.9k
    else {
3374
11.9k
      aSymbol = fxNewParserSymbol(parser, parser->states[0].string);
3375
11.9k
      fxPushSymbol(parser, aSymbol);
3376
11.9k
      aToken1 = XS_TOKEN_PROPERTY;
3377
11.9k
    }
3378
16.0k
  }
3379
6.11k
  else if (parser->states[0].token == XS_TOKEN_LEFT_BRACKET) {
3380
3.24k
    fxGetNextToken(parser);
3381
3.24k
    fxCommaExpression(parser);
3382
3.24k
    if (parser->states[0].token != XS_TOKEN_RIGHT_BRACKET) {
3383
231
      fxReportParserError(parser, parser->states[0].line, "missing ]");
3384
231
    }
3385
3.24k
    aToken1 = XS_TOKEN_PROPERTY_AT;
3386
3.24k
  }
3387
2.87k
  else {
3388
2.87k
    fxReportParserError(parser, parser->states[0].line, "missing identifier");
3389
2.87k
    fxPushNULL(parser);
3390
2.87k
  }
3391
169k
  if (aToken2 != XS_NO_TOKEN) {
3392
11.7k
    if ((gxTokenFlags[parser->states[0].token] & XS_TOKEN_IDENTIFIER_NAME)) {
3393
5.47k
      aSymbol = parser->states[0].symbol;
3394
5.47k
      fxPushSymbol(parser, aSymbol);
3395
5.47k
      aToken1 = XS_TOKEN_PROPERTY;
3396
5.47k
      fxGetNextToken(parser);
3397
5.47k
    }
3398
6.23k
    else if (parser->states[0].token == XS_TOKEN_PRIVATE_IDENTIFIER) {
3399
226
      aSymbol = parser->states[0].symbol;
3400
226
      fxPushSymbol(parser, aSymbol);
3401
226
      aToken1 = XS_TOKEN_PRIVATE_PROPERTY;
3402
226
      fxGetNextToken(parser);
3403
226
    }
3404
6.01k
    else if (parser->states[0].token == XS_TOKEN_INTEGER) {
3405
996
      if (fxIntegerToIndex(parser->console, parser->states[0].integer, &index)) {
3406
996
        fxPushIndexNode(parser, index, aLine);
3407
996
        aToken1 = XS_TOKEN_PROPERTY_AT;
3408
996
      }
3409
0
      else {
3410
0
        aSymbol = fxNewParserSymbol(parser, fxIntegerToString(parser->console, parser->states[0].integer, parser->buffer, parser->bufferSize));
3411
0
        fxPushSymbol(parser, aSymbol);
3412
0
        aToken1 = XS_TOKEN_PROPERTY;
3413
0
      }
3414
996
      fxGetNextToken(parser);
3415
996
    }
3416
5.01k
    else if (parser->states[0].token == XS_TOKEN_NUMBER) {
3417
422
      if (fxNumberToIndex(parser->console, parser->states[0].number, &index)) {
3418
4
        fxPushIndexNode(parser, index, aLine);
3419
4
        aToken1 = XS_TOKEN_PROPERTY_AT;
3420
4
      }
3421
418
      else {
3422
418
        aSymbol = fxNewParserSymbol(parser, fxNumberToString(parser->console, parser->states[0].number, parser->buffer, parser->bufferSize, 0, 0));
3423
418
        fxPushSymbol(parser, aSymbol);
3424
418
        aToken1 = XS_TOKEN_PROPERTY;
3425
418
      }
3426
422
      fxGetNextToken(parser);
3427
422
    }
3428
4.59k
    else if (parser->states[0].token == XS_TOKEN_STRING) {
3429
1.72k
      if (fxStringToIndex(parser->console, parser->states[0].string, &index)) {
3430
861
        fxPushIndexNode(parser, index, aLine);
3431
861
        aToken1 = XS_TOKEN_PROPERTY_AT;
3432
861
      }
3433
860
      else {
3434
860
        aSymbol = fxNewParserSymbol(parser, parser->states[0].string);
3435
860
        fxPushSymbol(parser, aSymbol);
3436
860
        aToken1 = XS_TOKEN_PROPERTY;
3437
860
      }
3438
1.72k
      fxGetNextToken(parser);
3439
1.72k
    }
3440
2.87k
    else if (parser->states[0].token == XS_TOKEN_LEFT_BRACKET) {
3441
722
      fxGetNextToken(parser);
3442
722
      fxCommaExpression(parser);
3443
722
      if (parser->states[0].token != XS_TOKEN_RIGHT_BRACKET) {
3444
189
        fxReportParserError(parser, parser->states[0].line, "missing ]");
3445
189
      }
3446
722
      aToken1 = XS_TOKEN_PROPERTY_AT;
3447
722
      fxGetNextToken(parser);
3448
722
    }
3449
2.15k
    else if (aToken2 == XS_TOKEN_GETTER) {
3450
1.40k
      fxPushSymbol(parser, aSymbol);
3451
1.40k
      aToken1 = XS_TOKEN_PROPERTY;
3452
1.40k
      aToken2 = XS_NO_TOKEN;
3453
1.40k
    }
3454
745
    else if (aToken2 == XS_TOKEN_SETTER) {
3455
200
      fxPushSymbol(parser, aSymbol);
3456
200
      aToken1 = XS_TOKEN_PROPERTY;
3457
200
      aToken2 = XS_NO_TOKEN;
3458
200
    }
3459
545
    else {
3460
545
      fxReportParserError(parser, parser->states[0].line, "missing identifier");
3461
545
      fxPushNULL(parser);
3462
545
    }
3463
11.7k
  }
3464
157k
  else
3465
157k
    fxGetNextToken(parser);
3466
169k
  *theSymbol = aSymbol;
3467
169k
  *theToken0 = aToken0;
3468
169k
  *theToken1 = aToken1;
3469
169k
  *theToken2 = aToken2;
3470
169k
}
3471
3472
void fxBinding(txParser* parser, txToken theToken, txUnsigned flags)
3473
204k
{
3474
204k
  txInteger aLine = parser->states[0].line;
3475
204k
  fxCheckParserStack(parser, aLine);
3476
204k
  if (parser->states[0].token == XS_TOKEN_IDENTIFIER) {
3477
171k
    fxCheckStrictSymbol(parser, parser->states[0].symbol);
3478
171k
    if (((theToken == XS_TOKEN_CONST) || (theToken == XS_TOKEN_LET) || (theToken == XS_TOKEN_USING)) && (parser->states[0].symbol == parser->letSymbol))
3479
18
      fxReportParserError(parser, parser->states[0].line, "invalid identifier");
3480
171k
    fxPushSymbol(parser, parser->states[0].symbol);
3481
171k
    fxPushNodeStruct(parser, 1, theToken, aLine);
3482
171k
    if (flags & mxAwaitingFlag)
3483
0
      parser->root->flags |= mxAwaitingFlag;
3484
171k
    fxGetNextToken(parser);
3485
171k
  }
3486
33.5k
  else if (parser->states[0].token == XS_TOKEN_LEFT_BRACE) {
3487
13.1k
    if (theToken == XS_TOKEN_USING)
3488
1
      fxReportParserError(parser, parser->states[0].line, "invalid using");
3489
13.1k
    fxObjectBinding(parser, theToken);
3490
13.1k
  }
3491
20.4k
  else if (parser->states[0].token == XS_TOKEN_LEFT_BRACKET) {
3492
19.5k
    if (theToken == XS_TOKEN_USING)
3493
1
      fxReportParserError(parser, parser->states[0].line, "invalid using");
3494
19.5k
    fxArrayBinding(parser, theToken);
3495
19.5k
  }
3496
833
  else {
3497
833
    fxReportParserError(parser, parser->states[0].line, "missing identifier");
3498
833
    fxPushNULL(parser);
3499
833
  }
3500
204k
  if ((flags & 1) && (parser->states[0].token == XS_TOKEN_ASSIGN)) {
3501
90.3k
    parser->flags &= ~mxForFlag;
3502
90.3k
    fxGetNextToken(parser);
3503
90.3k
    fxAssignmentExpression(parser);
3504
90.3k
    fxPushNodeStruct(parser, 2, XS_TOKEN_BINDING, aLine);
3505
90.3k
  }
3506
204k
}
3507
3508
txNode* fxBindingFromExpression(txParser* parser, txNode* theNode, txToken theToken)
3509
95.2k
{
3510
95.2k
  txToken aToken = (theNode && theNode->description) ? theNode->description->token : XS_NO_TOKEN;
3511
95.2k
  txNode* binding;
3512
95.3k
again:
3513
95.3k
  if (aToken == XS_TOKEN_EXPRESSIONS) {
3514
769
    txNode* item = ((txExpressionsNode*)theNode)->items->first;
3515
769
    if (item && !item->next) {
3516
720
      aToken = item->description->token;
3517
720
      if ((aToken == XS_TOKEN_ACCESS) || (aToken == XS_TOKEN_MEMBER) || (aToken == XS_TOKEN_MEMBER_AT) || (aToken == XS_TOKEN_PRIVATE_MEMBER) || (aToken == XS_TOKEN_UNDEFINED)) {
3518
663
        item->next = theNode->next;
3519
663
        theNode = item;
3520
663
      }
3521
57
      else if (aToken == XS_TOKEN_EXPRESSIONS) {
3522
56
        item->next = theNode->next;
3523
56
        theNode = item;
3524
56
        goto again;
3525
56
      }
3526
1
      else
3527
1
        return NULL;
3528
720
    }
3529
769
  }
3530
95.2k
  if (aToken == XS_TOKEN_BINDING) {
3531
25.9k
    binding = fxBindingFromExpression(parser, ((txBindingNode*)theNode)->target, theToken);
3532
25.9k
    ((txBindingNode*)theNode)->target = binding;
3533
//    fxCheckStrictBinding(parser, theNode);
3534
//    fxCheckStrictSymbol(parser, ((txBindingNode*)theNode)->symbol);
3535
//    theNode->description = &gxTokenDescriptions[theToken];
3536
25.9k
    return theNode;
3537
25.9k
  }
3538
69.2k
  if (aToken == XS_TOKEN_ARRAY_BINDING) {
3539
36.9k
    txNodeList* list = ((txArrayBindingNode*)theNode)->items;
3540
36.9k
    txNode** address = &(list->first);
3541
36.9k
    txNode* item;
3542
74.1k
    while ((item = *address)) {
3543
37.2k
      txNode* binding = *address = fxBindingFromExpression(parser, item, theToken);
3544
37.2k
      binding->next = item->next;
3545
37.2k
      address = &(binding->next);
3546
37.2k
    }
3547
36.9k
    return theNode;
3548
36.9k
  }
3549
32.3k
  if (aToken == XS_TOKEN_OBJECT_BINDING) {
3550
866
    txNodeList* list = ((txObjectBindingNode*)theNode)->items;
3551
866
    txNode** address = &(list->first);
3552
866
    txNode* item;
3553
2.15k
    while ((item = *address)) {
3554
1.28k
      txNode* binding = *address = fxBindingFromExpression(parser, item, theToken);
3555
1.28k
      binding->next = item->next;
3556
1.28k
      address = &(binding->next);
3557
1.28k
    }
3558
866
    return theNode;
3559
866
  }
3560
31.4k
  if (aToken == XS_TOKEN_PROPERTY_BINDING) {
3561
1.28k
    ((txPropertyBindingNode*)theNode)->binding = fxBindingFromExpression(parser, ((txPropertyBindingNode*)theNode)->binding, theToken);
3562
1.28k
    return theNode;
3563
1.28k
  }
3564
30.2k
  if (aToken == XS_TOKEN_PROPERTY_BINDING_AT) {
3565
1
    ((txPropertyBindingAtNode*)theNode)->binding = fxBindingFromExpression(parser, ((txPropertyBindingAtNode*)theNode)->binding, theToken);
3566
1
    return theNode;
3567
1
  }
3568
30.2k
  if (aToken == XS_TOKEN_REST_BINDING) {
3569
105
    ((txRestBindingNode*)theNode)->binding = fxBindingFromExpression(parser, ((txRestBindingNode*)theNode)->binding, theToken);
3570
105
    return theNode;
3571
105
  }
3572
30.1k
  if (aToken == XS_TOKEN_SKIP_BINDING)
3573
323
    return theNode;
3574
  
3575
29.7k
  if (aToken == XS_TOKEN_ACCESS) {
3576
20.7k
    fxCheckStrictSymbol(parser, ((txAccessNode*)theNode)->symbol);
3577
20.7k
    if (theToken == XS_TOKEN_ACCESS)
3578
5.64k
      return theNode;
3579
15.0k
    fxPushSymbol(parser, ((txAccessNode*)theNode)->symbol);
3580
15.0k
    fxPushNodeStruct(parser, 1, theToken, ((txAccessNode*)theNode)->line);
3581
15.0k
    return fxPopNode(parser);
3582
20.7k
  }
3583
9.04k
  if ((aToken == XS_TOKEN_MEMBER) || (aToken == XS_TOKEN_MEMBER_AT) || (aToken == XS_TOKEN_PRIVATE_MEMBER) || (aToken == XS_TOKEN_UNDEFINED)) {
3584
2.68k
    return theNode;
3585
2.68k
  }
3586
6.36k
  if (aToken == XS_TOKEN_ASSIGN) {
3587
1.38k
    binding = fxBindingFromExpression(parser, ((txAssignNode*)theNode)->reference, theToken);
3588
1.38k
    if (!binding)
3589
0
      return NULL;
3590
1.38k
    ((txBindingNode*)theNode)->description = &gxTokenDescriptions[XS_TOKEN_BINDING];
3591
1.38k
    ((txBindingNode*)theNode)->target = binding;
3592
1.38k
    ((txBindingNode*)theNode)->initializer = ((txAssignNode*)theNode)->value;
3593
1.38k
    return theNode;
3594
1.38k
  }
3595
  
3596
4.98k
  if (aToken == XS_TOKEN_ARRAY)
3597
1.17k
    return fxArrayBindingFromExpression(parser, theNode, theToken);
3598
3.81k
  if (aToken == XS_TOKEN_OBJECT)
3599
156
    return fxObjectBindingFromExpression(parser, theNode, theToken);
3600
3.65k
  return NULL;
3601
3.81k
}
3602
3603
void fxArrayBinding(txParser* parser, txToken theToken)
3604
19.5k
{
3605
19.5k
  txInteger aCount = 0;
3606
19.5k
  txInteger aLine = parser->states[0].line;
3607
19.5k
  int elision = 1;
3608
19.5k
  fxCheckParserStack(parser, aLine);
3609
19.5k
  fxMatchToken(parser, XS_TOKEN_LEFT_BRACKET);
3610
27.0k
  while ((parser->states[0].token == XS_TOKEN_COMMA) || (gxTokenFlags[parser->states[0].token] & XS_TOKEN_BEGIN_BINDING)) {
3611
7.49k
    txInteger anItemLine = parser->states[0].line;
3612
7.49k
    if (parser->states[0].token == XS_TOKEN_COMMA) {
3613
3.55k
      fxGetNextToken(parser);
3614
3.55k
      if (elision) {
3615
1.34k
        fxPushNodeStruct(parser, 0, XS_TOKEN_SKIP_BINDING, anItemLine);
3616
1.34k
        aCount++;
3617
1.34k
      }
3618
2.21k
      else
3619
2.21k
        elision = 1;
3620
3.55k
    }
3621
3.93k
    else {
3622
3.93k
      if (!elision)
3623
368
        fxReportParserError(parser, parser->states[0].line, "missing ,");
3624
3.93k
      if (parser->states[0].token == XS_TOKEN_SPREAD) {
3625
42
        fxRestBinding(parser, theToken, 0);
3626
42
        aCount++;
3627
42
        break;
3628
42
      }
3629
3.89k
      fxBinding(parser, theToken, 1);
3630
3.89k
      aCount++;
3631
3.89k
      elision = 0;
3632
3.89k
    }
3633
7.49k
  }
3634
19.5k
  fxMatchToken(parser, XS_TOKEN_RIGHT_BRACKET);
3635
19.5k
  fxPushNodeList(parser, aCount);
3636
19.5k
  fxPushNodeStruct(parser, 1, XS_TOKEN_ARRAY_BINDING, aLine);
3637
19.5k
}
3638
3639
txNode* fxArrayBindingFromExpression(txParser* parser, txNode* theNode, txToken theToken)
3640
5.06k
{
3641
5.06k
  txNodeList* list = ((txArrayNode*)theNode)->items;
3642
5.06k
  txNode** address = &(list->first);
3643
5.06k
  txNode* item;
3644
5.06k
  txNode* binding;
3645
8.96k
  while ((item = *address)) {
3646
7.35k
        if (!item->description) {
3647
0
            parser->errorSymbol = parser->SyntaxErrorSymbol;
3648
0
            return NULL;
3649
0
        }
3650
7.35k
    if (item->description->token == XS_TOKEN_SPREAD) {
3651
106
      if (theNode->flags & mxElisionFlag) {
3652
1
        parser->errorSymbol = parser->SyntaxErrorSymbol;
3653
1
        return NULL;
3654
1
      }
3655
105
      binding = fxRestBindingFromExpression(parser, item, theToken, 0);
3656
105
      if (!binding) {
3657
6
        parser->errorSymbol = parser->SyntaxErrorSymbol;
3658
6
        return NULL;
3659
6
      }
3660
99
      break;
3661
105
    }
3662
7.25k
    if (item->description->token == XS_TOKEN_ELISION) {
3663
399
      item->description = &gxTokenDescriptions[XS_TOKEN_SKIP_BINDING];
3664
399
    }
3665
6.85k
    else {
3666
//      if ((theToken == XS_TOKEN_BINDING) && ((item->description->token== XS_TOKEN_MEMBER) || (item->description->token == XS_TOKEN_MEMBER_AT)))
3667
//        binding = item;
3668
//      else {      
3669
6.85k
        binding = fxBindingFromExpression(parser, item, theToken);
3670
6.85k
        if (!binding) {
3671
3.35k
          parser->errorSymbol = parser->SyntaxErrorSymbol;
3672
3.35k
          return NULL;
3673
3.35k
        }
3674
3.49k
        binding->next = item->next;
3675
3.49k
        item = *address = binding;
3676
//      }
3677
3.49k
    }
3678
3.89k
    address = &(item->next);
3679
3.89k
  }
3680
1.70k
  fxPushNode(parser, (txNode*)list);
3681
1.70k
  fxPushNodeStruct(parser, 1, XS_TOKEN_ARRAY_BINDING, theNode->line);
3682
1.70k
  return fxPopNode(parser);
3683
5.06k
}
3684
3685
txUnsigned fxObjectBinding(txParser* parser, txToken theToken)
3686
13.1k
{
3687
13.1k
  txUnsigned flags = 0;
3688
13.1k
  txInteger aCount = 0;
3689
13.1k
  txInteger aLine = parser->states[0].line;
3690
13.1k
  txSymbol* aSymbol;
3691
13.1k
  txToken aToken;
3692
13.1k
  txIndex index;
3693
13.1k
  fxMatchToken(parser, XS_TOKEN_LEFT_BRACE);
3694
16.9k
  for (;;) {
3695
16.9k
    txInteger aPropertyLine = parser->states[0].line;
3696
16.9k
    if (parser->states[0].token == XS_TOKEN_RIGHT_BRACE)
3697
2.41k
      break;
3698
14.5k
    aSymbol = NULL;
3699
14.5k
    aToken = XS_TOKEN_PROPERTY_BINDING;
3700
14.5k
    if ((gxTokenFlags[parser->states[0].token] & XS_TOKEN_IDENTIFIER_NAME)) {
3701
8.52k
      aSymbol = parser->states[0].symbol;
3702
8.52k
      fxPushSymbol(parser, aSymbol);
3703
8.52k
      aToken = XS_TOKEN_PROPERTY_BINDING;
3704
8.52k
    }
3705
5.97k
    else if (parser->states[0].token == XS_TOKEN_INTEGER) {
3706
1.26k
      if (fxIntegerToIndex(parser->console, parser->states[0].integer, &index)) {
3707
1.26k
        fxPushIndexNode(parser, index, aPropertyLine);
3708
1.26k
        aToken = XS_TOKEN_PROPERTY_BINDING_AT;
3709
1.26k
      }
3710
0
      else {
3711
0
        aSymbol = fxNewParserSymbol(parser, fxIntegerToString(parser->console, parser->states[0].integer, parser->buffer, parser->bufferSize));
3712
0
        fxPushSymbol(parser, aSymbol);
3713
0
        aToken = XS_TOKEN_PROPERTY_BINDING;
3714
0
      }
3715
1.26k
    }
3716
4.70k
    else if (parser->states[0].token == XS_TOKEN_NUMBER) {
3717
81
      if (fxNumberToIndex(parser->console, parser->states[0].number, &index)) {
3718
3
        fxPushIndexNode(parser, index, aPropertyLine);
3719
3
        aToken = XS_TOKEN_PROPERTY_BINDING_AT;
3720
3
      }
3721
78
      else {
3722
78
        aSymbol = fxNewParserSymbol(parser, fxNumberToString(parser->console, parser->states[0].number, parser->buffer, parser->bufferSize, 0, 0));
3723
78
        fxPushSymbol(parser, aSymbol);
3724
78
        aToken = XS_TOKEN_PROPERTY_BINDING;
3725
78
      }
3726
81
    }
3727
4.62k
    else if (parser->states[0].token == XS_TOKEN_STRING) {
3728
614
      if (fxStringToIndex(parser->console, parser->states[0].string, &index)) {
3729
3
        fxPushIndexNode(parser, index, aPropertyLine);
3730
3
        aToken = XS_TOKEN_PROPERTY_BINDING_AT;
3731
3
      }
3732
611
      else {
3733
611
        aSymbol = fxNewParserSymbol(parser, parser->states[0].string);
3734
611
        fxPushSymbol(parser, aSymbol);
3735
611
        aToken = XS_TOKEN_PROPERTY_BINDING;
3736
611
      }
3737
614
    }
3738
4.01k
    else if (parser->states[0].token == XS_TOKEN_LEFT_BRACKET) {
3739
3.34k
      fxGetNextToken(parser);
3740
3.34k
      fxCommaExpression(parser);
3741
3.34k
      if (parser->states[0].token != XS_TOKEN_RIGHT_BRACKET) {
3742
723
        fxReportParserError(parser, parser->states[0].line, "missing ]");
3743
723
      }
3744
3.34k
      aToken = XS_TOKEN_PROPERTY_BINDING_AT;
3745
3.34k
    }
3746
670
    else if (parser->states[0].token == XS_TOKEN_SPREAD) {
3747
97
      flags |= mxSpreadFlag;
3748
97
      fxRestBinding(parser, theToken, 1);
3749
97
      aCount++;
3750
97
            break;
3751
97
    }
3752
573
    else {
3753
573
      fxReportParserError(parser, parser->states[0].line, "missing identifier");
3754
573
      fxPushNULL(parser);
3755
573
    }
3756
14.4k
    fxLookAheadOnce(parser);
3757
14.4k
    if (parser->states[1].token == XS_TOKEN_COLON) {
3758
557
      fxGetNextToken(parser);
3759
557
      fxGetNextToken(parser);
3760
557
      fxBinding(parser, theToken, 1);
3761
557
    }
3762
13.8k
    else if (aSymbol) {
3763
8.64k
      fxBinding(parser, theToken, 1);
3764
8.64k
    }
3765
5.20k
    else {
3766
5.20k
      fxReportParserError(parser, parser->states[0].line, "missing :");
3767
5.20k
      fxPushNULL(parser);
3768
5.20k
    }
3769
14.4k
    fxPushNodeStruct(parser, 2, aToken, aPropertyLine);
3770
14.4k
    aCount++;
3771
14.4k
        if (parser->states[0].token == XS_TOKEN_RIGHT_BRACE)
3772
3.59k
            break;
3773
10.8k
    if (parser->states[0].token == XS_TOKEN_COMMA)
3774
3.75k
      fxGetNextToken(parser);
3775
7.05k
    else
3776
7.05k
            break;
3777
10.8k
  }
3778
13.1k
  fxMatchToken(parser, XS_TOKEN_RIGHT_BRACE);
3779
13.1k
  fxPushNodeList(parser, aCount);
3780
13.1k
  fxPushNodeStruct(parser, 1, XS_TOKEN_OBJECT_BINDING, aLine);
3781
13.1k
  parser->root->flags |= flags;
3782
13.1k
  return flags;
3783
13.1k
}
3784
3785
txNode* fxObjectBindingFromExpression(txParser* parser, txNode* theNode, txToken theToken)
3786
19.2k
{
3787
19.2k
  txNodeList* list = ((txObjectNode*)theNode)->items;
3788
19.2k
  txNode* property = list->first;
3789
19.2k
  txNode* binding;
3790
19.2k
  txUnsigned flags = 0;
3791
25.9k
  while (property) {
3792
7.93k
    if (!property->description) {
3793
0
      parser->errorSymbol = parser->SyntaxErrorSymbol;
3794
0
      return NULL;
3795
0
    }
3796
7.93k
    if (property->description->token == XS_TOKEN_PROPERTY) {
3797
4.39k
      binding = fxBindingFromExpression(parser, ((txPropertyNode*)property)->value, theToken);
3798
4.39k
      if (!binding) {
3799
274
        parser->errorSymbol = parser->SyntaxErrorSymbol;
3800
274
        return NULL;
3801
274
      }
3802
4.12k
      property->description = &gxTokenDescriptions[XS_TOKEN_PROPERTY_BINDING];
3803
4.12k
      ((txPropertyBindingNode*)property)->binding = binding;
3804
4.12k
    }
3805
3.53k
    else if (property->description->token == XS_TOKEN_PROPERTY_AT) {
3806
2.57k
      binding = fxBindingFromExpression(parser, ((txPropertyAtNode*)property)->value, theToken);
3807
2.57k
      if (!binding) {
3808
13
        parser->errorSymbol = parser->SyntaxErrorSymbol;
3809
13
        return NULL;
3810
13
      }
3811
2.55k
      property->description = &gxTokenDescriptions[XS_TOKEN_PROPERTY_BINDING_AT];
3812
2.55k
      ((txPropertyBindingAtNode*)property)->binding = binding;
3813
2.55k
    }
3814
961
    else if (property->description->token == XS_TOKEN_SPREAD) {
3815
961
      binding = fxRestBindingFromExpression(parser, property, theToken, 1);
3816
961
      if (!binding) {
3817
62
        parser->errorSymbol = parser->SyntaxErrorSymbol;
3818
62
        return NULL;
3819
62
      }
3820
899
      flags |= mxSpreadFlag;
3821
899
      break;
3822
961
    }
3823
6.68k
    property = property->next;
3824
6.68k
  }
3825
18.8k
  fxPushNode(parser, (txNode*)list);
3826
18.8k
  fxPushNodeStruct(parser, 1, XS_TOKEN_OBJECT_BINDING, theNode->line);
3827
18.8k
  parser->root->flags |= flags;
3828
18.8k
  return fxPopNode(parser);
3829
19.2k
}
3830
3831
void fxParametersBinding(txParser* parser)
3832
234k
{
3833
234k
  txInteger aCount = 0;
3834
234k
  txInteger aLine = parser->states[0].line;
3835
234k
  txBindingNode* binding;
3836
234k
  if (parser->states[0].token == XS_TOKEN_LEFT_PARENTHESIS) {
3837
231k
    fxGetNextToken(parser);
3838
245k
    while (gxTokenFlags[parser->states[0].token] & XS_TOKEN_BEGIN_BINDING) {
3839
14.6k
      if (parser->states[0].token == XS_TOKEN_SPREAD) {
3840
324
        parser->flags |= mxNotSimpleParametersFlag;
3841
324
        fxRestBinding(parser, XS_TOKEN_ARG, 0);
3842
324
        aCount++;
3843
324
        break;
3844
324
      }
3845
14.3k
      fxBinding(parser, XS_TOKEN_ARG, 1);
3846
14.3k
      binding = (txBindingNode*)parser->root;
3847
14.3k
      if (binding->description->token != XS_TOKEN_ARG)
3848
525
        parser->flags |= mxNotSimpleParametersFlag;
3849
14.3k
      aCount++;
3850
14.3k
      if (parser->states[0].token != XS_TOKEN_RIGHT_PARENTHESIS)
3851
6.70k
        fxMatchToken(parser, XS_TOKEN_COMMA);
3852
14.3k
    }
3853
231k
    fxMatchToken(parser, XS_TOKEN_RIGHT_PARENTHESIS);
3854
231k
  }
3855
2.91k
  else
3856
2.91k
    fxReportParserError(parser, parser->states[0].line, "missing (");
3857
234k
  fxPushNodeList(parser, aCount);
3858
234k
  fxPushNodeStruct(parser, 1, XS_TOKEN_PARAMS_BINDING, aLine);
3859
234k
}
3860
3861
txNode* fxParametersBindingFromExpressions(txParser* parser, txNode* theNode)
3862
44.4k
{
3863
44.4k
  txNodeList* list = ((txParamsNode*)theNode)->items;
3864
44.4k
  txNode** address = &(list->first);
3865
44.4k
  txNode* item;
3866
44.4k
  txBindingNode* binding;
3867
57.2k
  while ((item = *address)) {
3868
13.1k
    txToken aToken = (item && item->description) ? item->description->token : XS_NO_TOKEN;
3869
13.1k
    if (aToken == XS_TOKEN_SPREAD) {
3870
17
      binding = (txBindingNode*)fxRestBindingFromExpression(parser, item, XS_TOKEN_ARG, 0);
3871
17
      if (!binding)
3872
1
        return NULL;
3873
16
      parser->flags |= mxNotSimpleParametersFlag;
3874
16
      break;
3875
17
    }
3876
13.1k
    binding = (txBindingNode*)fxBindingFromExpression(parser, item, XS_TOKEN_ARG);
3877
13.1k
    if (!binding)
3878
283
      return NULL;
3879
12.8k
    if (binding->description->token != XS_TOKEN_ARG)
3880
1.25k
      parser->flags |= mxNotSimpleParametersFlag;
3881
12.8k
    binding->next = item->next;
3882
12.8k
    item = *address = (txNode*)binding;
3883
12.8k
    address = &(item->next);
3884
12.8k
  }
3885
44.1k
  theNode->description = &gxTokenDescriptions[XS_TOKEN_PARAMS_BINDING];
3886
44.1k
  return theNode;
3887
44.4k
}
3888
3889
void fxRestBinding(txParser* parser, txToken theToken, txUnsigned flag)
3890
463
{
3891
463
  txInteger aLine = parser->states[0].line;
3892
463
  fxMatchToken(parser, XS_TOKEN_SPREAD);
3893
463
  fxBinding(parser, theToken, 0);
3894
463
  if (flag && ((parser->root->description->token == XS_TOKEN_ARRAY_BINDING) || (parser->root->description->token == XS_TOKEN_OBJECT_BINDING))) {
3895
46
    fxReportParserError(parser, parser->states[0].line, "invalid rest");
3896
46
  }
3897
463
  fxPushNodeStruct(parser, 1, XS_TOKEN_REST_BINDING, aLine);
3898
463
}
3899
3900
txNode* fxRestBindingFromExpression(txParser* parser, txNode* theNode, txToken theToken, txUnsigned flag)
3901
1.08k
{
3902
1.08k
  txNode* expression = ((txSpreadNode*)theNode)->expression;
3903
1.08k
  txNode* binding;
3904
1.08k
  if (theNode->next) {
3905
3
    parser->errorSymbol = parser->SyntaxErrorSymbol;
3906
3
    return NULL;
3907
3
  }
3908
1.08k
  if (!expression)
3909
0
    return NULL;
3910
/*  if ((theToken == XS_TOKEN_BINDING) && ((expression->description->token == XS_TOKEN_MEMBER) || (expression->description->token == XS_TOKEN_MEMBER_AT)))
3911
    binding = expression;
3912
  else */
3913
1.08k
  {
3914
1.08k
    binding = fxBindingFromExpression(parser, expression, theToken);
3915
1.08k
    if (!binding) {
3916
66
      parser->errorSymbol = parser->SyntaxErrorSymbol;
3917
66
      return NULL;
3918
66
    }
3919
1.01k
    if (binding->description->token == XS_TOKEN_BINDING) {
3920
42
      fxReportParserError(parser, parser->states[0].line, "invalid rest");
3921
42
      return NULL;
3922
42
    }
3923
972
    if (flag && ((binding->description->token == XS_TOKEN_ARRAY_BINDING) || (binding->description->token == XS_TOKEN_OBJECT_BINDING))) {
3924
58
      fxReportParserError(parser, parser->states[0].line, "invalid rest");
3925
58
      return NULL;
3926
58
    }
3927
972
  }
3928
914
  theNode->description = &gxTokenDescriptions[XS_TOKEN_REST_BINDING];
3929
914
  ((txRestBindingNode*)theNode)->binding = binding;
3930
914
  return theNode;
3931
972
}
3932
3933
void fxCheckArrowFunction(txParser* parser, txInteger count)
3934
13.6M
{
3935
13.6M
  txNode* node = parser->root;
3936
40.3M
  while (count) {
3937
26.6M
    if (node->flags & mxArrowFlag)
3938
17.7k
      fxReportParserError(parser, parser->states[0].line, "invalid arrow function");
3939
26.6M
    count--;
3940
26.6M
    node = node->next;
3941
26.6M
  }
3942
13.6M
}
3943
3944
static void fxReportWarning(txParser* parser, txInteger line, txString theFormat, ...)
3945
0
{
3946
0
  c_va_list arguments;
3947
0
  c_va_start(arguments, theFormat);
3948
0
    (*parser->reportWarning)(parser->console, parser->path ? parser->path->string : C_NULL, line, theFormat, arguments);
3949
0
  c_va_end(arguments);
3950
0
}
3951
3952
void fxCheckNativeConstructor(txParser* parser)
3953
428
{
3954
428
  txClassNode* root = (txClassNode*)(parser->root);
3955
428
  if (root->description != &gxTokenDescriptions[XS_TOKEN_CLASS])
3956
399
    return;
3957
29
  if (root->symbol != C_NULL)
3958
5
    return;
3959
24
  txHostNode* host = (txHostNode*)(root->heritage);
3960
24
  if (host == C_NULL)
3961
23
    return;
3962
1
  if (host->description != &gxTokenDescriptions[XS_TOKEN_HOST])
3963
1
    return;
3964
0
  if (root->constructorInit != C_NULL)
3965
0
    return;
3966
0
  if (root->instanceInit != C_NULL)
3967
0
    return;
3968
0
  txFunctionNode* constructor = (txFunctionNode*)(root->constructor);
3969
0
  if (constructor->description != &gxTokenDescriptions[XS_TOKEN_FUNCTION])
3970
0
    return;
3971
0
  txParamsBindingNode* args = (txParamsBindingNode*)(constructor->params);
3972
0
  if (args->description != &gxTokenDescriptions[XS_TOKEN_PARAMS_BINDING])
3973
0
    return;
3974
0
  if (args->items->length != 0)
3975
0
    return;
3976
0
  txBodyNode* body = (txBodyNode*)(constructor->body);
3977
0
  if (body->description != &gxTokenDescriptions[XS_TOKEN_BODY])
3978
0
    return;
3979
0
  txStatementNode* statement = (txStatementNode*)(body->statement);
3980
0
  if (statement->description != &gxTokenDescriptions[XS_TOKEN_STATEMENT])
3981
0
    return;
3982
0
  txNode* undefined = (txNode*)(statement->expression);
3983
0
  if (undefined->description != &gxTokenDescriptions[XS_TOKEN_UNDEFINED])
3984
0
    return;
3985
0
  fxPopNode(parser);
3986
0
  fxPushNode(parser, (txNode*)host);
3987
0
}
3988
3989
void fxCheckNativeFunction(txParser* parser)
3990
0
{
3991
0
  txFunctionNode* function = (txFunctionNode*)(parser->root);
3992
0
  txBodyNode* body = (txBodyNode*)(function->body);
3993
0
  if (body->description != &gxTokenDescriptions[XS_TOKEN_BODY])
3994
0
    goto bail;
3995
0
  txStatementNode* statement = (txStatementNode*)(body->statement);
3996
0
  if ((function->flags & mxDerivedFlag) && (function->flags & mxHostFlag)) {
3997
0
    txStatementsNode* statements = (txStatementsNode*)(statement);
3998
0
    if (statements->description != &gxTokenDescriptions[XS_TOKEN_STATEMENTS])
3999
0
      goto bail;
4000
0
    if (statements->items->length != 2)
4001
0
      goto bail;
4002
0
    statement = (txStatementNode*)(statements->items->first);
4003
0
    if (statement->description != &gxTokenDescriptions[XS_TOKEN_STATEMENT])
4004
0
      goto bail;
4005
0
    txSuperNode* super = (txSuperNode*)(statement->expression);
4006
0
    if (super->description != &gxTokenDescriptions[XS_TOKEN_SUPER])
4007
0
      goto bail;
4008
0
    txParamsNode* params = (txParamsNode*)(super->params);
4009
0
    if (params->items->length != 0)
4010
0
      goto bail;
4011
0
    statement = (txStatementNode*)(statement->next);
4012
0
  }
4013
0
  if ((statement->description != &gxTokenDescriptions[XS_TOKEN_RETURN]) && (statement->description != &gxTokenDescriptions[XS_TOKEN_STATEMENT]))
4014
0
    goto bail;
4015
0
  txCallNewNode* call = (txCallNewNode*)(statement->expression);
4016
0
  if (call->description != &gxTokenDescriptions[XS_TOKEN_CALL])
4017
0
    goto bail;
4018
0
  txMemberNode* member = (txMemberNode*)(call->reference);
4019
0
  if (member->description != &gxTokenDescriptions[XS_TOKEN_MEMBER])
4020
0
    goto bail;
4021
0
  if (member->symbol != parser->callSymbol)
4022
0
    goto bail;
4023
0
  txHostNode* host = (txHostNode*)(member->reference);
4024
0
  if (host->description != &gxTokenDescriptions[XS_TOKEN_HOST])
4025
0
    goto bail;
4026
0
  txParamsNode* params = (txParamsNode*)(call->params);
4027
0
  if (params->description != &gxTokenDescriptions[XS_TOKEN_PARAMS])
4028
0
    goto bail;
4029
0
  txParamsBindingNode* args = (txParamsBindingNode*)(function->params);
4030
0
  if (args->description != &gxTokenDescriptions[XS_TOKEN_PARAMS_BINDING])
4031
0
    goto bail;
4032
0
  if (params->items->length != args->items->length + 1)
4033
0
    goto bail;
4034
0
  txNode* arg = args->items->first;
4035
0
  txNode* param = params->items->first;
4036
0
  if (param->description != &gxTokenDescriptions[XS_TOKEN_THIS])
4037
0
    goto bail;
4038
0
  param = param->next;
4039
0
  while (arg) {
4040
0
    txDeclareNode* binding;
4041
0
    txAccessNode* access;
4042
0
    if (arg->description == &gxTokenDescriptions[XS_TOKEN_REST_BINDING]) {
4043
0
      if (param->description != &gxTokenDescriptions[XS_TOKEN_SPREAD])
4044
0
        goto bail;
4045
0
      binding = (txDeclareNode*)(((txRestBindingNode*)arg)->binding);
4046
0
      access = (txAccessNode*)(((txSpreadNode*)param)->expression);
4047
0
    }
4048
0
    else {
4049
0
      binding = (txDeclareNode*)arg;
4050
0
      access = (txAccessNode*)param;
4051
0
    }
4052
0
    if (binding->description != &gxTokenDescriptions[XS_TOKEN_ARG])
4053
0
      goto bail;
4054
0
    if (access->description != &gxTokenDescriptions[XS_TOKEN_ACCESS])
4055
0
      goto bail;
4056
0
    if (binding->symbol != access->symbol)
4057
0
      goto bail;
4058
0
    arg = arg->next;
4059
0
    param = param->next;
4060
0
  }
4061
0
  host->flags |= function->flags;
4062
0
  host->params = (txNode*)args;
4063
0
  fxPopNode(parser);
4064
0
  fxPushNode(parser, (txNode*)host);
4065
0
  return;
4066
0
bail:
4067
0
    fxReportWarning(parser, function->line, "cannot optimize native");
4068
0
}
4069
4070
txBoolean fxCheckReference(txParser* parser, txToken theToken)
4071
194k
{
4072
194k
  txNode* node = parser->root;
4073
194k
  txToken aToken = (node && node->description) ? node->description->token : XS_NO_TOKEN;
4074
194k
  if (aToken == XS_TOKEN_EXPRESSIONS) {
4075
1.66k
    txNode* item;
4076
1.93k
  again:
4077
1.93k
    item = ((txExpressionsNode*)node)->items->first;
4078
1.93k
    if (item && !item->next) {
4079
1.79k
      aToken = (item->description) ? item->description->token : XS_NO_TOKEN;
4080
1.79k
      if ((aToken == XS_TOKEN_ACCESS) || (aToken == XS_TOKEN_MEMBER) || (aToken == XS_TOKEN_MEMBER_AT) || (aToken == XS_TOKEN_PRIVATE_MEMBER) || (aToken == XS_TOKEN_UNDEFINED)) {
4081
482
        item->next = node->next;
4082
482
        node = parser->root = item;
4083
482
      }
4084
1.31k
      else if (aToken == XS_TOKEN_EXPRESSIONS) {
4085
272
        item->next = node->next;
4086
272
        node = item;
4087
272
        goto again;
4088
272
      }
4089
1.03k
      else
4090
1.03k
        aToken = XS_TOKEN_EXPRESSIONS;
4091
1.79k
    }
4092
1.93k
  }
4093
194k
  if (aToken == XS_TOKEN_ACCESS) {
4094
138k
    fxCheckStrictSymbol(parser, ((txAccessNode*)node)->symbol);
4095
138k
    return 1;
4096
138k
  }
4097
56.6k
  if ((aToken == XS_TOKEN_MEMBER) || (aToken == XS_TOKEN_MEMBER_AT) || (aToken == XS_TOKEN_PRIVATE_MEMBER) || (aToken == XS_TOKEN_UNDEFINED))
4098
27.0k
    return 1;
4099
    
4100
29.6k
  if (theToken == XS_TOKEN_ASSIGN) {
4101
25.0k
    if (aToken == XS_TOKEN_ARRAY) {
4102
3.89k
      txNode* binding = fxArrayBindingFromExpression(parser, node, XS_TOKEN_ACCESS);
4103
3.89k
            if (binding) {
4104
783
                binding->next = node->next;
4105
783
                parser->root = binding;
4106
783
        return 1;
4107
783
           }
4108
3.89k
        }
4109
21.1k
    else if (aToken == XS_TOKEN_OBJECT) {
4110
19.0k
      txNode* binding = fxObjectBindingFromExpression(parser, node, XS_TOKEN_ACCESS);
4111
19.0k
            if (binding) {
4112
18.7k
                binding->next = node->next;
4113
18.7k
                parser->root = binding;
4114
18.7k
        return 1;
4115
18.7k
            }
4116
19.0k
        }
4117
25.0k
  }
4118
4.65k
  else if (theToken == XS_TOKEN_DELETE)
4119
1.54k
    return 1;
4120
8.65k
  return 0;
4121
29.6k
}
4122
4123
void fxCheckStrictBinding(txParser* parser, txNode* node)
4124
64.3k
{
4125
64.3k
  if (node && node->description) {
4126
64.3k
    if (node->description->token == XS_TOKEN_ACCESS) {
4127
0
      fxCheckStrictSymbol(parser, ((txAccessNode*)node)->symbol);
4128
0
    }
4129
64.3k
    else if (node->description->token == XS_TOKEN_ARG) {
4130
15.2k
      fxCheckStrictSymbol(parser, ((txDeclareNode*)node)->symbol);
4131
15.2k
    }
4132
49.0k
    else if (node->description->token == XS_TOKEN_CONST) {
4133
0
      fxCheckStrictSymbol(parser, ((txDeclareNode*)node)->symbol);
4134
0
    }
4135
49.0k
    else if (node->description->token == XS_TOKEN_LET) {
4136
0
      fxCheckStrictSymbol(parser, ((txDeclareNode*)node)->symbol);
4137
0
    }
4138
49.0k
    else if (node->description->token == XS_TOKEN_USING) {
4139
0
      fxCheckStrictSymbol(parser, ((txDeclareNode*)node)->symbol);
4140
0
    }
4141
49.0k
    else if (node->description->token == XS_TOKEN_VAR) {
4142
0
      fxCheckStrictSymbol(parser, ((txDeclareNode*)node)->symbol);
4143
0
    }
4144
49.0k
    else if (node->description->token == XS_TOKEN_BINDING) {
4145
643
      fxCheckStrictBinding(parser, ((txBindingNode*)node)->target);
4146
643
    }
4147
48.4k
    else if (node->description->token == XS_TOKEN_ARRAY_BINDING) {
4148
533
      node = ((txArrayBindingNode*)node)->items->first;
4149
2.58k
      while (node) {
4150
2.05k
        fxCheckStrictBinding(parser, node);
4151
2.05k
        node = node->next;
4152
2.05k
      }
4153
533
    }
4154
47.9k
    else if (node->description->token == XS_TOKEN_OBJECT_BINDING) {
4155
684
      node = ((txObjectBindingNode*)node)->items->first;
4156
2.00k
      while (node) {
4157
1.32k
        fxCheckStrictBinding(parser, node);
4158
1.32k
        node = node->next;
4159
1.32k
      }
4160
684
    }
4161
47.2k
    else if (node->description->token == XS_TOKEN_PARAMS_BINDING) {
4162
45.6k
      node = ((txParamsBindingNode*)node)->items->first;
4163
58.9k
      while (node) {
4164
13.3k
        fxCheckStrictBinding(parser, node);
4165
13.3k
        node = node->next;
4166
13.3k
      }
4167
45.6k
    }
4168
1.63k
    else if (node->description->token == XS_TOKEN_PROPERTY_BINDING)
4169
1.31k
      fxCheckStrictBinding(parser, ((txPropertyBindingNode*)node)->binding);
4170
319
    else if (node->description->token == XS_TOKEN_PROPERTY_BINDING_AT)
4171
11
      fxCheckStrictBinding(parser, ((txPropertyBindingAtNode*)node)->binding);
4172
308
    else if (node->description->token == XS_TOKEN_REST_BINDING)
4173
16
      fxCheckStrictBinding(parser, ((txRestBindingNode*)node)->binding);
4174
64.3k
  }
4175
64.3k
}
4176
4177
void fxCheckStrictFunction(txParser* parser, txFunctionNode* function)
4178
1.48k
{
4179
1.48k
  parser->states[0].line = function->line;
4180
1.48k
  fxCheckStrictSymbol(parser, function->symbol);
4181
1.48k
  fxCheckStrictBinding(parser, function->params);
4182
1.48k
}
4183
4184
void fxCheckStrictSymbol(txParser* parser, txSymbol* symbol)
4185
527k
{
4186
527k
  if (parser->flags & mxStrictFlag) {
4187
22.1k
    if (symbol == parser->argumentsSymbol)
4188
3
      fxReportParserError(parser, parser->states[0].line, "invalid arguments (strict mode)");
4189
22.1k
    else if (symbol == parser->evalSymbol)
4190
73
      fxReportParserError(parser, parser->states[0].line, "invalid eval (strict mode)");
4191
22.0k
    else if (symbol == parser->yieldSymbol)
4192
0
      fxReportParserError(parser, parser->states[0].line, "invalid yield (strict mode)");
4193
22.1k
  }
4194
505k
  else if (parser->flags & mxYieldFlag) {
4195
11.8k
    if (symbol == parser->yieldSymbol)
4196
0
      fxReportParserError(parser, parser->states[0].line, "invalid yield");
4197
11.8k
  }
4198
527k
}
4199
4200
void fxCheckUniqueProperty(txParser* parser, txNode* base, txNode* current)
4201
110k
{
4202
110k
  return; // no more!
4203
0
  if (current->description->token == XS_TOKEN_PROPERTY) {
4204
0
    txPropertyNode* currentNode = (txPropertyNode*)current;
4205
0
    while (base != current) {
4206
0
      txPropertyNode* baseNode = (txPropertyNode*)base;
4207
0
      if (baseNode->description->token == XS_TOKEN_PROPERTY) {
4208
0
        if (baseNode->symbol == currentNode->symbol) {
4209
0
          fxCheckUniquePropertyAux(parser, (txNode*)baseNode, (txNode*)currentNode);      
4210
0
        }
4211
0
      }
4212
0
      base = base->next;
4213
0
    }
4214
0
  }
4215
0
  else {
4216
0
    txPropertyAtNode* currentNode = (txPropertyAtNode*)current;
4217
0
    txIntegerNode* currentAt = (txIntegerNode*)(currentNode->at);
4218
0
    if (currentAt->description->token == XS_TOKEN_INTEGER) {
4219
0
      while (base != current) {
4220
0
        txPropertyAtNode* baseNode = (txPropertyAtNode*)base;
4221
0
        if (baseNode->description->token == XS_TOKEN_PROPERTY_AT) {
4222
0
          txIntegerNode* baseAt = (txIntegerNode*)(baseNode->at);
4223
0
          if (baseAt->description->token == XS_TOKEN_INTEGER) {
4224
0
            if (baseAt->value == currentAt->value) {
4225
0
              fxCheckUniquePropertyAux(parser, (txNode*)baseNode, (txNode*)currentNode);      
4226
0
            }
4227
0
          }
4228
0
        }
4229
0
        base = base->next;
4230
0
      }
4231
0
    }
4232
0
  }
4233
0
}
4234
4235
void fxCheckUniquePropertyAux(txParser* parser, txNode* baseNode, txNode* currentNode)
4236
0
{
4237
0
  if (currentNode->flags & mxGetterFlag) {
4238
0
    if (baseNode->flags & mxGetterFlag)
4239
0
      fxReportParserError(parser, parser->states[0].line, "getter already defined");
4240
0
    else if (!(baseNode->flags & mxSetterFlag))
4241
0
      fxReportParserError(parser, parser->states[0].line, "property already defined");
4242
0
  }
4243
0
  else if (currentNode->flags & mxSetterFlag) {
4244
0
    if (baseNode->flags & mxSetterFlag)
4245
0
      fxReportParserError(parser, parser->states[0].line, "setter already defined");
4246
0
    else if (!(baseNode->flags & mxGetterFlag))
4247
0
      fxReportParserError(parser, parser->states[0].line, "property already defined");
4248
0
  }
4249
0
  else {
4250
0
    if (baseNode->flags & mxGetterFlag)
4251
0
      fxReportParserError(parser, parser->states[0].line, "getter already defined");
4252
0
    else if (baseNode->flags & mxSetterFlag)
4253
0
      fxReportParserError(parser, parser->states[0].line, "setter already defined");
4254
0
    else if (parser->flags & mxStrictFlag)
4255
0
      fxReportParserError(parser, parser->states[0].line, "property already defined (strict mode)");
4256
0
  }
4257
0
}
4258
4259
4260
void fxJSONValue(txParser* parser)
4261
0
{
4262
0
  switch (parser->states[0].token) {
4263
0
  case XS_TOKEN_FALSE:
4264
0
    fxPushNodeStruct(parser, 0, parser->states[0].token, parser->states[0].line);
4265
0
    fxGetNextTokenJSON(parser);
4266
0
    break;
4267
0
  case XS_TOKEN_TRUE:
4268
0
    fxPushNodeStruct(parser, 0, parser->states[0].token, parser->states[0].line);
4269
0
    fxGetNextTokenJSON(parser);
4270
0
    break;
4271
0
  case XS_TOKEN_NULL:
4272
0
    fxPushNodeStruct(parser, 0, parser->states[0].token, parser->states[0].line);
4273
0
    fxGetNextTokenJSON(parser);
4274
0
    break;
4275
0
  case XS_TOKEN_INTEGER:
4276
0
    fxPushIntegerNode(parser, parser->states[0].integer, parser->states[0].line);
4277
0
    fxGetNextTokenJSON(parser);
4278
0
    break;
4279
0
  case XS_TOKEN_NUMBER:
4280
0
    fxPushNumberNode(parser, parser->states[0].number, parser->states[0].line);
4281
0
    fxGetNextTokenJSON(parser);
4282
0
    break;
4283
0
  case XS_TOKEN_STRING:
4284
0
    fxPushStringNode(parser, parser->states[0].stringLength, parser->states[0].string, parser->states[0].line);
4285
0
    fxGetNextTokenJSON(parser);
4286
0
    break;
4287
0
  case XS_TOKEN_LEFT_BRACE:
4288
0
    fxJSONObject(parser);
4289
0
    break;
4290
0
  case XS_TOKEN_LEFT_BRACKET:
4291
0
    fxJSONArray(parser);
4292
0
    break;
4293
0
  default:
4294
0
    fxPushNULL(parser);
4295
0
    fxReportParserError(parser, parser->states[0].line, "invalid value");
4296
0
    break;
4297
0
  }
4298
0
}
4299
4300
void fxJSONObject(txParser* parser)
4301
0
{
4302
0
  txIndex aLength = 0;
4303
0
  txInteger aLine = parser->states[0].line;
4304
0
  fxGetNextTokenJSON(parser);
4305
0
  for (;;) {
4306
0
    if (parser->states[0].token == XS_TOKEN_RIGHT_BRACE)
4307
0
      break;
4308
0
    if (parser->states[0].token != XS_TOKEN_STRING) {
4309
0
      fxReportParserError(parser, parser->states[0].line, "missing name");
4310
0
      break;
4311
0
    }
4312
0
    fxPushStringNode(parser, parser->states[0].stringLength, parser->states[0].string, parser->states[0].line);
4313
0
    fxGetNextTokenJSON(parser);
4314
0
    if (parser->states[0].token != XS_TOKEN_COLON) {
4315
0
      fxReportParserError(parser, parser->states[0].line, "missing :");
4316
0
      break;
4317
0
    }
4318
0
    fxGetNextTokenJSON(parser);
4319
0
    fxJSONValue(parser);
4320
0
    fxPushNodeStruct(parser, 2, XS_TOKEN_PROPERTY_AT, parser->states[0].line);
4321
0
    aLength++;
4322
0
    if (parser->states[0].token != XS_TOKEN_COMMA)
4323
0
      break;
4324
0
    fxGetNextTokenJSON(parser);
4325
0
  }
4326
0
  if (parser->states[0].token != XS_TOKEN_RIGHT_BRACE)
4327
0
    fxReportParserError(parser, parser->states[0].line, "missing }");
4328
0
  fxGetNextTokenJSON(parser);
4329
0
  fxPushNodeList(parser, aLength);
4330
0
  fxPushNodeStruct(parser, 1, XS_TOKEN_OBJECT, aLine);
4331
0
}
4332
4333
void fxJSONArray(txParser* parser)
4334
0
{
4335
0
  txIndex aLength = 0;
4336
0
  txInteger aLine = parser->states[0].line;
4337
0
  fxGetNextTokenJSON(parser);
4338
0
  for (;;) {
4339
0
    if (parser->states[0].token == XS_TOKEN_RIGHT_BRACKET)
4340
0
      break;
4341
0
    fxJSONValue(parser);
4342
0
    aLength++;
4343
0
    if (parser->states[0].token != XS_TOKEN_COMMA)
4344
0
      break;
4345
0
    fxGetNextTokenJSON(parser);
4346
0
  }
4347
0
  if (parser->states[0].token != XS_TOKEN_RIGHT_BRACKET)
4348
0
    fxReportParserError(parser, parser->states[0].line, "missing ]");
4349
0
  fxGetNextTokenJSON(parser);
4350
0
  fxPushNodeList(parser, aLength);
4351
0
  fxPushNodeStruct(parser, 1, XS_TOKEN_ARRAY, aLine);
4352
0
}
4353
4354
void fxJSONModule(txParser* parser)
4355
0
{
4356
0
  fxJSONValue(parser);
4357
  
4358
0
  fxPushSymbol(parser, parser->defaultSymbol);
4359
0
  fxPushNULL(parser);
4360
0
  fxPushNodeStruct(parser, 2, XS_TOKEN_CONST, 1);
4361
0
  fxSwapNodes(parser);
4362
0
  fxPushNodeStruct(parser, 2, XS_TOKEN_ASSIGN, 1);
4363
0
  fxPushNodeStruct(parser, 1, XS_TOKEN_STATEMENT, 1);
4364
  
4365
0
  fxPushSymbol(parser, parser->defaultSymbol);
4366
0
  fxPushNULL(parser);
4367
0
  fxPushNodeStruct(parser, 2, XS_TOKEN_SPECIFIER, 1);
4368
0
  fxPushNodeList(parser, 1);
4369
0
  fxPushNULL(parser);
4370
0
  fxPushNULL(parser);
4371
0
  fxPushNodeStruct(parser, 3, XS_TOKEN_EXPORT, 1);
4372
  
4373
0
  fxPushNodeList(parser, 2);
4374
0
  fxPushNodeStruct(parser, 1, XS_TOKEN_STATEMENTS, 1);
4375
  
4376
0
  fxPushNodeStruct(parser, 1, XS_TOKEN_MODULE, 1);
4377
0
}
4378
4379
static txSymbol* fxJSXName(txParser* parser, txSymbol* before, txSymbol* after)
4380
3.10k
{
4381
3.10k
  txSize beforeLength = before->length;
4382
3.10k
  txSize afterLength = after->length;
4383
3.10k
  txSize length = beforeLength + 1 + afterLength + 1;
4384
3.10k
  txString string = fxNewParserChunk(parser, length);
4385
3.10k
  snprintf(string, length, "%s-%s", before->string, after->string);
4386
3.10k
  return fxNewParserSymbol(parser, string);
4387
3.10k
}
4388
4389
void fxJSXAttributeName(txParser* parser)
4390
18.5k
{
4391
18.5k
  txSymbol* symbol = parser->states[0].symbol;
4392
18.5k
  fxGetNextToken(parser);
4393
22.9k
  while (parser->states[0].token == XS_TOKEN_SUBTRACT) {
4394
4.32k
    fxGetNextToken(parser);
4395
4.32k
    if (gxTokenFlags[parser->states[0].token] & XS_TOKEN_IDENTIFIER_NAME)
4396
2.51k
      symbol = fxJSXName(parser, symbol, parser->states[0].symbol);
4397
1.80k
    else
4398
1.80k
      fxReportParserError(parser, parser->states[0].line, "missing name");
4399
4.32k
    fxGetNextToken(parser);
4400
4.32k
  }
4401
18.5k
  if (parser->states[0].token == XS_TOKEN_COLON) {
4402
3.14k
    fxGetNextToken(parser);
4403
3.14k
    if (gxTokenFlags[parser->states[0].token] & XS_TOKEN_IDENTIFIER_NAME)
4404
629
      symbol = fxJSXNamespace(parser, symbol, parser->states[0].symbol);
4405
2.51k
    else
4406
2.51k
      fxReportParserError(parser, parser->states[0].line, "missing name");
4407
3.14k
    fxGetNextToken(parser);
4408
3.74k
    while (parser->states[0].token == XS_TOKEN_SUBTRACT) {
4409
600
      fxGetNextToken(parser);
4410
600
      if (gxTokenFlags[parser->states[0].token] & XS_TOKEN_IDENTIFIER_NAME)
4411
591
        symbol = fxJSXName(parser, symbol, parser->states[0].symbol);
4412
9
      else
4413
9
        fxReportParserError(parser, parser->states[0].line, "missing name");
4414
600
      fxGetNextToken(parser);
4415
600
    }  
4416
3.14k
  }
4417
18.5k
  fxPushSymbol(parser, symbol);
4418
18.5k
}
4419
4420
void fxJSXAttributeValue(txParser* parser)
4421
1.69k
{
4422
1.69k
  txInteger line = parser->states[0].line;
4423
1.69k
  fxGetNextTokenJSXAttribute(parser);
4424
1.69k
  if (parser->states[0].token == XS_TOKEN_STRING) {
4425
402
    fxPushStringNode(parser, parser->states[0].stringLength, parser->states[0].string, line);
4426
402
    fxGetNextToken(parser);
4427
402
  }
4428
1.28k
  else if (parser->states[0].token == XS_TOKEN_LEFT_BRACE) {
4429
221
    fxGetNextToken(parser);
4430
221
    if (parser->states[0].token == XS_TOKEN_RIGHT_BRACE) {
4431
1
      fxGetNextToken(parser);
4432
1
      fxReportParserError(parser, parser->states[0].line, "missing expression");
4433
1
      fxPushNodeStruct(parser, 0, XS_TOKEN_UNDEFINED, line);
4434
1
    }
4435
220
    else {
4436
220
      fxAssignmentExpression(parser);
4437
220
      if (parser->states[0].token == XS_TOKEN_RIGHT_BRACE)
4438
33
        fxGetNextToken(parser);
4439
187
      else
4440
187
        fxReportParserError(parser, parser->states[0].line, "missing }");
4441
220
    }
4442
221
  }
4443
1.06k
  else {
4444
1.06k
    fxReportParserError(parser, parser->states[0].line, "invalid %s", gxTokenNames[parser->states[0].token]);
4445
1.06k
    fxPushNodeStruct(parser, 0, XS_TOKEN_UNDEFINED, line);
4446
1.06k
  }
4447
1.69k
}
4448
4449
void fxJSXElement(txParser* parser)
4450
110k
{
4451
110k
  txBoolean closed = 0;
4452
110k
  txInteger line = parser->states[0].line;
4453
110k
  txNode* name = NULL;
4454
110k
  txInteger nodeCount = parser->nodeCount;
4455
110k
  txInteger propertyCount = 0;
4456
110k
  fxCheckParserStack(parser, line);
4457
110k
  fxPushSymbol(parser, parser->__jsx__Symbol);
4458
110k
  fxPushNodeStruct(parser, 1, XS_TOKEN_ACCESS, parser->states[0].line);
4459
110k
  if (parser->states[0].token == XS_TOKEN_IDENTIFIER) {
4460
108k
    fxJSXElementName(parser);
4461
108k
    name = parser->root;
4462
108k
  }
4463
1.91k
  else {
4464
1.91k
    fxReportParserError(parser, parser->states[0].line, "missing identifier");
4465
1.91k
    fxPushNULL(parser);
4466
1.91k
  }
4467
117k
  for (;;) {
4468
117k
    if (parser->states[0].token == XS_TOKEN_MORE)
4469
41.0k
      break;
4470
76.0k
    if (parser->states[0].token == XS_TOKEN_DIVIDE) {
4471
55.0k
      fxGetNextToken(parser);
4472
55.0k
      if (parser->states[0].token != XS_TOKEN_MORE)
4473
1.06k
        fxReportParserError(parser, parser->states[0].line, "missing >");
4474
55.0k
      closed = 1;
4475
55.0k
      break;
4476
55.0k
    }
4477
21.0k
    if (gxTokenFlags[parser->states[0].token] & XS_TOKEN_IDENTIFIER_NAME) {
4478
18.5k
      fxJSXAttributeName(parser);
4479
18.5k
      if (parser->states[0].token == XS_TOKEN_ASSIGN)
4480
1.69k
        fxJSXAttributeValue(parser);
4481
16.9k
      else
4482
16.9k
        fxPushNodeStruct(parser, 0, XS_TOKEN_TRUE, parser->states[0].line);
4483
18.5k
      fxPushNodeStruct(parser, 2, XS_TOKEN_PROPERTY, parser->states[0].line);
4484
18.5k
      propertyCount++;
4485
18.5k
    }
4486
2.41k
    else if (parser->states[0].token == XS_TOKEN_LEFT_BRACE) {
4487
923
      fxGetNextToken(parser);
4488
923
      if (parser->states[0].token == XS_TOKEN_SPREAD) {
4489
1
        fxGetNextToken(parser);
4490
1
        fxAssignmentExpression(parser);
4491
1
        if (parser->states[0].token == XS_TOKEN_RIGHT_BRACE)
4492
0
          fxGetNextToken(parser);
4493
1
        else
4494
1
          fxReportParserError(parser, parser->states[0].line, "missing }");
4495
1
        fxPushNodeStruct(parser, 1, XS_TOKEN_SPREAD, parser->states[0].line);
4496
1
        propertyCount++;
4497
1
      }
4498
922
      else
4499
922
        fxReportParserError(parser, parser->states[0].line, "invalid %s", gxTokenNames[parser->states[0].token]);
4500
923
    }
4501
1.49k
    else {
4502
1.49k
      fxReportParserError(parser, parser->states[0].line, "invalid %s", gxTokenNames[parser->states[0].token]);
4503
1.49k
      break;
4504
1.49k
    }
4505
21.0k
  }
4506
110k
  if (propertyCount > 0) {
4507
9.05k
    fxPushNodeList(parser, propertyCount);
4508
9.05k
    fxPushNodeStruct(parser, 1, XS_TOKEN_OBJECT, parser->states[0].line);
4509
9.05k
  }
4510
101k
  else
4511
101k
    fxPushNodeStruct(parser, 0, XS_TOKEN_NULL, parser->states[0].line);
4512
110k
  if (!closed) {
4513
103k
    for (;;) {
4514
103k
      fxGetNextTokenJSXChild(parser);
4515
103k
      if (parser->states[0].stringLength)
4516
20.1k
        fxPushStringNode(parser, parser->states[0].stringLength, parser->states[0].string, parser->states[0].line);
4517
103k
      if (parser->states[0].token == XS_TOKEN_LEFT_BRACE) {
4518
13.5k
        fxGetNextToken(parser);
4519
13.5k
        if (parser->states[0].token == XS_TOKEN_RIGHT_BRACE)
4520
2.78k
          fxGetNextToken(parser);
4521
10.7k
        else {
4522
10.7k
          fxAssignmentExpression(parser);
4523
10.7k
          if (parser->states[0].token != XS_TOKEN_RIGHT_BRACE)
4524
2.62k
            fxReportParserError(parser, parser->states[0].line, "missing }");
4525
10.7k
        }
4526
13.5k
      }
4527
89.5k
      else if (parser->states[0].token == XS_TOKEN_LESS) {
4528
83.3k
        fxGetNextToken(parser);
4529
83.3k
        if (parser->states[0].token == XS_TOKEN_DIVIDE) {
4530
9.75k
          fxGetNextToken(parser);
4531
9.75k
          if (parser->states[0].token == XS_TOKEN_IDENTIFIER) {
4532
8.44k
            fxJSXElementName(parser);
4533
8.44k
            if (!fxJSXMatch(parser, name, parser->root)) {
4534
6.51k
              fxReportParserError(parser, parser->states[0].line, "invalid element");
4535
6.51k
              fxPushNULL(parser);
4536
6.51k
            }
4537
8.44k
          }
4538
1.31k
          else {
4539
1.31k
            fxReportParserError(parser, parser->states[0].line, "missing identifier");
4540
1.31k
            fxPushNULL(parser);
4541
1.31k
          }
4542
9.75k
          if (parser->states[0].token != XS_TOKEN_MORE)
4543
1.31k
            fxReportParserError(parser, parser->states[0].line, "missing >");
4544
9.75k
          fxPopNode(parser);
4545
9.75k
          break;
4546
9.75k
        }
4547
73.5k
        else
4548
73.5k
          fxJSXElement(parser);
4549
83.3k
      }
4550
6.21k
      else {
4551
6.21k
        fxReportParserError(parser, parser->states[0].line, "invalid %s", gxTokenNames[parser->states[0].token]);
4552
6.21k
        break;
4553
6.21k
      }
4554
103k
    }
4555
41.0k
  }
4556
110k
  fxPushNodeList(parser, parser->nodeCount - nodeCount - 1);
4557
110k
  fxPushNodeStruct(parser, 1, XS_TOKEN_PARAMS, line);
4558
110k
  fxPushNodeStruct(parser, 2, XS_TOKEN_CALL, line);
4559
110k
}
4560
4561
void fxJSXElementName(txParser* parser)
4562
117k
{
4563
117k
  txInteger line = parser->states[0].line;
4564
117k
  txSymbol* symbol = parser->states[0].symbol;
4565
117k
  fxGetNextToken(parser);
4566
117k
  if (parser->states[0].token == XS_TOKEN_COLON) {
4567
3.20k
    fxGetNextToken(parser);
4568
3.20k
    if (parser->states[0].token == XS_TOKEN_IDENTIFIER)
4569
178
      symbol = fxJSXNamespace(parser, symbol, parser->states[0].symbol);
4570
3.02k
    else
4571
3.02k
      fxReportParserError(parser, parser->states[0].line, "missing name");
4572
3.20k
    fxPushSymbol(parser, symbol);
4573
3.20k
    fxPushNodeStruct(parser, 1, XS_TOKEN_ACCESS, line);
4574
3.20k
    fxGetNextToken(parser);
4575
3.20k
  }
4576
114k
  else {
4577
114k
    fxPushSymbol(parser, symbol);
4578
114k
    fxPushNodeStruct(parser, 1, XS_TOKEN_ACCESS, line);
4579
145k
    while (parser->states[0].token == XS_TOKEN_DOT) {
4580
31.3k
      fxGetNextToken(parser);
4581
31.3k
      if (parser->states[0].token == XS_TOKEN_IDENTIFIER) {
4582
29.6k
        fxPushSymbol(parser, parser->states[0].symbol);
4583
29.6k
        fxPushNodeStruct(parser, 2, XS_TOKEN_MEMBER, parser->states[0].line);
4584
29.6k
        fxGetNextToken(parser);
4585
29.6k
      }
4586
1.62k
      else
4587
1.62k
        fxReportParserError(parser, parser->states[0].line, "missing property");
4588
31.3k
    }
4589
114k
  }
4590
117k
}
4591
4592
txBoolean fxJSXMatch(txParser* parser, txNode* opening, txNode* closing)
4593
8.04k
{
4594
8.04k
  if (opening && closing) {
4595
8.04k
    while (opening->description->token == XS_TOKEN_MEMBER) {
4596
3.46k
      if (closing->description->token != XS_TOKEN_MEMBER)
4597
1.61k
        return 0;
4598
1.85k
      if (((txMemberNode*)opening)->symbol != ((txMemberNode*)closing)->symbol)
4599
1.85k
        return 0;
4600
4
      opening = ((txMemberNode*)opening)->reference;
4601
4
      closing = ((txMemberNode*)closing)->reference;
4602
4
    }
4603
4.57k
    if (opening->description->token == XS_TOKEN_ACCESS) {
4604
4.57k
      if (closing->description->token != XS_TOKEN_ACCESS)
4605
1.49k
        return 0;
4606
3.08k
      if (((txAccessNode*)opening)->symbol != ((txAccessNode*)closing)->symbol)
4607
1.55k
        return 0;
4608
1.53k
      return 1;
4609
3.08k
    }
4610
4.57k
  }
4611
0
  return 0;
4612
8.04k
}
4613
4614
txSymbol* fxJSXNamespace(txParser* parser, txSymbol* namespace, txSymbol* name)
4615
807
{
4616
807
  txSize namespaceLength = namespace->length;
4617
807
  txSize nameLength = name->length;
4618
807
  txSize length = namespaceLength + 1 + nameLength + 1;
4619
807
  txString string = fxNewParserChunk(parser, length);
4620
807
  snprintf(string, length, "%s:%s", namespace->string, name->string);
4621
807
  return fxNewParserSymbol(parser, string);
4622
807
}