vbscript: Added a hack for parameterized assignments with one argument.
[wine/multimedia.git] / dlls / vbscript / parse.h
blob50151d3f29c88dc1ced021b20cd59bb054dba900
1 /*
2 * Copyright 2011 Jacek Caban for CodeWeavers
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.
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.
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
19 typedef enum {
20 EXPR_ADD,
21 EXPR_AND,
22 EXPR_BOOL,
23 EXPR_BRACKETS,
24 EXPR_CONCAT,
25 EXPR_DIV,
26 EXPR_DOUBLE,
27 EXPR_EMPTY,
28 EXPR_EQUAL,
29 EXPR_EQV,
30 EXPR_EXP,
31 EXPR_GT,
32 EXPR_GTEQ,
33 EXPR_IDIV,
34 EXPR_IMP,
35 EXPR_IS,
36 EXPR_LT,
37 EXPR_LTEQ,
38 EXPR_ME,
39 EXPR_MEMBER,
40 EXPR_MOD,
41 EXPR_MUL,
42 EXPR_NEG,
43 EXPR_NEQUAL,
44 EXPR_NEW,
45 EXPR_NOT,
46 EXPR_NOTHING,
47 EXPR_NULL,
48 EXPR_OR,
49 EXPR_STRING,
50 EXPR_SUB,
51 EXPR_ULONG,
52 EXPR_USHORT,
53 EXPR_XOR
54 } expression_type_t;
56 typedef struct _expression_t {
57 expression_type_t type;
58 struct _expression_t *next;
59 } expression_t;
61 typedef struct {
62 expression_t expr;
63 VARIANT_BOOL value;
64 } bool_expression_t;
66 typedef struct {
67 expression_t expr;
68 LONG value;
69 } int_expression_t;
71 typedef struct {
72 expression_t expr;
73 double value;
74 } double_expression_t;
76 typedef struct {
77 expression_t expr;
78 const WCHAR *value;
79 } string_expression_t;
81 typedef struct {
82 expression_t expr;
83 expression_t *subexpr;
84 } unary_expression_t;
86 typedef struct {
87 expression_t expr;
88 expression_t *left;
89 expression_t *right;
90 } binary_expression_t;
92 typedef struct {
93 expression_t expr;
94 expression_t *obj_expr;
95 const WCHAR *identifier;
96 expression_t *args;
97 } member_expression_t;
99 typedef enum {
100 STAT_ASSIGN,
101 STAT_CALL,
102 STAT_CONST,
103 STAT_DIM,
104 STAT_DOUNTIL,
105 STAT_DOWHILE,
106 STAT_EXITDO,
107 STAT_EXITFOR,
108 STAT_EXITFUNC,
109 STAT_EXITPROP,
110 STAT_EXITSUB,
111 STAT_FOREACH,
112 STAT_FORTO,
113 STAT_FUNC,
114 STAT_IF,
115 STAT_ONERROR,
116 STAT_SET,
117 STAT_STOP,
118 STAT_UNTIL,
119 STAT_WHILE,
120 STAT_WHILELOOP
121 } statement_type_t;
123 typedef struct _statement_t {
124 statement_type_t type;
125 struct _statement_t *next;
126 } statement_t;
128 typedef struct {
129 statement_t stat;
130 member_expression_t *expr;
131 BOOL is_strict;
132 } call_statement_t;
134 typedef struct {
135 statement_t stat;
136 member_expression_t *member_expr;
137 expression_t *value_expr;
138 } assign_statement_t;
140 typedef struct _dim_decl_t {
141 const WCHAR *name;
142 struct _dim_decl_t *next;
143 } dim_decl_t;
145 typedef struct _dim_statement_t {
146 statement_t stat;
147 dim_decl_t *dim_decls;
148 } dim_statement_t;
150 typedef struct _arg_decl_t {
151 const WCHAR *name;
152 BOOL by_ref;
153 struct _arg_decl_t *next;
154 } arg_decl_t;
156 typedef struct _function_decl_t {
157 const WCHAR *name;
158 function_type_t type;
159 BOOL is_public;
160 arg_decl_t *args;
161 statement_t *body;
162 struct _function_decl_t *next;
163 struct _function_decl_t *next_prop_func;
164 } function_decl_t;
166 typedef struct {
167 statement_t stat;
168 function_decl_t *func_decl;
169 } function_statement_t;
171 typedef struct _class_prop_decl_t {
172 BOOL is_public;
173 const WCHAR *name;
174 struct _class_prop_decl_t *next;
175 } class_prop_decl_t;
177 typedef struct _class_decl_t {
178 const WCHAR *name;
179 function_decl_t *funcs;
180 class_prop_decl_t *props;
181 struct _class_decl_t *next;
182 } class_decl_t;
184 typedef struct _elseif_decl_t {
185 expression_t *expr;
186 statement_t *stat;
187 struct _elseif_decl_t *next;
188 } elseif_decl_t;
190 typedef struct {
191 statement_t stat;
192 expression_t *expr;
193 statement_t *if_stat;
194 elseif_decl_t *elseifs;
195 statement_t *else_stat;
196 } if_statement_t;
198 typedef struct {
199 statement_t stat;
200 expression_t *expr;
201 statement_t *body;
202 } while_statement_t;
204 typedef struct {
205 statement_t stat;
206 const WCHAR *identifier;
207 expression_t *from_expr;
208 expression_t *to_expr;
209 expression_t *step_expr;
210 statement_t *body;
211 } forto_statement_t;
213 typedef struct {
214 statement_t stat;
215 const WCHAR *identifier;
216 expression_t *group_expr;
217 statement_t *body;
218 } foreach_statement_t;
220 typedef struct {
221 statement_t stat;
222 BOOL resume_next;
223 } onerror_statement_t;
225 typedef struct _const_decl_t {
226 const WCHAR *name;
227 expression_t *value_expr;
228 struct _const_decl_t *next;
229 } const_decl_t;
231 typedef struct {
232 statement_t stat;
233 const_decl_t *decls;
234 } const_statement_t;
236 typedef struct {
237 const WCHAR *code;
238 const WCHAR *ptr;
239 const WCHAR *end;
241 BOOL option_explicit;
242 BOOL parse_complete;
243 HRESULT hres;
245 int last_token;
246 unsigned last_nl;
248 statement_t *stats;
249 statement_t *stats_tail;
250 class_decl_t *class_decls;
252 vbsheap_t heap;
253 } parser_ctx_t;
255 HRESULT parse_script(parser_ctx_t*,const WCHAR*) DECLSPEC_HIDDEN;
256 void parser_release(parser_ctx_t*) DECLSPEC_HIDDEN;
257 int parser_lex(void*,parser_ctx_t*) DECLSPEC_HIDDEN;
258 void *parser_alloc(parser_ctx_t*,size_t) DECLSPEC_HIDDEN;