vbscript: Add parser support for redim statement.
Signed-off-by: Jacek Caban <jacek@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
37e2729607
commit
7e420a475e
|
@ -72,9 +72,11 @@ static const struct {
|
||||||
{L"on", tON},
|
{L"on", tON},
|
||||||
{L"option", tOPTION},
|
{L"option", tOPTION},
|
||||||
{L"or", tOR},
|
{L"or", tOR},
|
||||||
|
{L"preserve", tPRESERVE},
|
||||||
{L"private", tPRIVATE},
|
{L"private", tPRIVATE},
|
||||||
{L"property", tPROPERTY},
|
{L"property", tPROPERTY},
|
||||||
{L"public", tPUBLIC},
|
{L"public", tPUBLIC},
|
||||||
|
{L"redim", tREDIM},
|
||||||
{L"rem", tREM},
|
{L"rem", tREM},
|
||||||
{L"resume", tRESUME},
|
{L"resume", tRESUME},
|
||||||
{L"select", tSELECT},
|
{L"select", tSELECT},
|
||||||
|
|
|
@ -120,6 +120,7 @@ typedef enum {
|
||||||
STAT_FUNC,
|
STAT_FUNC,
|
||||||
STAT_IF,
|
STAT_IF,
|
||||||
STAT_ONERROR,
|
STAT_ONERROR,
|
||||||
|
STAT_REDIM,
|
||||||
STAT_SELECT,
|
STAT_SELECT,
|
||||||
STAT_SET,
|
STAT_SET,
|
||||||
STAT_STOP,
|
STAT_STOP,
|
||||||
|
@ -165,6 +166,13 @@ typedef struct _dim_statement_t {
|
||||||
dim_decl_t *dim_decls;
|
dim_decl_t *dim_decls;
|
||||||
} dim_statement_t;
|
} dim_statement_t;
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
statement_t stat;
|
||||||
|
const WCHAR *identifier;
|
||||||
|
BOOL preserve;
|
||||||
|
expression_t *dims;
|
||||||
|
} redim_statement_t;
|
||||||
|
|
||||||
typedef struct _arg_decl_t {
|
typedef struct _arg_decl_t {
|
||||||
const WCHAR *name;
|
const WCHAR *name;
|
||||||
BOOL by_ref;
|
BOOL by_ref;
|
||||||
|
|
|
@ -51,6 +51,7 @@ static statement_t *new_call_statement(parser_ctx_t*,BOOL,expression_t*);
|
||||||
static statement_t *new_assign_statement(parser_ctx_t*,expression_t*,expression_t*);
|
static statement_t *new_assign_statement(parser_ctx_t*,expression_t*,expression_t*);
|
||||||
static statement_t *new_set_statement(parser_ctx_t*,member_expression_t*,expression_t*,expression_t*);
|
static statement_t *new_set_statement(parser_ctx_t*,member_expression_t*,expression_t*,expression_t*);
|
||||||
static statement_t *new_dim_statement(parser_ctx_t*,dim_decl_t*);
|
static statement_t *new_dim_statement(parser_ctx_t*,dim_decl_t*);
|
||||||
|
static statement_t *new_redim_statement(parser_ctx_t*,const WCHAR*,BOOL,expression_t*);
|
||||||
static statement_t *new_while_statement(parser_ctx_t*,statement_type_t,expression_t*,statement_t*);
|
static statement_t *new_while_statement(parser_ctx_t*,statement_type_t,expression_t*,statement_t*);
|
||||||
static statement_t *new_forto_statement(parser_ctx_t*,const WCHAR*,expression_t*,expression_t*,expression_t*,statement_t*);
|
static statement_t *new_forto_statement(parser_ctx_t*,const WCHAR*,expression_t*,expression_t*,expression_t*,statement_t*);
|
||||||
static statement_t *new_foreach_statement(parser_ctx_t*,const WCHAR*,expression_t*,statement_t*);
|
static statement_t *new_foreach_statement(parser_ctx_t*,const WCHAR*,expression_t*,statement_t*);
|
||||||
|
@ -112,7 +113,8 @@ static statement_t *link_statements(statement_t*,statement_t*);
|
||||||
%token <string> tTRUE tFALSE
|
%token <string> tTRUE tFALSE
|
||||||
%token <string> tNOT tAND tOR tXOR tEQV tIMP
|
%token <string> tNOT tAND tOR tXOR tEQV tIMP
|
||||||
%token <string> tIS tMOD
|
%token <string> tIS tMOD
|
||||||
%token <string> tCALL tDIM tSUB tFUNCTION tGET tLET tCONST
|
%token <string> tCALL tSUB tFUNCTION tGET tLET tCONST
|
||||||
|
%token <string> tDIM tREDIM tPRESERVE
|
||||||
%token <string> tIF tELSE tELSEIF tEND tTHEN tEXIT
|
%token <string> tIF tELSE tELSEIF tEND tTHEN tEXIT
|
||||||
%token <string> tWHILE tWEND tDO tLOOP tUNTIL tFOR tTO tEACH tIN
|
%token <string> tWHILE tWEND tDO tLOOP tUNTIL tFOR tTO tEACH tIN
|
||||||
%token <string> tSELECT tCASE tWITH
|
%token <string> tSELECT tCASE tWITH
|
||||||
|
@ -133,7 +135,7 @@ static statement_t *link_statements(statement_t*,statement_t*);
|
||||||
%type <expression> ConstExpression NumericLiteralExpression
|
%type <expression> ConstExpression NumericLiteralExpression
|
||||||
%type <member> MemberExpression
|
%type <member> MemberExpression
|
||||||
%type <expression> Arguments Arguments_opt ArgumentList ArgumentList_opt Step_opt ExpressionList
|
%type <expression> Arguments Arguments_opt ArgumentList ArgumentList_opt Step_opt ExpressionList
|
||||||
%type <boolean> OptionExplicit_opt DoType
|
%type <boolean> OptionExplicit_opt DoType Preserve_opt
|
||||||
%type <arg_decl> ArgumentsDecl_opt ArgumentDeclList ArgumentDecl
|
%type <arg_decl> ArgumentsDecl_opt ArgumentDeclList ArgumentDecl
|
||||||
%type <func_decl> FunctionDecl PropertyDecl
|
%type <func_decl> FunctionDecl PropertyDecl
|
||||||
%type <elseif> ElseIfs_opt ElseIfs ElseIf
|
%type <elseif> ElseIfs_opt ElseIfs ElseIf
|
||||||
|
@ -194,6 +196,8 @@ SimpleStatement
|
||||||
| CallExpression '=' Expression
|
| CallExpression '=' Expression
|
||||||
{ $$ = new_assign_statement(ctx, $1, $3); CHECK_ERROR; }
|
{ $$ = new_assign_statement(ctx, $1, $3); CHECK_ERROR; }
|
||||||
| tDIM DimDeclList { $$ = new_dim_statement(ctx, $2); CHECK_ERROR; }
|
| tDIM DimDeclList { $$ = new_dim_statement(ctx, $2); CHECK_ERROR; }
|
||||||
|
| tREDIM Preserve_opt tIdentifier '(' ArgumentList ')'
|
||||||
|
{ $$ = new_redim_statement(ctx, $3, $2, $5); CHECK_ERROR; }
|
||||||
| IfStatement { $$ = $1; }
|
| IfStatement { $$ = $1; }
|
||||||
| tWHILE Expression StSep StatementsNl_opt tWEND
|
| tWHILE Expression StSep StatementsNl_opt tWEND
|
||||||
{ $$ = new_while_statement(ctx, STAT_WHILE, $2, $4); CHECK_ERROR; }
|
{ $$ = new_while_statement(ctx, STAT_WHILE, $2, $4); CHECK_ERROR; }
|
||||||
|
@ -231,6 +235,10 @@ MemberExpression
|
||||||
| tDOT DotIdentifier { expression_t *dot_expr = new_expression(ctx, EXPR_DOT, sizeof(*dot_expr)); CHECK_ERROR;
|
| tDOT DotIdentifier { expression_t *dot_expr = new_expression(ctx, EXPR_DOT, sizeof(*dot_expr)); CHECK_ERROR;
|
||||||
$$ = new_member_expression(ctx, dot_expr, $2); CHECK_ERROR; }
|
$$ = new_member_expression(ctx, dot_expr, $2); CHECK_ERROR; }
|
||||||
|
|
||||||
|
Preserve_opt
|
||||||
|
: /* empty */ { $$ = FALSE; }
|
||||||
|
| tPRESERVE { $$ = TRUE; }
|
||||||
|
|
||||||
DimDeclList
|
DimDeclList
|
||||||
: DimDecl { $$ = $1; }
|
: DimDecl { $$ = $1; }
|
||||||
| DimDecl ',' DimDeclList { $1->next = $3; $$ = $1; }
|
| DimDecl ',' DimDeclList { $1->next = $3; $$ = $1; }
|
||||||
|
@ -537,6 +545,8 @@ DotIdentifier
|
||||||
| tRESUME { $$ = $1; }
|
| tRESUME { $$ = $1; }
|
||||||
| tGOTO { $$ = $1; }
|
| tGOTO { $$ = $1; }
|
||||||
| tWITH { $$ = $1; }
|
| tWITH { $$ = $1; }
|
||||||
|
| tREDIM { $$ = $1; }
|
||||||
|
| tPRESERVE { $$ = $1; }
|
||||||
|
|
||||||
/* Most statements accept both new line and ':' as separators */
|
/* Most statements accept both new line and ':' as separators */
|
||||||
StSep
|
StSep
|
||||||
|
@ -864,6 +874,20 @@ static statement_t *new_dim_statement(parser_ctx_t *ctx, dim_decl_t *decls)
|
||||||
return &stat->stat;
|
return &stat->stat;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static statement_t *new_redim_statement(parser_ctx_t *ctx, const WCHAR *identifier, BOOL preserve, expression_t *dims)
|
||||||
|
{
|
||||||
|
redim_statement_t *stat;
|
||||||
|
|
||||||
|
stat = new_statement(ctx, STAT_REDIM, sizeof(*stat));
|
||||||
|
if(!stat)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
stat->identifier = identifier;
|
||||||
|
stat->preserve = preserve;
|
||||||
|
stat->dims = dims;
|
||||||
|
return &stat->stat;
|
||||||
|
}
|
||||||
|
|
||||||
static elseif_decl_t *new_elseif_decl(parser_ctx_t *ctx, expression_t *expr, statement_t *stat)
|
static elseif_decl_t *new_elseif_decl(parser_ctx_t *ctx, expression_t *expr, statement_t *stat)
|
||||||
{
|
{
|
||||||
elseif_decl_t *decl;
|
elseif_decl_t *decl;
|
||||||
|
|
Loading…
Reference in New Issue