Jacek Caban : vbscript: Added dim statement parser implementation.

Alexandre Julliard julliard at winehq.org
Tue Sep 13 12:18:09 CDT 2011


Module: wine
Branch: master
Commit: 924da4056bf7a83712c85705f911721666858077
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=924da4056bf7a83712c85705f911721666858077

Author: Jacek Caban <jacek at codeweavers.com>
Date:   Tue Sep 13 11:36:26 2011 +0200

vbscript: Added dim statement parser implementation.

---

 dlls/vbscript/parse.h  |   13 ++++++++++++-
 dlls/vbscript/parser.y |   37 ++++++++++++++++++++++++++++++++++++-
 2 files changed, 48 insertions(+), 2 deletions(-)

diff --git a/dlls/vbscript/parse.h b/dlls/vbscript/parse.h
index f7b9436..d50889d 100644
--- a/dlls/vbscript/parse.h
+++ b/dlls/vbscript/parse.h
@@ -79,7 +79,8 @@ typedef struct {
 
 typedef enum {
     STAT_ASSIGN,
-    STAT_CALL
+    STAT_CALL,
+    STAT_DIM
 } statement_type_t;
 
 typedef struct _statement_t {
@@ -98,6 +99,16 @@ typedef struct {
     expression_t *value_expr;
 } assign_statement_t;
 
+typedef struct _dim_decl_t {
+    const WCHAR *name;
+    struct _dim_decl_t *next;
+} dim_decl_t;
+
+typedef struct _dim_statement_t {
+    statement_t stat;
+    dim_decl_t *dim_decls;
+} dim_statement_t;
+
 typedef struct {
     const WCHAR *code;
     const WCHAR *ptr;
diff --git a/dlls/vbscript/parser.y b/dlls/vbscript/parser.y
index 5d9ae7d..b5e740e 100644
--- a/dlls/vbscript/parser.y
+++ b/dlls/vbscript/parser.y
@@ -46,7 +46,10 @@ static expression_t *new_binary_expression(parser_ctx_t*,expression_type_t,expre
 static member_expression_t *new_member_expression(parser_ctx_t*,expression_t*,const WCHAR*);
 
 static statement_t *new_call_statement(parser_ctx_t*,member_expression_t*);
- static statement_t *new_assign_statement(parser_ctx_t*,member_expression_t*,expression_t*);
+static statement_t *new_assign_statement(parser_ctx_t*,member_expression_t*,expression_t*);
+static statement_t *new_dim_statement(parser_ctx_t*,dim_decl_t*);
+
+static dim_decl_t *new_dim_decl(parser_ctx_t*,const WCHAR*,dim_decl_t*);
 
 #define CHECK_ERROR if(((parser_ctx_t*)ctx)->hres != S_OK) YYABORT
 
@@ -60,6 +63,7 @@ static statement_t *new_call_statement(parser_ctx_t*,member_expression_t*);
     statement_t *statement;
     expression_t *expression;
     member_expression_t *member;
+    dim_decl_t *dim_decl;
     LONG lng;
     BOOL bool;
     double dbl;
@@ -89,6 +93,7 @@ static statement_t *new_call_statement(parser_ctx_t*,member_expression_t*);
 %type <member> MemberExpression
 %type <expression> Arguments_opt ArgumentList_opt ArgumentList
 %type <bool> OptionExplicit_opt
+%type <dim_decl> DimDeclList
 
 %%
 
@@ -111,11 +116,16 @@ Statement
     | tCALL MemberExpression Arguments_opt  { $2->args = $3; $$ = new_call_statement(ctx, $2); CHECK_ERROR; }
     | MemberExpression Arguments_opt '=' Expression
                                             { $1->args = $2; $$ = new_assign_statement(ctx, $1, $4); CHECK_ERROR; }
+    | tDIM DimDeclList                      { $$ = new_dim_statement(ctx, $2); CHECK_ERROR; }
 
 MemberExpression
     : tIdentifier                           { $$ = new_member_expression(ctx, NULL, $1); CHECK_ERROR; }
     | CallExpression '.' tIdentifier        { $$ = new_member_expression(ctx, $1, $3); CHECK_ERROR; }
 
+DimDeclList /* FIXME: Support arrays */
+    : tIdentifier                           { $$ = new_dim_decl(ctx, $1, NULL); CHECK_ERROR; }
+    | tIdentifier ',' DimDeclList           { $$ = new_dim_decl(ctx, $1, $3); CHECK_ERROR; }
+
 Arguments_opt
     : EmptyBrackets_opt             { $$ = NULL; }
     | '(' ArgumentList ')'          { $$ = $2; }
@@ -341,6 +351,31 @@ static statement_t *new_assign_statement(parser_ctx_t *ctx, member_expression_t
     return &stat->stat;
 }
 
+static dim_decl_t *new_dim_decl(parser_ctx_t *ctx, const WCHAR *name, dim_decl_t *next)
+{
+    dim_decl_t *decl;
+
+    decl = parser_alloc(ctx, sizeof(*decl));
+    if(!decl)
+        return NULL;
+
+    decl->name = name;
+    decl->next = next;
+    return decl;
+}
+
+static statement_t *new_dim_statement(parser_ctx_t *ctx, dim_decl_t *decls)
+{
+    dim_statement_t *stat;
+
+    stat = new_statement(ctx, STAT_DIM, sizeof(*stat));
+    if(!stat)
+        return NULL;
+
+    stat->dim_decls = decls;
+    return &stat->stat;
+}
+
 void *parser_alloc(parser_ctx_t *ctx, size_t size)
 {
     void *ret;




More information about the wine-cvs mailing list