jscript: Fixed parsing regexps starting with '='.

This commit is contained in:
Jacek Caban 2009-08-27 01:20:37 +02:00 committed by Alexandre Julliard
parent 560d63548d
commit 05b104c6a3
3 changed files with 18 additions and 5 deletions

View File

@ -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++;

View File

@ -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

View File

@ -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() {}