vbscipt: Allow ':' to be a separator in select case statement.

This commit is contained in:
Jacek Caban 2014-03-08 14:52:56 +01:00 committed by Alexandre Julliard
parent 6f45902252
commit aa045d51b3
2 changed files with 29 additions and 3 deletions

View File

@ -205,7 +205,7 @@ SimpleStatement
{ $$ = new_forto_statement(ctx, $2, $4, $6, $7, $9); CHECK_ERROR; }
| tFOR tEACH Identifier tIN Expression tNL StatementsNl_opt tNEXT
{ $$ = new_foreach_statement(ctx, $3, $5, $7); }
| tSELECT tCASE Expression tNL CaseClausules tEND tSELECT
| tSELECT tCASE Expression StSep CaseClausules tEND tSELECT
{ $$ = new_select_statement(ctx, $3, $5); }
MemberExpression
@ -273,8 +273,8 @@ Else_opt
CaseClausules
: /* empty */ { $$ = NULL; }
| tCASE tELSE tNL StatementsNl { $$ = new_case_clausule(ctx, NULL, $4, NULL); }
| tCASE ExpressionList tNL StatementsNl_opt CaseClausules
| tCASE tELSE StSep StatementsNl { $$ = new_case_clausule(ctx, NULL, $4, NULL); }
| tCASE ExpressionList StSep StatementsNl_opt CaseClausules
{ $$ = new_case_clausule(ctx, $2, $4, $5); }
Arguments_opt
@ -442,6 +442,12 @@ ArgumentDecl
Identifier
: tIdentifier { $$ = $1; }
| tPROPERTY { $$ = propertyW; }
/* Some statements accept both new line and ':' as a separator */
StSep
: tNL
| ':'
%%
static int parser_error(parser_ctx_t *ctx, const char *str)

View File

@ -224,6 +224,10 @@ if false then x = y : if true then call ok(false, "embedded if called")
if false then x=1 else x=2 end if
x = false
if false then x = true : x = true
Call ok(x = false, "x <> false")
if false then
ok false, "if false called"
end if
@ -538,6 +542,22 @@ end select
select case 0
end select
x = false
select case 2
case 3,1,2,4: x = true
case 5,6,7
Call ok(false, "unexpected case")
end select
Call ok(x, "wrong case")
x = false
select case 2: case 5,6,7: Call ok(false, "unexpected case")
case 2,1,2,4
x = true
case else: Call ok(false, "unexpected case else")
end select
Call ok(x, "wrong case")
if false then
Sub testsub
x = true