[PATCH v2 2/2] vbscript: Allow GET, SET and LET to be used as id

Brendan McGrath brendan at redmandi.com
Sat Feb 9 18:45:24 CST 2019


Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=46318
Signed-off-by: Brendan McGrath <brendan at redmandi.com>
---
I took a look at the way jscript did this - but I couldn't work out how it
was using '$1' as a value. So I ended up following the approach used for
'property'.

This meant I had to add a new constant definition for each keyword that
could be used as an indentifier. As a result I went with a conservative
approach and only added three more (in addition to 'property').

As a result - this passes the test in the bug report but perhaps doesn't
address the other keywords.

 dlls/vbscript/parser.y | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)

diff --git a/dlls/vbscript/parser.y b/dlls/vbscript/parser.y
index 020109998e..9e9f5ab932 100644
--- a/dlls/vbscript/parser.y
+++ b/dlls/vbscript/parser.y
@@ -72,6 +72,9 @@ 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};
+static const WCHAR getW[] = {'g','e','t',0};
+static const WCHAR setW[] = {'s','e','t',0};
+static const WCHAR letW[] = {'l','e','t',0};
 
 #define STORAGE_IS_PRIVATE    1
 #define STORAGE_IS_DEFAULT    2
@@ -138,7 +141,7 @@ static const WCHAR propertyW[] = {'p','r','o','p','e','r','t','y',0};
 %type <dim_decl> DimDeclList DimDecl
 %type <dim_list> DimList
 %type <const_decl> ConstDecl ConstDeclList
-%type <string> Identifier
+%type <string> Identifier ReservedAsIdentifier
 %type <case_clausule> CaseClausules
 
 %%
@@ -445,7 +448,13 @@ ArgumentDecl
 
 /* 'property' may be both keyword and identifier, depending on context */
 Identifier
-    : tIdentifier    { $$ = $1; }
+    : tIdentifier           { $$ = $1; }
+    | ReservedAsIdentifier  { $$ = $1; }
+
+ReservedAsIdentifier
+    : tGET           { $$ = getW; }
+    | tSET           { $$ = setW; }
+    | tLET           { $$ = letW; }
     | tPROPERTY      { $$ = propertyW; }
 
 /* Most statements accept both new line and ':' as separators */
diff --git a/dlls/vbscript/tests/run.c b/dlls/vbscript/tests/run.c
index bc3e0742df..2cb52f4145 100644
--- a/dlls/vbscript/tests/run.c
+++ b/dlls/vbscript/tests/run.c
@@ -2408,7 +2408,6 @@ static void run_tests(void)
 
-    hres = parse_script_ar("Set oLocator = CreateObject(\"Wbemscripting.SWbemLocator\")\r"
-                           "Set oReg = oLocator.ConnectServer(\"\", \"root\\default\", \"\", \"\").Get(\"StdRegProv\")");
-    todo_wine ok(hres == S_OK, "parse_script failed: %08x\n", hres);
+    parse_script_a("Set oLocator = CreateObject(\"Wbemscripting.SWbemLocator\")\r"
+                   "Set oReg = oLocator.ConnectServer(\"\", \"root\\default\", \"\", \"\").Get(\"StdRegProv\")");
 
     run_from_res("lang.vbs");
     run_from_res("api.vbs");

-- 
2.17.1




More information about the wine-devel mailing list