vbscript: Added assign statement parser implementation.
[wine] / dlls / vbscript / parse.h
1 /*
2  * Copyright 2011 Jacek Caban for CodeWeavers
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Lesser General Public
6  * License as published by the Free Software Foundation; either
7  * version 2.1 of the License, or (at your option) any later version.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12  * Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public
15  * License along with this library; if not, write to the Free Software
16  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
17  */
18
19 typedef enum {
20     EXPR_ADD,
21     EXPR_BOOL,
22     EXPR_CONCAT,
23     EXPR_DOUBLE,
24     EXPR_EMPTY,
25     EXPR_EQUAL,
26     EXPR_MEMBER,
27     EXPR_NEG,
28     EXPR_NEQUAL,
29     EXPR_NOT,
30     EXPR_NULL,
31     EXPR_STRING,
32     EXPR_SUB,
33     EXPR_ULONG,
34     EXPR_USHORT
35 } expression_type_t;
36
37 typedef struct _expression_t {
38     expression_type_t type;
39     struct _expression_t *next;
40 } expression_t;
41
42 typedef struct {
43     expression_t expr;
44     VARIANT_BOOL value;
45 } bool_expression_t;
46
47 typedef struct {
48     expression_t expr;
49     LONG value;
50 } int_expression_t;
51
52 typedef struct {
53     expression_t expr;
54     double value;
55 } double_expression_t;
56
57 typedef struct {
58     expression_t expr;
59     const WCHAR *value;
60 } string_expression_t;
61
62 typedef struct {
63     expression_t expr;
64     expression_t *subexpr;
65 } unary_expression_t;
66
67 typedef struct {
68     expression_t expr;
69     expression_t *left;
70     expression_t *right;
71 } binary_expression_t;
72
73 typedef struct {
74     expression_t expr;
75     expression_t *obj_expr;
76     const WCHAR *identifier;
77     expression_t *args;
78 } member_expression_t;
79
80 typedef enum {
81     STAT_ASSIGN,
82     STAT_CALL
83 } statement_type_t;
84
85 typedef struct _statement_t {
86     statement_type_t type;
87     struct _statement_t *next;
88 } statement_t;
89
90 typedef struct {
91     statement_t stat;
92     member_expression_t *expr;
93 } call_statement_t;
94
95 typedef struct {
96     statement_t stat;
97     member_expression_t *member_expr;
98     expression_t *value_expr;
99 } assign_statement_t;
100
101 typedef struct {
102     const WCHAR *code;
103     const WCHAR *ptr;
104     const WCHAR *end;
105
106     BOOL option_explicit;
107     BOOL parse_complete;
108     HRESULT hres;
109
110     int last_token;
111     unsigned last_nl;
112
113     statement_t *stats;
114     statement_t *stats_tail;
115
116     vbsheap_t heap;
117 } parser_ctx_t;
118
119 HRESULT parse_script(parser_ctx_t*,const WCHAR*) DECLSPEC_HIDDEN;
120 void parser_release(parser_ctx_t*) DECLSPEC_HIDDEN;
121 int parser_lex(void*,parser_ctx_t*) DECLSPEC_HIDDEN;
122 void *parser_alloc(parser_ctx_t*,size_t) DECLSPEC_HIDDEN;