Commit 7e420a47 authored by Jacek Caban's avatar Jacek Caban Committed by Alexandre Julliard

vbscript: Add parser support for redim statement.

parent 37e27296
......@@ -72,9 +72,11 @@ static const struct {
{L"on", tON},
{L"option", tOPTION},
{L"or", tOR},
{L"preserve", tPRESERVE},
{L"private", tPRIVATE},
{L"property", tPROPERTY},
{L"public", tPUBLIC},
{L"redim", tREDIM},
{L"rem", tREM},
{L"resume", tRESUME},
{L"select", tSELECT},
......
......@@ -120,6 +120,7 @@ typedef enum {
STAT_FUNC,
STAT_IF,
STAT_ONERROR,
STAT_REDIM,
STAT_SELECT,
STAT_SET,
STAT_STOP,
......@@ -165,6 +166,13 @@ typedef struct _dim_statement_t {
dim_decl_t *dim_decls;
} dim_statement_t;
typedef struct {
statement_t stat;
const WCHAR *identifier;
BOOL preserve;
expression_t *dims;
} redim_statement_t;
typedef struct _arg_decl_t {
const WCHAR *name;
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_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_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_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*);
......@@ -112,7 +113,8 @@ static statement_t *link_statements(statement_t*,statement_t*);
%token <string> tTRUE tFALSE
%token <string> tNOT tAND tOR tXOR tEQV tIMP
%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> tWHILE tWEND tDO tLOOP tUNTIL tFOR tTO tEACH tIN
%token <string> tSELECT tCASE tWITH
......@@ -133,7 +135,7 @@ static statement_t *link_statements(statement_t*,statement_t*);
%type <expression> ConstExpression NumericLiteralExpression
%type <member> MemberExpression
%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 <func_decl> FunctionDecl PropertyDecl
%type <elseif> ElseIfs_opt ElseIfs ElseIf
......@@ -194,6 +196,8 @@ SimpleStatement
| CallExpression '=' Expression
{ $$ = new_assign_statement(ctx, $1, $3); 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; }
| tWHILE Expression StSep StatementsNl_opt tWEND
{ $$ = 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;
$$ = new_member_expression(ctx, dot_expr, $2); CHECK_ERROR; }
Preserve_opt
: /* empty */ { $$ = FALSE; }
| tPRESERVE { $$ = TRUE; }
DimDeclList
: DimDecl { $$ = $1; }
| DimDecl ',' DimDeclList { $1->next = $3; $$ = $1; }
......@@ -537,6 +545,8 @@ DotIdentifier
| tRESUME { $$ = $1; }
| tGOTO { $$ = $1; }
| tWITH { $$ = $1; }
| tREDIM { $$ = $1; }
| tPRESERVE { $$ = $1; }
/* Most statements accept both new line and ':' as separators */
StSep
......@@ -864,6 +874,20 @@ static statement_t *new_dim_statement(parser_ctx_t *ctx, dim_decl_t *decls)
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)
{
elseif_decl_t *decl;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment