Commit 78beca78 authored by Jacek Caban's avatar Jacek Caban Committed by Alexandre Julliard

jscript: Use wide-char literals in lexer.

parent 5007b2c7
...@@ -32,76 +32,42 @@ ...@@ -32,76 +32,42 @@
WINE_DEFAULT_DEBUG_CHANNEL(jscript); WINE_DEFAULT_DEBUG_CHANNEL(jscript);
static const WCHAR breakW[] = {'b','r','e','a','k',0};
static const WCHAR caseW[] = {'c','a','s','e',0};
static const WCHAR catchW[] = {'c','a','t','c','h',0};
static const WCHAR continueW[] = {'c','o','n','t','i','n','u','e',0};
static const WCHAR defaultW[] = {'d','e','f','a','u','l','t',0};
static const WCHAR deleteW[] = {'d','e','l','e','t','e',0};
static const WCHAR doW[] = {'d','o',0};
static const WCHAR elseW[] = {'e','l','s','e',0};
static const WCHAR falseW[] = {'f','a','l','s','e',0};
static const WCHAR finallyW[] = {'f','i','n','a','l','l','y',0};
static const WCHAR forW[] = {'f','o','r',0};
static const WCHAR functionW[] = {'f','u','n','c','t','i','o','n',0};
static const WCHAR getW[] = {'g','e','t',0};
static const WCHAR ifW[] = {'i','f',0};
static const WCHAR inW[] = {'i','n',0};
static const WCHAR instanceofW[] = {'i','n','s','t','a','n','c','e','o','f',0};
static const WCHAR newW[] = {'n','e','w',0};
static const WCHAR nullW[] = {'n','u','l','l',0};
static const WCHAR returnW[] = {'r','e','t','u','r','n',0};
static const WCHAR setW[] = {'s','e','t',0};
static const WCHAR switchW[] = {'s','w','i','t','c','h',0};
static const WCHAR thisW[] = {'t','h','i','s',0};
static const WCHAR throwW[] = {'t','h','r','o','w',0};
static const WCHAR trueW[] = {'t','r','u','e',0};
static const WCHAR tryW[] = {'t','r','y',0};
static const WCHAR typeofW[] = {'t','y','p','e','o','f',0};
static const WCHAR varW[] = {'v','a','r',0};
static const WCHAR voidW[] = {'v','o','i','d',0};
static const WCHAR whileW[] = {'w','h','i','l','e',0};
static const WCHAR withW[] = {'w','i','t','h',0};
static const WCHAR elifW[] = {'e','l','i','f',0};
static const WCHAR endW[] = {'e','n','d',0};
static const struct { static const struct {
const WCHAR *word; const WCHAR *word;
int token; int token;
BOOL no_nl; BOOL no_nl;
unsigned min_version; unsigned min_version;
} keywords[] = { } keywords[] = {
{breakW, kBREAK, TRUE}, {L"break", kBREAK, TRUE},
{caseW, kCASE}, {L"case", kCASE},
{catchW, kCATCH}, {L"catch", kCATCH},
{continueW, kCONTINUE, TRUE}, {L"continue", kCONTINUE, TRUE},
{defaultW, kDEFAULT}, {L"default", kDEFAULT},
{deleteW, kDELETE}, {L"delete", kDELETE},
{doW, kDO}, {L"do", kDO},
{elseW, kELSE}, {L"else", kELSE},
{falseW, kFALSE}, {L"false", kFALSE},
{finallyW, kFINALLY}, {L"finally", kFINALLY},
{forW, kFOR}, {L"for", kFOR},
{functionW, kFUNCTION}, {L"function", kFUNCTION},
{getW, kGET, FALSE, SCRIPTLANGUAGEVERSION_ES5}, {L"get", kGET, FALSE, SCRIPTLANGUAGEVERSION_ES5},
{ifW, kIF}, {L"if", kIF},
{inW, kIN}, {L"in", kIN},
{instanceofW, kINSTANCEOF}, {L"instanceof", kINSTANCEOF},
{newW, kNEW}, {L"new", kNEW},
{nullW, kNULL}, {L"null", kNULL},
{returnW, kRETURN, TRUE}, {L"return", kRETURN, TRUE},
{setW, kSET, FALSE, SCRIPTLANGUAGEVERSION_ES5}, {L"set", kSET, FALSE, SCRIPTLANGUAGEVERSION_ES5},
{switchW, kSWITCH}, {L"switch", kSWITCH},
{thisW, kTHIS}, {L"this", kTHIS},
{throwW, kTHROW}, {L"throw", kTHROW},
{trueW, kTRUE}, {L"true", kTRUE},
{tryW, kTRY}, {L"try", kTRY},
{typeofW, kTYPEOF}, {L"typeof", kTYPEOF},
{varW, kVAR}, {L"var", kVAR},
{voidW, kVOID}, {L"void", kVOID},
{whileW, kWHILE}, {L"while", kWHILE},
{withW, kWITH} {L"with", kWITH}
}; };
static int lex_error(parser_ctx_t *ctx, HRESULT hres) static int lex_error(parser_ctx_t *ctx, HRESULT hres)
...@@ -895,14 +861,6 @@ static BOOL init_cc(parser_ctx_t *ctx) ...@@ -895,14 +861,6 @@ static BOOL init_cc(parser_ctx_t *ctx)
{ {
cc_ctx_t *cc; cc_ctx_t *cc;
static const WCHAR _win32W[] = {'_','w','i','n','3','2',0};
static const WCHAR _win64W[] = {'_','w','i','n','6','4',0};
static const WCHAR _x86W[] = {'_','x','8','6',0};
static const WCHAR _amd64W[] = {'_','a','m','d','6','4',0};
static const WCHAR _jscriptW[] = {'_','j','s','c','r','i','p','t',0};
static const WCHAR _jscript_buildW[] = {'_','j','s','c','r','i','p','t','_','b','u','i','l','d',0};
static const WCHAR _jscript_versionW[] = {'_','j','s','c','r','i','p','t','_','v','e','r','s','i','o','n',0};
if(ctx->script->cc) if(ctx->script->cc)
return TRUE; return TRUE;
...@@ -914,11 +872,11 @@ static BOOL init_cc(parser_ctx_t *ctx) ...@@ -914,11 +872,11 @@ static BOOL init_cc(parser_ctx_t *ctx)
cc->vars = NULL; cc->vars = NULL;
if(!new_cc_var(cc, _jscriptW, -1, ccval_bool(TRUE)) if(!new_cc_var(cc, L"_jscript", -1, ccval_bool(TRUE))
|| !new_cc_var(cc, sizeof(void*) == 8 ? _win64W : _win32W, -1, ccval_bool(TRUE)) || !new_cc_var(cc, sizeof(void*) == 8 ? L"_win64" : L"_win32", -1, ccval_bool(TRUE))
|| !new_cc_var(cc, sizeof(void*) == 8 ? _amd64W : _x86W, -1, ccval_bool(TRUE)) || !new_cc_var(cc, sizeof(void*) == 8 ? L"_amd64" : L"_x86", -1, ccval_bool(TRUE))
|| !new_cc_var(cc, _jscript_versionW, -1, ccval_num(JSCRIPT_MAJOR_VERSION + (DOUBLE)JSCRIPT_MINOR_VERSION/10.0)) || !new_cc_var(cc, L"_jscript_version", -1, ccval_num(JSCRIPT_MAJOR_VERSION + (DOUBLE)JSCRIPT_MINOR_VERSION/10.0))
|| !new_cc_var(cc, _jscript_buildW, -1, ccval_num(JSCRIPT_BUILD_VERSION))) { || !new_cc_var(cc, L"_jscript_build", -1, ccval_num(JSCRIPT_BUILD_VERSION))) {
release_cc(cc); release_cc(cc);
lex_error(ctx, E_OUTOFMEMORY); lex_error(ctx, E_OUTOFMEMORY);
return FALSE; return FALSE;
...@@ -974,12 +932,12 @@ int try_parse_ccval(parser_ctx_t *ctx, ccval_t *r) ...@@ -974,12 +932,12 @@ int try_parse_ccval(parser_ctx_t *ctx, ccval_t *r)
return 1; return 1;
} }
if(!check_keyword(ctx, trueW, NULL)) { if(!check_keyword(ctx, L"true", NULL)) {
*r = ccval_bool(TRUE); *r = ccval_bool(TRUE);
return 1; return 1;
} }
if(!check_keyword(ctx, falseW, NULL)) { if(!check_keyword(ctx, L"false", NULL)) {
*r = ccval_bool(FALSE); *r = ccval_bool(FALSE);
return 1; return 1;
} }
...@@ -1000,13 +958,13 @@ static int skip_code(parser_ctx_t *ctx, BOOL exec_else) ...@@ -1000,13 +958,13 @@ static int skip_code(parser_ctx_t *ctx, BOOL exec_else)
} }
ctx->ptr = ptr+1; ctx->ptr = ptr+1;
if(!check_keyword(ctx, endW, NULL)) { if(!check_keyword(ctx, L"end", NULL)) {
if(--if_depth) if(--if_depth)
continue; continue;
return 0; return 0;
} }
if(exec_else && !check_keyword(ctx, elifW, NULL)) { if(exec_else && !check_keyword(ctx, L"elif", NULL)) {
if(if_depth > 1) if(if_depth > 1)
continue; continue;
...@@ -1024,7 +982,7 @@ static int skip_code(parser_ctx_t *ctx, BOOL exec_else) ...@@ -1024,7 +982,7 @@ static int skip_code(parser_ctx_t *ctx, BOOL exec_else)
return 0; return 0;
} }
if(exec_else && !check_keyword(ctx, elseW, NULL)) { if(exec_else && !check_keyword(ctx, L"else", NULL)) {
if(if_depth > 1) if(if_depth > 1)
continue; continue;
...@@ -1033,7 +991,7 @@ static int skip_code(parser_ctx_t *ctx, BOOL exec_else) ...@@ -1033,7 +991,7 @@ static int skip_code(parser_ctx_t *ctx, BOOL exec_else)
return 0; return 0;
} }
if(!check_keyword(ctx, ifW, NULL)) { if(!check_keyword(ctx, L"if", NULL)) {
if_depth++; if_depth++;
continue; continue;
} }
...@@ -1047,15 +1005,12 @@ static int cc_token(parser_ctx_t *ctx, void *lval) ...@@ -1047,15 +1005,12 @@ static int cc_token(parser_ctx_t *ctx, void *lval)
unsigned id_len = 0; unsigned id_len = 0;
cc_var_t *var; cc_var_t *var;
static const WCHAR cc_onW[] = {'c','c','_','o','n',0};
static const WCHAR setW[] = {'s','e','t',0};
ctx->ptr++; ctx->ptr++;
if(!check_keyword(ctx, cc_onW, NULL)) if(!check_keyword(ctx, L"cc_on", NULL))
return init_cc(ctx) ? 0 : -1; return init_cc(ctx) ? 0 : -1;
if(!check_keyword(ctx, setW, NULL)) { if(!check_keyword(ctx, L"set", NULL)) {
const WCHAR *ident; const WCHAR *ident;
unsigned ident_len; unsigned ident_len;
cc_var_t *var; cc_var_t *var;
...@@ -1089,7 +1044,7 @@ static int cc_token(parser_ctx_t *ctx, void *lval) ...@@ -1089,7 +1044,7 @@ static int cc_token(parser_ctx_t *ctx, void *lval)
return 0; return 0;
} }
if(!check_keyword(ctx, ifW, NULL)) { if(!check_keyword(ctx, L"if", NULL)) {
if(!init_cc(ctx)) if(!init_cc(ctx))
return -1; return -1;
...@@ -1108,14 +1063,14 @@ static int cc_token(parser_ctx_t *ctx, void *lval) ...@@ -1108,14 +1063,14 @@ static int cc_token(parser_ctx_t *ctx, void *lval)
return skip_code(ctx, TRUE); return skip_code(ctx, TRUE);
} }
if(!check_keyword(ctx, elifW, NULL) || !check_keyword(ctx, elseW, NULL)) { if(!check_keyword(ctx, L"elif", NULL) || !check_keyword(ctx, L"else", NULL)) {
if(!ctx->cc_if_depth) if(!ctx->cc_if_depth)
return lex_error(ctx, JS_E_SYNTAX); return lex_error(ctx, JS_E_SYNTAX);
return skip_code(ctx, FALSE); return skip_code(ctx, FALSE);
} }
if(!check_keyword(ctx, endW, NULL)) { if(!check_keyword(ctx, L"end", NULL)) {
if(!ctx->cc_if_depth) if(!ctx->cc_if_depth)
return lex_error(ctx, JS_E_SYNTAX); return lex_error(ctx, JS_E_SYNTAX);
......
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