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)
if(*ctx->ptr == '=') { /* /= */
ctx->ptr++;
*(int*)lval = EXPR_ASSIGNDIV;
return tAssignOper;
return kDIVEQ;
}
}
return '/';
......@@ -772,7 +772,10 @@ literal_t *parse_regexp(parser_ctx_t *ctx)
TRACE("\n");
re = ctx->ptr;
while(*ctx->ptr != '/')
ctx->ptr--;
re = ++ctx->ptr;
while(ctx->ptr < ctx->end && *ctx->ptr != '/') {
if(*ctx->ptr++ == '\\' && ctx->ptr < ctx->end)
ctx->ptr++;
......
......@@ -172,7 +172,7 @@ static source_elements_t *source_elements_add_statement(source_elements_t*,state
/* keywords */
%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 tANDAND tOROR tINC tDEC tHTMLCOMMENT
%token tANDAND tOROR tINC tDEC tHTMLCOMMENT kDIVEQ
%token <srcptr> kFUNCTION '}'
......@@ -245,6 +245,7 @@ static source_elements_t *source_elements_add_statement(source_elements_t*,state
%type <literal> PropertyName
%type <literal> BooleanLiteral
%type <srcptr> KFunction
%type <ival> AssignOper
%nonassoc LOWER_THAN_ELSE
%nonassoc kELSE
......@@ -515,12 +516,16 @@ ExpressionNoIn
| ExpressionNoIn ',' AssignmentExpressionNoIn
{ $$ = new_binary_expression(ctx, EXPR_COMMA, $1, $3); }
AssignOper
: tAssignOper { $$ = $1; }
| kDIVEQ { $$ = EXPR_ASSIGNDIV; }
/* ECMA-262 3rd Edition 11.13 */
AssignmentExpression
: ConditionalExpression { $$ = $1; }
| LeftHandSideExpression '=' AssignmentExpression
{ $$ = new_binary_expression(ctx, EXPR_ASSIGN, $1, $3); }
| LeftHandSideExpression tAssignOper AssignmentExpression
| LeftHandSideExpression AssignOper AssignmentExpression
{ $$ = new_binary_expression(ctx, $2, $1, $3); }
/* ECMA-262 3rd Edition 11.13 */
......@@ -529,7 +534,7 @@ AssignmentExpressionNoIn
{ $$ = $1; }
| LeftHandSideExpression '=' AssignmentExpressionNoIn
{ $$ = new_binary_expression(ctx, EXPR_ASSIGN, $1, $3); }
| LeftHandSideExpression tAssignOper AssignmentExpressionNoIn
| LeftHandSideExpression AssignOper AssignmentExpressionNoIn
{ $$ = new_binary_expression(ctx, $2, $1, $3); }
/* ECMA-262 3rd Edition 11.12 */
......@@ -800,6 +805,8 @@ Literal
| tStringLiteral { $$ = new_string_literal(ctx, $1); }
| '/' { $$ = parse_regexp(ctx);
if(!$$) YYABORT; }
| kDIVEQ { $$ = parse_regexp(ctx);
if(!$$) YYABORT; }
/* ECMA-262 3rd Edition 7.8.2 */
BooleanLiteral
......
......@@ -896,6 +896,9 @@ ok(""+str === "test", "''+str = " + str);
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() !== ''");
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