Module: wine Branch: master Commit: 05b104c6a3d0193302b8e2cd0c00d54090dade5b URL: http://source.winehq.org/git/wine.git/?a=commit;h=05b104c6a3d0193302b8e2cd0c...
Author: Jacek Caban jacek@codeweavers.com Date: Thu Aug 27 01:20:37 2009 +0200
jscript: Fixed parsing regexps starting with '='.
---
dlls/jscript/lex.c | 7 +++++-- dlls/jscript/parser.y | 13 ++++++++++--- dlls/jscript/tests/lang.js | 3 +++ 3 files changed, 18 insertions(+), 5 deletions(-)
diff --git a/dlls/jscript/lex.c b/dlls/jscript/lex.c index 1b33737..680ce55 100644 --- a/dlls/jscript/lex.c +++ b/dlls/jscript/lex.c @@ -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++; diff --git a/dlls/jscript/parser.y b/dlls/jscript/parser.y index 29d805f..7e74880 100644 --- a/dlls/jscript/parser.y +++ b/dlls/jscript/parser.y @@ -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 diff --git a/dlls/jscript/tests/lang.js b/dlls/jscript/tests/lang.js index fa100ea..fd14c93 100644 --- a/dlls/jscript/tests/lang.js +++ b/dlls/jscript/tests/lang.js @@ -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() {}