Jacek Caban : vbscript: Always treat keywords after dot as identifiers.
Alexandre Julliard
julliard at winehq.org
Tue Nov 12 16:56:06 CST 2019
Module: wine
Branch: master
Commit: 107bba15632eb2ae58358cf3610d5790e71da4fb
URL: https://source.winehq.org/git/wine.git/?a=commit;h=107bba15632eb2ae58358cf3610d5790e71da4fb
Author: Jacek Caban <jacek at codeweavers.com>
Date: Tue Nov 12 14:26:04 2019 +0100
vbscript: Always treat keywords after dot as identifiers.
Signed-off-by: Jacek Caban <jacek at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
---
dlls/vbscript/lex.c | 4 ++-
dlls/vbscript/parser.y | 62 +++-----------------------------------------
dlls/vbscript/tests/lang.vbs | 5 +++-
dlls/vbscript/tests/run.c | 11 ++++----
4 files changed, 16 insertions(+), 66 deletions(-)
diff --git a/dlls/vbscript/lex.c b/dlls/vbscript/lex.c
index 197285c98e..444774b434 100644
--- a/dlls/vbscript/lex.c
+++ b/dlls/vbscript/lex.c
@@ -358,7 +358,9 @@ static int parse_next_token(void *lval, parser_ctx_t *ctx)
return parse_numeric_literal(ctx, lval);
if(iswalpha(c)) {
- int ret = check_keywords(ctx, lval);
+ int ret = 0;
+ if(ctx->last_token != '.' && ctx->last_token != tDOT)
+ 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 9315b7ea39..a28717ff76 100644
--- a/dlls/vbscript/parser.y
+++ b/dlls/vbscript/parser.y
@@ -144,7 +144,7 @@ static statement_t *link_statements(statement_t*,statement_t*);
%type <dim_decl> DimDeclList DimDecl
%type <dim_list> DimList
%type <const_decl> ConstDecl ConstDeclList
-%type <string> Identifier DotIdentifier
+%type <string> Identifier
%type <case_clausule> CaseClausules
%%
@@ -231,8 +231,8 @@ SimpleStatement
MemberExpression
: Identifier { $$ = new_member_expression(ctx, NULL, $1); CHECK_ERROR; }
- | CallExpression '.' DotIdentifier { $$ = new_member_expression(ctx, $1, $3); CHECK_ERROR; }
- | tDOT DotIdentifier { expression_t *dot_expr = new_expression(ctx, EXPR_DOT, sizeof(*dot_expr)); CHECK_ERROR;
+ | CallExpression '.' tIdentifier { $$ = new_member_expression(ctx, $1, $3); CHECK_ERROR; }
+ | tDOT tIdentifier { expression_t *dot_expr = new_expression(ctx, EXPR_DOT, sizeof(*dot_expr)); CHECK_ERROR;
$$ = new_member_expression(ctx, dot_expr, $2); CHECK_ERROR; }
Preserve_opt
@@ -492,62 +492,6 @@ Identifier
| tPROPERTY { $$ = $1; }
| tSTEP { $$ = $1; }
-/* most keywords can be an identifier after a dot */
-DotIdentifier
- : Identifier { $$ = $1; }
- | tTRUE { $$ = $1; }
- | tFALSE { $$ = $1; }
- | tNOT { $$ = $1; }
- | tAND { $$ = $1; }
- | tOR { $$ = $1; }
- | tXOR { $$ = $1; }
- | tEQV { $$ = $1; }
- | tIMP { $$ = $1; }
- | tIS { $$ = $1; }
- | tMOD { $$ = $1; }
- | tCALL { $$ = $1; }
- | tDIM { $$ = $1; }
- | tSUB { $$ = $1; }
- | tFUNCTION { $$ = $1; }
- | tGET { $$ = $1; }
- | tLET { $$ = $1; }
- | tCONST { $$ = $1; }
- | tIF { $$ = $1; }
- | tELSE { $$ = $1; }
- | tELSEIF { $$ = $1; }
- | tEND { $$ = $1; }
- | tTHEN { $$ = $1; }
- | tEXIT { $$ = $1; }
- | tWHILE { $$ = $1; }
- | tWEND { $$ = $1; }
- | tDO { $$ = $1; }
- | tLOOP { $$ = $1; }
- | tUNTIL { $$ = $1; }
- | tFOR { $$ = $1; }
- | tTO { $$ = $1; }
- | tEACH { $$ = $1; }
- | tIN { $$ = $1; }
- | tSELECT { $$ = $1; }
- | tCASE { $$ = $1; }
- | tBYREF { $$ = $1; }
- | tBYVAL { $$ = $1; }
- | tOPTION { $$ = $1; }
- | tNOTHING { $$ = $1; }
- | tEMPTY { $$ = $1; }
- | tNULL { $$ = $1; }
- | tCLASS { $$ = $1; }
- | tSET { $$ = $1; }
- | tNEW { $$ = $1; }
- | tPUBLIC { $$ = $1; }
- | tPRIVATE { $$ = $1; }
- | tNEXT { $$ = $1; }
- | tON { $$ = $1; }
- | tRESUME { $$ = $1; }
- | tGOTO { $$ = $1; }
- | tWITH { $$ = $1; }
- | tREDIM { $$ = $1; }
- | tPRESERVE { $$ = $1; }
-
/* Most statements accept both new line and ':' as separators */
StSep
: tNL
diff --git a/dlls/vbscript/tests/lang.vbs b/dlls/vbscript/tests/lang.vbs
index 46e2ac7ab8..6eebe287fe 100644
--- a/dlls/vbscript/tests/lang.vbs
+++ b/dlls/vbscript/tests/lang.vbs
@@ -1514,7 +1514,7 @@ call test_identifiers()
sub test_dotIdentifiers
' test keywords that can also be an identifier after a dot
- ' Call ok(testObj.rem = 10, "testObj.rem = " & testObj.rem & " expected 10")
+ Call ok(testObj.rem = 10, "testObj.rem = " & testObj.rem & " expected 10")
Call ok(testObj.true = 10, "testObj.true = " & testObj.true & " expected 10")
Call ok(testObj.false = 10, "testObj.false = " & testObj.false & " expected 10")
Call ok(testObj.not = 10, "testObj.not = " & testObj.not & " expected 10")
@@ -1567,6 +1567,9 @@ sub test_dotIdentifiers
Call ok(testObj.with = 10, "testObj.with = " & testObj.with & " expected 10")
Call ok(testObj.redim = 10, "testObj.redim = " & testObj.redim & " expected 10")
Call ok(testObj.preserve = 10, "testObj.preserve = " & testObj.preserve & " expected 10")
+ Call ok(testObj.property = 10, "testObj.property = " & testObj.property & " expected 10")
+ Call ok(testObj.me = 10, "testObj.me = " & testObj.me & " expected 10")
+ Call ok(testObj.stop = 10, "testObj.stop = " & testObj.stop & " expected 10")
end sub
call test_dotIdentifiers
diff --git a/dlls/vbscript/tests/run.c b/dlls/vbscript/tests/run.c
index 707fd89493..5fc23707e3 100644
--- a/dlls/vbscript/tests/run.c
+++ b/dlls/vbscript/tests/run.c
@@ -859,7 +859,10 @@ static HRESULT WINAPI testObj_GetDispID(IDispatchEx *iface, BSTR bstrName, DWORD
{ L"goto", DISPID_TESTOBJ_KEYWORD },
{ L"redim", DISPID_TESTOBJ_KEYWORD },
{ L"preserve", DISPID_TESTOBJ_KEYWORD },
- { L"with", DISPID_TESTOBJ_KEYWORD }
+ { L"with", DISPID_TESTOBJ_KEYWORD },
+ { L"property", DISPID_TESTOBJ_KEYWORD },
+ { L"me", DISPID_TESTOBJ_KEYWORD },
+ { L"stop", DISPID_TESTOBJ_KEYWORD }
};
test_grfdex(grfdex, fdexNameCaseInsensitive);
@@ -2881,12 +2884,8 @@ static void run_tests(void)
parse_script_a("Option Explicit\nset test.setobj = testObj");
CHECK_CALLED(global_setobj_i);
- SET_EXPECT(OnScriptError);
hres = parse_script_ar("dim x\nx = testObj.rem");
- todo_wine
ok(hres == S_OK, "use of 'rem' as dot identifier failed: %x08\n", hres);
- todo_wine
- CHECK_NOT_CALLED(OnScriptError);
SET_EXPECT(testobj_propget_d);
SET_EXPECT(testobj_propget_i);
@@ -2948,6 +2947,8 @@ static void run_tests(void)
"x(counter(), counter()) = counter\n");
CHECK_CALLED(testobj_valueput_i);
+ parse_script_a("dim x\nx = testObj.property(1)");
+
parse_htmlscript_a("<!--");
parse_htmlscript_a(" -->");
parse_htmlscript_a("<!--\ndim x\nx=1\n-->\n");
More information about the wine-cvs
mailing list