[PATCH 0/1] MR10489: vbscript: Return specific error codes for missing keywords in parser.
Add error productions in the bison grammar for five cases where a specific keyword is expected after a recognized prefix: - Expected '=' after identifier in Const declaration (error 1011) - Expected 'To' after expression in For loop (error 1013) - Expected 'Then' after expression in If statement (error 1017) - Expected 'Case' after Select (error 1021) - Expected 'In' after identifier in For Each loop (error 1046) Previously these all fell through to the generic E_FAIL path in parser_error(). Now each sets the correct VBSE_EXPECTED_* error code via MAKE_VBSERROR before aborting the parse. -- https://gitlab.winehq.org/wine/wine/-/merge_requests/10489
From: Francis De Brabandere <francisdb@gmail.com> Add error productions in the bison grammar for five cases where a specific keyword is expected after a recognized prefix: - Expected '=' after identifier in Const declaration (error 1011) - Expected 'To' after expression in For loop (error 1013) - Expected 'Then' after expression in If statement (error 1017) - Expected 'Case' after Select (error 1021) - Expected 'In' after identifier in For Each loop (error 1046) Previously these all fell through to the generic E_FAIL path in parser_error(). Now each sets the correct VBSE_EXPECTED_* error code via MAKE_VBSERROR before aborting the parse. --- dlls/vbscript/parser.y | 6 ++++++ dlls/vbscript/tests/run.c | 10 +++++----- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/dlls/vbscript/parser.y b/dlls/vbscript/parser.y index c1a5b944268..646c7e17891 100644 --- a/dlls/vbscript/parser.y +++ b/dlls/vbscript/parser.y @@ -243,10 +243,14 @@ SimpleStatement | tCONST ConstDeclList { $$ = new_const_statement(ctx, @$, $2); CHECK_ERROR; } | tFOR Identifier '=' Expression tTO Expression Step_opt StSep StatementsNl_opt tNEXT { $$ = new_forto_statement(ctx, @$, $2, $4, $6, $7, $9); CHECK_ERROR; } + | tFOR Identifier '=' Expression error + { ctx->hres = MAKE_VBSERROR(VBSE_EXPECTED_TO); YYABORT; } | tFOR tEACH Identifier tIN Expression StSep StatementsNl_opt tNEXT { $$ = new_foreach_statement(ctx, @$, $3, $5, $7); } + | tFOR tEACH Identifier error { ctx->hres = MAKE_VBSERROR(VBSE_EXPECTED_IN); YYABORT; } | tSELECT tCASE Expression StSep CaseClausules tEND tSELECT { $$ = new_select_statement(ctx, @$, $3, $5); } + | tSELECT error { ctx->hres = MAKE_VBSERROR(VBSE_EXPECTED_CASE); YYABORT; } | tWITH Expression StSep StatementsNl_opt tEND tWITH { $$ = new_with_statement(ctx, @$, $2, $4); } @@ -295,6 +299,7 @@ ConstDeclList ConstDecl : Identifier '=' ConstExpression { $$ = new_const_decl(ctx, $1, $3); CHECK_ERROR; } + | Identifier error { ctx->hres = MAKE_VBSERROR(VBSE_EXPECTED_ASSIGN); YYABORT; } ConstExpression : LiteralExpression { $$ = $1; } @@ -316,6 +321,7 @@ IfStatement { $$ = new_if_statement(ctx, @$, $2, $4, NULL, $6); CHECK_ERROR; } | tIF Expression tTHEN Statement tELSE EndIf_opt { $$ = new_if_statement(ctx, @$, $2, $4, NULL, NULL); CHECK_ERROR; } + | tIF Expression error { ctx->hres = MAKE_VBSERROR(VBSE_EXPECTED_THEN); YYABORT; } EndIf_opt : /* empty */ diff --git a/dlls/vbscript/tests/run.c b/dlls/vbscript/tests/run.c index d3aebff098a..52797852ef0 100644 --- a/dlls/vbscript/tests/run.c +++ b/dlls/vbscript/tests/run.c @@ -2921,19 +2921,19 @@ static void test_parse_errors(void) /* Expected '=' - error 1011 */ L"Const x\n", 0, 7, - NULL, S_OK, -1011 + NULL, S_OK, 1011 }, { /* Expected 'To' - error 1013 */ L"For i = 1 x 10\nNext\n", 0, 10, - NULL, S_OK, -1013 + NULL, S_OK, 1013 }, { /* Expected 'Then' - error 1017 */ L"If True\nEnd If\n", 0, 7, - NULL, S_OK, -1017 + NULL, S_OK, 1017 }, { /* Expected 'Wend' - error 1018 */ @@ -2957,7 +2957,7 @@ static void test_parse_errors(void) /* Expected 'Case' - error 1021 */ L"Select x\nEnd Select\n", 0, 7, - NULL, S_OK, -1021 + NULL, S_OK, 1021 }, { /* Expected integer constant - error 1026 */ @@ -2987,7 +2987,7 @@ static void test_parse_errors(void) /* Expected 'In' - error 1046 */ L"For Each x = arr\nNext\n", 0, 11, - NULL, S_OK, -1046 + NULL, S_OK, 1046 }, { /* Must be defined inside a Class - error 1048 */ -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/10489
participants (2)
-
Francis De Brabandere -
Francis De Brabandere (@francisdb)