Module: wine Branch: master Commit: dc2133cc66e12f8749e467909f5568d8d5054af2 URL: http://source.winehq.org/git/wine.git/?a=commit;h=dc2133cc66e12f8749e467909f...
Author: Jacek Caban jacek@codeweavers.com Date: Mon Sep 10 14:44:51 2012 +0200
jscript: Added support for no new line between break and identifier rule.
---
dlls/jscript/engine.h | 1 + dlls/jscript/lex.c | 26 +++++++++++++++----------- dlls/jscript/tests/lang.js | 17 +++++++++++++++++ 3 files changed, 33 insertions(+), 11 deletions(-)
diff --git a/dlls/jscript/engine.h b/dlls/jscript/engine.h index d0dec0d..b3648af 100644 --- a/dlls/jscript/engine.h +++ b/dlls/jscript/engine.h @@ -28,6 +28,7 @@ typedef struct { script_ctx_t *script; source_elements_t *source; BOOL nl; + BOOL implicit_nl_semicolon; BOOL is_html; BOOL lexer_error; HRESULT hres; diff --git a/dlls/jscript/lex.c b/dlls/jscript/lex.c index d2b87ac..39a1197 100644 --- a/dlls/jscript/lex.c +++ b/dlls/jscript/lex.c @@ -68,8 +68,9 @@ static const WCHAR withW[] = {'w','i','t','h',0}; static const struct { const WCHAR *word; int token; + BOOL no_nl; } keywords[] = { - {breakW, kBREAK}, + {breakW, kBREAK, TRUE}, {caseW, kCASE}, {catchW, kCATCH}, {continueW, kCONTINUE}, @@ -161,8 +162,10 @@ static int check_keywords(parser_ctx_t *ctx, const WCHAR **lval) i = (min+max)/2;
r = check_keyword(ctx, keywords[i].word, lval); - if(!r) + if(!r) { + ctx->implicit_nl_semicolon = keywords[i].no_nl; return keywords[i].token; + }
if(r > 0) min = i+1; @@ -173,14 +176,6 @@ static int check_keywords(parser_ctx_t *ctx, const WCHAR **lval) return 0; }
-static void skip_spaces(parser_ctx_t *ctx) -{ - while(ctx->ptr < ctx->end && isspaceW(*ctx->ptr)) { - if(is_endline(*ctx->ptr++)) - ctx->nl = TRUE; - } -} - static BOOL skip_html_comment(parser_ctx_t *ctx) { const WCHAR html_commentW[] = {'<','!','-','-',0}; @@ -509,11 +504,20 @@ static int parse_numeric_literal(parser_ctx_t *ctx, literal_t **literal) static int next_token(parser_ctx_t *ctx, void *lval) { do { - skip_spaces(ctx); + while(ctx->ptr < ctx->end && isspaceW(*ctx->ptr)) { + if(is_endline(*ctx->ptr++)) + ctx->nl = TRUE; + } if(ctx->ptr == ctx->end) return tEOF; }while(skip_comment(ctx) || skip_html_comment(ctx));
+ if(ctx->implicit_nl_semicolon) { + if(ctx->nl) + return ';'; + ctx->implicit_nl_semicolon = FALSE; + } + if(isalphaW(*ctx->ptr)) { int ret = check_keywords(ctx, lval); if(ret) diff --git a/dlls/jscript/tests/lang.js b/dlls/jscript/tests/lang.js index cb127da..d7f6884 100644 --- a/dlls/jscript/tests/lang.js +++ b/dlls/jscript/tests/lang.js @@ -1355,6 +1355,23 @@ ok(name_override_func === 3, "name_override_func = " + name_override_func); function name_override_func() {}; ok(name_override_func === 3, "name_override_func = " + name_override_func);
+/* NoNewline rule parser tests */ +while(true) { + if(true) break + tmp = false +} + +while(true) { + if(true) break /* + * no semicolon, but comment present */ + tmp = false +} + +while(true) { + if(true) break // no semicolon, but comment present + tmp = false +} + /* Keep this test in the end of file */ undefined = 6; ok(undefined === 6, "undefined = " + undefined);