[PATCH 1/2] jscript: Allow ES5 keywords in identifiers.
Gabriel Ivăncescu
gabrielopcode at gmail.com
Fri Aug 27 09:47:54 CDT 2021
Signed-off-by: Gabriel Ivăncescu <gabrielopcode at gmail.com>
---
Anything that imports prototype.js needs this.
dlls/jscript/parser.y | 28 +++++++++++++++++-----------
1 file changed, 17 insertions(+), 11 deletions(-)
diff --git a/dlls/jscript/parser.y b/dlls/jscript/parser.y
index 0ebdc2b..e44f20e 100644
--- a/dlls/jscript/parser.y
+++ b/dlls/jscript/parser.y
@@ -220,7 +220,7 @@ static expression_t *new_prop_and_value_expression(parser_ctx_t*,property_list_t
%type <expr> MemberExpression
%type <expr> PrimaryExpression
%type <expr> GetterSetterMethod
-%type <identifier> Identifier_opt
+%type <identifier> Identifier Identifier_opt
%type <variable_list> VariableDeclarationList
%type <variable_list> VariableDeclarationListNoIn
%type <variable_declaration> VariableDeclaration
@@ -267,9 +267,9 @@ FunctionStatementList
FunctionExpression
: kFUNCTION left_bracket FormalParameterList_opt right_bracket '{' FunctionBody '}'
{ $$ = new_function_expression(ctx, NULL, $3, $6, NULL, ctx->begin + @1, @7 - @1 + 1); }
- | kFUNCTION tIdentifier left_bracket FormalParameterList_opt right_bracket '{' FunctionBody '}'
+ | kFUNCTION Identifier left_bracket FormalParameterList_opt right_bracket '{' FunctionBody '}'
{ $$ = new_function_expression(ctx, $2, $4, $7, NULL, ctx->begin + @1, @8 - @1 + 1); }
- | kFUNCTION tIdentifier kDCOL tIdentifier left_bracket FormalParameterList_opt right_bracket '{' FunctionBody '}'
+ | kFUNCTION Identifier kDCOL Identifier left_bracket FormalParameterList_opt right_bracket '{' FunctionBody '}'
{ $$ = new_function_expression(ctx, $4, $6, $9, $2, ctx->begin + @1, @10 - @1 + 1); }
/* ECMA-262 10th Edition 14.1 */
@@ -278,8 +278,8 @@ FunctionBody
/* ECMA-262 3rd Edition 13 */
FormalParameterList
- : tIdentifier { $$ = new_parameter_list(ctx, $1); }
- | FormalParameterList ',' tIdentifier
+ : Identifier { $$ = new_parameter_list(ctx, $1); }
+ | FormalParameterList ',' Identifier
{ $$ = parameter_list_add(ctx, $1, $3); }
/* ECMA-262 3rd Edition 13 */
@@ -380,12 +380,12 @@ VariableDeclarationListNoIn
/* ECMA-262 3rd Edition 12.2 */
VariableDeclaration
- : tIdentifier Initialiser_opt
+ : Identifier Initialiser_opt
{ $$ = new_variable_declaration(ctx, $1, $2); }
/* ECMA-262 3rd Edition 12.2 */
VariableDeclarationNoIn
- : tIdentifier InitialiserNoIn_opt
+ : Identifier InitialiserNoIn_opt
{ $$ = new_variable_declaration(ctx, $1, $2); }
/* ECMA-262 3rd Edition 12.2 */
@@ -476,7 +476,7 @@ WithStatement
/* ECMA-262 3rd Edition 12.12 */
LabelledStatement
- : tIdentifier ':' Statement
+ : Identifier ':' Statement
{ $$ = new_labelled_statement(ctx, @$, $1, $3); }
/* ECMA-262 3rd Edition 12.11 */
@@ -526,7 +526,7 @@ TryStatement
/* ECMA-262 3rd Edition 12.14 */
Catch
- : kCATCH left_bracket tIdentifier right_bracket Block
+ : kCATCH left_bracket Identifier right_bracket Block
{ $$ = new_catch_block(ctx, $3, $5); }
/* ECMA-262 3rd Edition 12.14 */
@@ -785,7 +785,7 @@ ArgumentList
/* ECMA-262 3rd Edition 11.1 */
PrimaryExpression
: kTHIS { $$ = new_expression(ctx, EXPR_THIS, 0); }
- | tIdentifier { $$ = new_identifier_expression(ctx, $1); }
+ | Identifier { $$ = new_identifier_expression(ctx, $1); }
| Literal { $$ = new_literal_expression(ctx, $1); }
| ArrayLiteral { $$ = $1; }
| ObjectLiteral { $$ = $1; }
@@ -859,7 +859,13 @@ PropertyName
/* ECMA-262 3rd Edition 7.6 */
Identifier_opt
: /* empty*/ { $$ = NULL; }
- | tIdentifier { $$ = $1; }
+ | Identifier { $$ = $1; }
+
+Identifier
+ : tIdentifier { $$ = $1; }
+ | kGET { $$ = $1; }
+ | kLET { $$ = $1; }
+ | kSET { $$ = $1; }
/* ECMA-262 5.1 Edition 7.6 */
IdentifierName
--
2.31.1
More information about the wine-devel
mailing list