Commit 05b104c6 authored by Jacek Caban's avatar Jacek Caban Committed by Alexandre Julliard

jscript: Fixed parsing regexps starting with '='.

parent 560d6354
...@@ -735,7 +735,7 @@ int parser_lex(void *lval, parser_ctx_t *ctx) ...@@ -735,7 +735,7 @@ int parser_lex(void *lval, parser_ctx_t *ctx)
if(*ctx->ptr == '=') { /* /= */ if(*ctx->ptr == '=') { /* /= */
ctx->ptr++; ctx->ptr++;
*(int*)lval = EXPR_ASSIGNDIV; *(int*)lval = EXPR_ASSIGNDIV;
return tAssignOper; return kDIVEQ;
} }
} }
return '/'; return '/';
...@@ -772,7 +772,10 @@ literal_t *parse_regexp(parser_ctx_t *ctx) ...@@ -772,7 +772,10 @@ literal_t *parse_regexp(parser_ctx_t *ctx)
TRACE("\n"); TRACE("\n");
re = ctx->ptr; while(*ctx->ptr != '/')
ctx->ptr--;
re = ++ctx->ptr;
while(ctx->ptr < ctx->end && *ctx->ptr != '/') { while(ctx->ptr < ctx->end && *ctx->ptr != '/') {
if(*ctx->ptr++ == '\\' && ctx->ptr < ctx->end) if(*ctx->ptr++ == '\\' && ctx->ptr < ctx->end)
ctx->ptr++; ctx->ptr++;
......
...@@ -172,7 +172,7 @@ static source_elements_t *source_elements_add_statement(source_elements_t*,state ...@@ -172,7 +172,7 @@ static source_elements_t *source_elements_add_statement(source_elements_t*,state
/* keywords */ /* keywords */
%token kBREAK kCASE kCATCH kCONTINUE kDEFAULT kDELETE kDO kELSE kIF kFINALLY kFOR kIN %token kBREAK kCASE kCATCH kCONTINUE kDEFAULT kDELETE kDO kELSE kIF kFINALLY kFOR kIN
%token kINSTANCEOF kNEW kNULL kUNDEFINED kRETURN kSWITCH kTHIS kTHROW kTRUE kFALSE kTRY kTYPEOF kVAR kVOID kWHILE kWITH %token kINSTANCEOF kNEW kNULL kUNDEFINED kRETURN kSWITCH kTHIS kTHROW kTRUE kFALSE kTRY kTYPEOF kVAR kVOID kWHILE kWITH
%token tANDAND tOROR tINC tDEC tHTMLCOMMENT %token tANDAND tOROR tINC tDEC tHTMLCOMMENT kDIVEQ
%token <srcptr> kFUNCTION '}' %token <srcptr> kFUNCTION '}'
...@@ -245,6 +245,7 @@ static source_elements_t *source_elements_add_statement(source_elements_t*,state ...@@ -245,6 +245,7 @@ static source_elements_t *source_elements_add_statement(source_elements_t*,state
%type <literal> PropertyName %type <literal> PropertyName
%type <literal> BooleanLiteral %type <literal> BooleanLiteral
%type <srcptr> KFunction %type <srcptr> KFunction
%type <ival> AssignOper
%nonassoc LOWER_THAN_ELSE %nonassoc LOWER_THAN_ELSE
%nonassoc kELSE %nonassoc kELSE
...@@ -515,12 +516,16 @@ ExpressionNoIn ...@@ -515,12 +516,16 @@ ExpressionNoIn
| ExpressionNoIn ',' AssignmentExpressionNoIn | ExpressionNoIn ',' AssignmentExpressionNoIn
{ $$ = new_binary_expression(ctx, EXPR_COMMA, $1, $3); } { $$ = new_binary_expression(ctx, EXPR_COMMA, $1, $3); }
AssignOper
: tAssignOper { $$ = $1; }
| kDIVEQ { $$ = EXPR_ASSIGNDIV; }
/* ECMA-262 3rd Edition 11.13 */ /* ECMA-262 3rd Edition 11.13 */
AssignmentExpression AssignmentExpression
: ConditionalExpression { $$ = $1; } : ConditionalExpression { $$ = $1; }
| LeftHandSideExpression '=' AssignmentExpression | LeftHandSideExpression '=' AssignmentExpression
{ $$ = new_binary_expression(ctx, EXPR_ASSIGN, $1, $3); } { $$ = new_binary_expression(ctx, EXPR_ASSIGN, $1, $3); }
| LeftHandSideExpression tAssignOper AssignmentExpression | LeftHandSideExpression AssignOper AssignmentExpression
{ $$ = new_binary_expression(ctx, $2, $1, $3); } { $$ = new_binary_expression(ctx, $2, $1, $3); }
/* ECMA-262 3rd Edition 11.13 */ /* ECMA-262 3rd Edition 11.13 */
...@@ -529,7 +534,7 @@ AssignmentExpressionNoIn ...@@ -529,7 +534,7 @@ AssignmentExpressionNoIn
{ $$ = $1; } { $$ = $1; }
| LeftHandSideExpression '=' AssignmentExpressionNoIn | LeftHandSideExpression '=' AssignmentExpressionNoIn
{ $$ = new_binary_expression(ctx, EXPR_ASSIGN, $1, $3); } { $$ = new_binary_expression(ctx, EXPR_ASSIGN, $1, $3); }
| LeftHandSideExpression tAssignOper AssignmentExpressionNoIn | LeftHandSideExpression AssignOper AssignmentExpressionNoIn
{ $$ = new_binary_expression(ctx, $2, $1, $3); } { $$ = new_binary_expression(ctx, $2, $1, $3); }
/* ECMA-262 3rd Edition 11.12 */ /* ECMA-262 3rd Edition 11.12 */
...@@ -800,6 +805,8 @@ Literal ...@@ -800,6 +805,8 @@ Literal
| tStringLiteral { $$ = new_string_literal(ctx, $1); } | tStringLiteral { $$ = new_string_literal(ctx, $1); }
| '/' { $$ = parse_regexp(ctx); | '/' { $$ = parse_regexp(ctx);
if(!$$) YYABORT; } if(!$$) YYABORT; }
| kDIVEQ { $$ = parse_regexp(ctx);
if(!$$) YYABORT; }
/* ECMA-262 3rd Edition 7.8.2 */ /* ECMA-262 3rd Edition 7.8.2 */
BooleanLiteral BooleanLiteral
......
...@@ -896,6 +896,9 @@ ok(""+str === "test", "''+str = " + str); ...@@ -896,6 +896,9 @@ ok(""+str === "test", "''+str = " + str);
ok((function (){return 1;})() === 1, "(function (){return 1;})() = " + (function (){return 1;})()); ok((function (){return 1;})() === 1, "(function (){return 1;})() = " + (function (){return 1;})());
var re = /=(\?|%3F)/g;
ok(re.source === "=(\\?|%3F)", "re.source = " + re.source);
ok(createNullBSTR() === '', "createNullBSTR() !== ''"); ok(createNullBSTR() === '', "createNullBSTR() !== ''");
function do_test() {} function do_test() {}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment