[PATCH 0/1] MR10333: Draft: vbscript: Refactor ElseIf and Else grammar rules to avoid reduce/reduce conflicts.
Introduce StatementsBody, InlineStatements and InlineStatements_opt non-terminals whose FIRST sets do not overlap with StSep. This allows splitting ElseIf into multi-line (strict, requires statement separator) and inline (lenient, allows trailing End If) forms, and splitting Else_opt into separator and inline forms that naturally reject "Else End If" without a semantic check. -- https://gitlab.winehq.org/wine/wine/-/merge_requests/10333
From: Francis De Brabandere <francisdb@gmail.com> Introduce StatementsBody, InlineStatements and InlineStatements_opt non-terminals whose FIRST sets do not overlap with StSep. This allows splitting ElseIf into multi-line (strict, requires statement separator) and inline (lenient, allows trailing End If) forms, and splitting Else_opt into separator and inline forms that naturally reject "Else End If" without a semantic check. --- dlls/vbscript/parser.y | 26 ++++++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-) diff --git a/dlls/vbscript/parser.y b/dlls/vbscript/parser.y index 20c30eed681..ca42fa758c4 100644 --- a/dlls/vbscript/parser.y +++ b/dlls/vbscript/parser.y @@ -137,7 +137,7 @@ static statement_t *link_statements(statement_t*,statement_t*); %token <date> tDate %type <statement> Statement SimpleStatement StatementNl StatementsNl StatementsNl_opt BodyStatements IfStatement Else_opt -%type <statement> GlobalDimDeclaration +%type <statement> GlobalDimDeclaration StatementsBody InlineStatements InlineStatements_opt %type <expression> Expression LiteralExpression PrimaryExpression EqualityExpression CallExpression ExpressionNl_opt %type <expression> ConcatExpression AdditiveExpression ModExpression IntdivExpression MultiplicativeExpression ExpExpression %type <expression> NotExpression UnaryExpression AndExpression OrExpression XorExpression EqvExpression SignExpression @@ -325,12 +325,30 @@ ElseIfs | ElseIf ElseIfs { $1->next = $2; $$ = $1; } ElseIf - : tELSEIF Expression tTHEN StSep_opt StatementsNl_opt - { $$ = new_elseif_decl(ctx, @$, $2, $5); } + : tELSEIF Expression tTHEN StSep StatementsNl_opt + { $$ = new_elseif_decl(ctx, @$, $2, $5); } + | tELSEIF Expression tTHEN InlineStatements_opt + { $$ = new_elseif_decl(ctx, @$, $2, $4); } Else_opt : /* empty */ { $$ = NULL; } - | tELSE StSep_opt StatementsNl_opt { $$ = $3; } + | tELSE StSep StatementsBody { $$ = $3; } + | tELSE InlineStatements { $$ = $2; } + +StatementsBody + : /* empty */ { $$ = NULL; } + | StSep StatementsBody { $$ = $2; } + | SimpleStatement { $$ = $1; } + | SimpleStatement StSep StatementsBody { $1->next = $3; $$ = $1; } + +InlineStatements_opt + : /* empty */ { $$ = NULL; } + | SimpleStatement { $$ = $1; } + | SimpleStatement StSep StatementsBody { $1->next = $3; $$ = $1; } + +InlineStatements + : SimpleStatement { $$ = $1; } + | SimpleStatement StSep StatementsBody { $1->next = $3; $$ = $1; } CaseClausules : /* empty */ { $$ = NULL; } -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/10333
participants (2)
-
Francis De Brabandere -
Francis De Brabandere (@francisdb)