"Safe Keywords" include: - Default - Error - Explicit - Property - Step
Signed-off-by: Brendan McGrath brendan@redmandi.com --- This patch just addresses the "Safe Keywords" and not the keywords that can be used after a 'dot'. Therefore this does not address bug 46318.
dlls/vbscript/lex.c | 10 ++++++---- dlls/vbscript/parser.y | 21 ++++++++++++--------- dlls/vbscript/tests/lang.vbs | 21 +++++++++++++++++++++ 3 files changed, 39 insertions(+), 13 deletions(-)
diff --git a/dlls/vbscript/lex.c b/dlls/vbscript/lex.c index 571854db58..751fdb2aa5 100644 --- a/dlls/vbscript/lex.c +++ b/dlls/vbscript/lex.c @@ -156,7 +156,7 @@ static inline BOOL is_identifier_char(WCHAR c) return isalnumW(c) || c == '_'; }
-static int check_keyword(parser_ctx_t *ctx, const WCHAR *word) +static int check_keyword(parser_ctx_t *ctx, const WCHAR *word, const WCHAR **lval) { const WCHAR *p1 = ctx->ptr; const WCHAR *p2 = word; @@ -173,18 +173,20 @@ static int check_keyword(parser_ctx_t *ctx, const WCHAR *word) if(*p2 || (p1 < ctx->end && is_identifier_char(*p1))) return 1;
+ if(lval) + *lval = word; ctx->ptr = p1; return 0; }
-static int check_keywords(parser_ctx_t *ctx) +static int check_keywords(parser_ctx_t *ctx, const WCHAR **lval) { int min = 0, max = ARRAY_SIZE(keywords)-1, r, i;
while(min <= max) { i = (min+max)/2;
- r = check_keyword(ctx, keywords[i].word); + r = check_keyword(ctx, keywords[i].word, lval); if(!r) return keywords[i].token;
@@ -412,7 +414,7 @@ static int parse_next_token(void *lval, parser_ctx_t *ctx) return parse_numeric_literal(ctx, lval);
if(isalphaW(c)) { - int ret = check_keywords(ctx); + int ret = check_keywords(ctx, lval); if(!ret) return parse_identifier(ctx, lval); if(ret != tREM) diff --git a/dlls/vbscript/parser.y b/dlls/vbscript/parser.y index 020109998e..b81d791966 100644 --- a/dlls/vbscript/parser.y +++ b/dlls/vbscript/parser.y @@ -71,8 +71,6 @@ static class_decl_t *add_dim_prop(parser_ctx_t*,class_decl_t*,dim_decl_t*,unsign
static statement_t *link_statements(statement_t*,statement_t*);
-static const WCHAR propertyW[] = {'p','r','o','p','e','r','t','y',0}; - #define STORAGE_IS_PRIVATE 1 #define STORAGE_IS_DEFAULT 2
@@ -108,17 +106,18 @@ static const WCHAR propertyW[] = {'p','r','o','p','e','r','t','y',0}; %token tTRUE tFALSE %token tNOT tAND tOR tXOR tEQV tIMP tNEQ %token tIS tLTEQ tGTEQ tMOD -%token tCALL tDIM tSUB tFUNCTION tPROPERTY tGET tLET tCONST +%token tCALL tDIM tSUB tFUNCTION tGET tLET tCONST %token tIF tELSE tELSEIF tEND tTHEN tEXIT -%token tWHILE tWEND tDO tLOOP tUNTIL tFOR tTO tSTEP tEACH tIN +%token tWHILE tWEND tDO tLOOP tUNTIL tFOR tTO tEACH tIN %token tSELECT tCASE %token tBYREF tBYVAL -%token tOPTION tEXPLICIT +%token tOPTION %token tSTOP %token tNOTHING tEMPTY tNULL -%token tCLASS tSET tNEW tPUBLIC tPRIVATE tDEFAULT tME -%token tERROR tNEXT tON tRESUME tGOTO +%token tCLASS tSET tNEW tPUBLIC tPRIVATE tME +%token tNEXT tON tRESUME tGOTO %token <string> tIdentifier tString +%token <string> tDEFAULT tERROR tEXPLICIT tPROPERTY tSTEP %token <lng> tLong tShort %token <dbl> tDouble
@@ -443,10 +442,14 @@ ArgumentDecl | tBYREF Identifier EmptyBrackets_opt { $$ = new_argument_decl(ctx, $2, TRUE); } | tBYVAL Identifier EmptyBrackets_opt { $$ = new_argument_decl(ctx, $2, FALSE); }
-/* 'property' may be both keyword and identifier, depending on context */ +/* these keywords may also be an identifier, depending on context */ Identifier : tIdentifier { $$ = $1; } - | tPROPERTY { $$ = propertyW; } + | tDEFAULT { $$ = $1; } + | tERROR { $$ = $1; } + | tEXPLICIT { $$ = $1; } + | tPROPERTY { $$ = $1; } + | tSTEP { $$ = $1; }
/* Most statements accept both new line and ':' as separators */ StSep diff --git a/dlls/vbscript/tests/lang.vbs b/dlls/vbscript/tests/lang.vbs index 2af77bdfcc..515dad94c5 100644 --- a/dlls/vbscript/tests/lang.vbs +++ b/dlls/vbscript/tests/lang.vbs @@ -1345,4 +1345,25 @@ end class set x = new RegExp Call ok(x.Global = false, "x.Global = " & x.Global)
+' test keywords that can also be a declared identifier +Dim default +default = "xx" +Call ok(default = "xx", "default = " & default & " expected ""xx""") + +Dim error +error = "xx" +Call ok(error = "xx", "error = " & error & " expected ""xx""") + +Dim explicit +explicit = "xx" +Call ok(explicit = "xx", "explicit = " & explicit & " expected ""xx""") + +Dim property +property = "xx" +Call ok(property = "xx", "property = " & property & " expected ""xx""") + +Dim step +step = "xx" +Call ok(step = "xx", "step = " & step & " expected ""xx""") + reportSuccess()
Hi,
While running your changed tests on Windows, I think I found new failures. Being a bot and all I'm not very good at pattern recognition, so I might be wrong, but could you please double-check?
Full results can be found at: https://testbot.winehq.org/JobDetails.pl?Key=47562
Your paranoid android.
=== wxppro (32 bit report) ===
vbscript: run.c:1670: Test failed: unexpected call OnScriptError run.c:2184: Test failed: expected global_success_d run.c:2185: Test failed: expected global_success_i run.c:2187: Test failed: parse_script failed: 800a0411
=== w2003std (32 bit report) ===
vbscript: run.c:1670: Test failed: unexpected call OnScriptError run.c:2184: Test failed: expected global_success_d run.c:2185: Test failed: expected global_success_i run.c:2187: Test failed: parse_script failed: 800a0411
=== wvistau64 (32 bit report) ===
vbscript: run.c:1670: Test failed: unexpected call OnScriptError run.c:2184: Test failed: expected global_success_d run.c:2185: Test failed: expected global_success_i run.c:2187: Test failed: parse_script failed: 800a0411
=== wvistau64_zh_CN (32 bit report) ===
vbscript: run.c:1670: Test failed: unexpected call OnScriptError run.c:2184: Test failed: expected global_success_d run.c:2185: Test failed: expected global_success_i run.c:2187: Test failed: parse_script failed: 800a0411
=== wvistau64_fr (32 bit report) ===
vbscript: run.c:1670: Test failed: unexpected call OnScriptError run.c:2184: Test failed: expected global_success_d run.c:2185: Test failed: expected global_success_i run.c:2187: Test failed: parse_script failed: 800a0411
=== wvistau64_he (32 bit report) ===
vbscript: run.c:1670: Test failed: unexpected call OnScriptError run.c:2184: Test failed: expected global_success_d run.c:2185: Test failed: expected global_success_i run.c:2187: Test failed: parse_script failed: 800a0411
=== w2008s64 (32 bit report) ===
vbscript: run.c:1670: Test failed: unexpected call OnScriptError run.c:2184: Test failed: expected global_success_d run.c:2185: Test failed: expected global_success_i run.c:2187: Test failed: parse_script failed: 800a0411
=== w7u (32 bit report) ===
vbscript: run.c:1670: Test failed: unexpected call OnScriptError run.c:2184: Test failed: expected global_success_d run.c:2185: Test failed: expected global_success_i run.c:2187: Test failed: parse_script failed: 800a0411
=== w7pro64 (32 bit report) ===
vbscript: run.c:1670: Test failed: unexpected call OnScriptError run.c:2184: Test failed: expected global_success_d run.c:2185: Test failed: expected global_success_i run.c:2187: Test failed: parse_script failed: 800a0411
=== w8 (32 bit report) ===
vbscript: run.c:1670: Test failed: unexpected call OnScriptError run.c:2184: Test failed: expected global_success_d run.c:2185: Test failed: expected global_success_i run.c:2187: Test failed: parse_script failed: 800a0411
=== w8adm (32 bit report) ===
vbscript: run.c:1670: Test failed: unexpected call OnScriptError run.c:2184: Test failed: expected global_success_d run.c:2185: Test failed: expected global_success_i run.c:2187: Test failed: parse_script failed: 800a0411
=== w864 (32 bit report) ===
vbscript: run.c:1670: Test failed: unexpected call OnScriptError run.c:2184: Test failed: expected global_success_d run.c:2185: Test failed: expected global_success_i run.c:2187: Test failed: parse_script failed: 800a0411
=== w1064 (32 bit report) ===
vbscript: run.c:1670: Test failed: unexpected call OnScriptError run.c:2184: Test failed: expected global_success_d run.c:2185: Test failed: expected global_success_i run.c:2187: Test failed: parse_script failed: 800a0411
=== wvistau64 (64 bit report) ===
vbscript: run.c:1670: Test failed: unexpected call OnScriptError run.c:2184: Test failed: expected global_success_d run.c:2185: Test failed: expected global_success_i run.c:2187: Test failed: parse_script failed: 800a0411
=== w2008s64 (64 bit report) ===
vbscript: run.c:1670: Test failed: unexpected call OnScriptError run.c:2184: Test failed: expected global_success_d run.c:2185: Test failed: expected global_success_i run.c:2187: Test failed: parse_script failed: 800a0411
=== w7pro64 (64 bit report) ===
vbscript: run.c:1670: Test failed: unexpected call OnScriptError run.c:2184: Test failed: expected global_success_d run.c:2185: Test failed: expected global_success_i run.c:2187: Test failed: parse_script failed: 800a0411
=== w864 (64 bit report) ===
vbscript: run.c:1670: Test failed: unexpected call OnScriptError run.c:2184: Test failed: expected global_success_d run.c:2185: Test failed: expected global_success_i run.c:2187: Test failed: parse_script failed: 800a0411
=== w1064 (64 bit report) ===
vbscript: run.c:1670: Test failed: unexpected call OnScriptError run.c:2184: Test failed: expected global_success_d run.c:2185: Test failed: expected global_success_i run.c:2187: Test failed: parse_script failed: 800a0411
"Safe Keywords" include: - Default - Error - Explicit - Property - Step
Signed-off-by: Brendan McGrath brendan@redmandi.com --- Changes since v1: - remove the test for property (as one already exists, causing failures on Windows)
dlls/vbscript/lex.c | 10 ++++++---- dlls/vbscript/parser.y | 21 ++++++++++++--------- dlls/vbscript/tests/lang.vbs | 17 +++++++++++++++++ 3 files changed, 35 insertions(+), 13 deletions(-)
diff --git a/dlls/vbscript/lex.c b/dlls/vbscript/lex.c index 571854db58..751fdb2aa5 100644 --- a/dlls/vbscript/lex.c +++ b/dlls/vbscript/lex.c @@ -156,7 +156,7 @@ static inline BOOL is_identifier_char(WCHAR c) return isalnumW(c) || c == '_'; }
-static int check_keyword(parser_ctx_t *ctx, const WCHAR *word) +static int check_keyword(parser_ctx_t *ctx, const WCHAR *word, const WCHAR **lval) { const WCHAR *p1 = ctx->ptr; const WCHAR *p2 = word; @@ -173,18 +173,20 @@ static int check_keyword(parser_ctx_t *ctx, const WCHAR *word) if(*p2 || (p1 < ctx->end && is_identifier_char(*p1))) return 1;
+ if(lval) + *lval = word; ctx->ptr = p1; return 0; }
-static int check_keywords(parser_ctx_t *ctx) +static int check_keywords(parser_ctx_t *ctx, const WCHAR **lval) { int min = 0, max = ARRAY_SIZE(keywords)-1, r, i;
while(min <= max) { i = (min+max)/2;
- r = check_keyword(ctx, keywords[i].word); + r = check_keyword(ctx, keywords[i].word, lval); if(!r) return keywords[i].token;
@@ -412,7 +414,7 @@ static int parse_next_token(void *lval, parser_ctx_t *ctx) return parse_numeric_literal(ctx, lval);
if(isalphaW(c)) { - int ret = check_keywords(ctx); + int ret = check_keywords(ctx, lval); if(!ret) return parse_identifier(ctx, lval); if(ret != tREM) diff --git a/dlls/vbscript/parser.y b/dlls/vbscript/parser.y index 020109998e..b81d791966 100644 --- a/dlls/vbscript/parser.y +++ b/dlls/vbscript/parser.y @@ -71,8 +71,6 @@ static class_decl_t *add_dim_prop(parser_ctx_t*,class_decl_t*,dim_decl_t*,unsign
static statement_t *link_statements(statement_t*,statement_t*);
-static const WCHAR propertyW[] = {'p','r','o','p','e','r','t','y',0}; - #define STORAGE_IS_PRIVATE 1 #define STORAGE_IS_DEFAULT 2
@@ -108,17 +106,18 @@ static const WCHAR propertyW[] = {'p','r','o','p','e','r','t','y',0}; %token tTRUE tFALSE %token tNOT tAND tOR tXOR tEQV tIMP tNEQ %token tIS tLTEQ tGTEQ tMOD -%token tCALL tDIM tSUB tFUNCTION tPROPERTY tGET tLET tCONST +%token tCALL tDIM tSUB tFUNCTION tGET tLET tCONST %token tIF tELSE tELSEIF tEND tTHEN tEXIT -%token tWHILE tWEND tDO tLOOP tUNTIL tFOR tTO tSTEP tEACH tIN +%token tWHILE tWEND tDO tLOOP tUNTIL tFOR tTO tEACH tIN %token tSELECT tCASE %token tBYREF tBYVAL -%token tOPTION tEXPLICIT +%token tOPTION %token tSTOP %token tNOTHING tEMPTY tNULL -%token tCLASS tSET tNEW tPUBLIC tPRIVATE tDEFAULT tME -%token tERROR tNEXT tON tRESUME tGOTO +%token tCLASS tSET tNEW tPUBLIC tPRIVATE tME +%token tNEXT tON tRESUME tGOTO %token <string> tIdentifier tString +%token <string> tDEFAULT tERROR tEXPLICIT tPROPERTY tSTEP %token <lng> tLong tShort %token <dbl> tDouble
@@ -443,10 +442,14 @@ ArgumentDecl | tBYREF Identifier EmptyBrackets_opt { $$ = new_argument_decl(ctx, $2, TRUE); } | tBYVAL Identifier EmptyBrackets_opt { $$ = new_argument_decl(ctx, $2, FALSE); }
-/* 'property' may be both keyword and identifier, depending on context */ +/* these keywords may also be an identifier, depending on context */ Identifier : tIdentifier { $$ = $1; } - | tPROPERTY { $$ = propertyW; } + | tDEFAULT { $$ = $1; } + | tERROR { $$ = $1; } + | tEXPLICIT { $$ = $1; } + | tPROPERTY { $$ = $1; } + | tSTEP { $$ = $1; }
/* Most statements accept both new line and ':' as separators */ StSep diff --git a/dlls/vbscript/tests/lang.vbs b/dlls/vbscript/tests/lang.vbs index 2af77bdfcc..d016e0e22c 100644 --- a/dlls/vbscript/tests/lang.vbs +++ b/dlls/vbscript/tests/lang.vbs @@ -1345,4 +1345,21 @@ end class set x = new RegExp Call ok(x.Global = false, "x.Global = " & x.Global)
+' test keywords that can also be a declared identifier +Dim default +default = "xx" +Call ok(default = "xx", "default = " & default & " expected ""xx""") + +Dim error +error = "xx" +Call ok(error = "xx", "error = " & error & " expected ""xx""") + +Dim explicit +explicit = "xx" +Call ok(explicit = "xx", "explicit = " & explicit & " expected ""xx""") + +Dim step +step = "xx" +Call ok(step = "xx", "step = " & step & " expected ""xx""") + reportSuccess()