From: Robert Wilhelm Subject: [PATCH 1/2] vbscript: Allow keywords to be used as function name. Message-Id: <4a33cd6b979d255e1d698c6e637d6535a2c714a2.camel@gmx.net> Date: Mon, 26 Oct 2020 23:17:46 +0100 Signed-off-by: Robert Wilhelm --- dlls/vbscript/lex.c | 10 +++++++++- dlls/vbscript/tests/lang.vbs | 22 ++++++++++++++++++++++ 2 files changed, 31 insertions(+), 1 deletion(-) diff --git a/dlls/vbscript/lex.c b/dlls/vbscript/lex.c index 251374d90e6..78fca8271cc 100644 --- a/dlls/vbscript/lex.c +++ b/dlls/vbscript/lex.c @@ -99,6 +99,14 @@ static inline BOOL is_identifier_char(WCHAR c) return iswalnum(c) || c == '_'; } +static BOOL is_identifier( int token) +{ + if (token == tIdentifier || token == tDEFAULT || token == tERROR || + token == tEXPLICIT || token == tPROPERTY || token == tSTEP) + return TRUE; + return FALSE; +} + static int check_keyword(parser_ctx_t *ctx, const WCHAR *word, const WCHAR **lval) { const WCHAR *p1 = ctx->ptr; @@ -425,7 +433,7 @@ static int parse_next_token(void *lval, unsigned *loc, parser_ctx_t *ctx) * Parser can't predict if bracket is part of argument expression or an argument * in call expression. We predict it here instead. */ - if(ctx->last_token == tIdentifier || ctx->last_token == ')') + if(is_identifier(ctx->last_token) || ctx->last_token == ')') return '('; return tEXPRLBRACKET; case '"': diff --git a/dlls/vbscript/tests/lang.vbs b/dlls/vbscript/tests/lang.vbs index 65f8a458cd7..570bb7fbcb3 100644 --- a/dlls/vbscript/tests/lang.vbs +++ b/dlls/vbscript/tests/lang.vbs @@ -1631,9 +1631,31 @@ sub test_identifiers Dim step step = "xx" Call ok(step = "xx", "step = " & step & " expected ""xx""") + + Dim property + property = "xx" + Call ok(property = "xx", "property = " & property & " expected ""xx""") end sub call test_identifiers() +Class class_test_identifiers_as_function_name + Sub Property ( par ) + End Sub + + Function Error( par ) + End Function + + Sub Default () + End Sub + + Function Explicit (par) + Explicit = par + End Function + + Sub Step ( default ) + End Sub +End Class + 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") -- 2.26.2