jscript: Added support for no new line between break and identifier rule.

This commit is contained in:
Jacek Caban 2012-09-10 14:44:51 +02:00 committed by Alexandre Julliard
parent 3f2365d5de
commit dc2133cc66
3 changed files with 33 additions and 11 deletions

View file

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

View file

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

View file

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