widl: Generate helper macros for WinRT implementation.
[wine/zf.git] / dlls / vbscript / parse.h
blob2888ea3b546cf2f421aefb86e98a939d7cd333ce
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_CALL,
25 EXPR_CONCAT,
26 EXPR_DIV,
27 EXPR_DOT,
28 EXPR_DOUBLE,
29 EXPR_EMPTY,
30 EXPR_EQUAL,
31 EXPR_EQV,
32 EXPR_EXP,
33 EXPR_GT,
34 EXPR_GTEQ,
35 EXPR_IDIV,
36 EXPR_IMP,
37 EXPR_INT,
38 EXPR_IS,
39 EXPR_LT,
40 EXPR_LTEQ,
41 EXPR_ME,
42 EXPR_MEMBER,
43 EXPR_MOD,
44 EXPR_MUL,
45 EXPR_NEG,
46 EXPR_NEQUAL,
47 EXPR_NEW,
48 EXPR_NOARG, /* not a real expression */
49 EXPR_NOT,
50 EXPR_NOTHING,
51 EXPR_NULL,
52 EXPR_OR,
53 EXPR_STRING,
54 EXPR_SUB,
55 EXPR_XOR
56 } expression_type_t;
58 typedef struct _expression_t {
59 expression_type_t type;
60 struct _expression_t *next;
61 } expression_t;
63 typedef struct {
64 expression_t expr;
65 VARIANT_BOOL value;
66 } bool_expression_t;
68 typedef struct {
69 expression_t expr;
70 LONG value;
71 } int_expression_t;
73 typedef struct {
74 expression_t expr;
75 double value;
76 } double_expression_t;
78 typedef struct {
79 expression_t expr;
80 const WCHAR *value;
81 } string_expression_t;
83 typedef struct {
84 expression_t expr;
85 expression_t *subexpr;
86 } unary_expression_t;
88 typedef struct {
89 expression_t expr;
90 expression_t *left;
91 expression_t *right;
92 } binary_expression_t;
94 typedef struct {
95 expression_t expr;
96 expression_t *obj_expr;
97 const WCHAR *identifier;
98 } member_expression_t;
100 typedef struct {
101 expression_t expr;
102 expression_t *call_expr;
103 expression_t *args;
104 } call_expression_t;
106 typedef enum {
107 STAT_ASSIGN,
108 STAT_CALL,
109 STAT_CONST,
110 STAT_DIM,
111 STAT_DOUNTIL,
112 STAT_DOWHILE,
113 STAT_EXITDO,
114 STAT_EXITFOR,
115 STAT_EXITFUNC,
116 STAT_EXITPROP,
117 STAT_EXITSUB,
118 STAT_FOREACH,
119 STAT_FORTO,
120 STAT_FUNC,
121 STAT_IF,
122 STAT_ONERROR,
123 STAT_REDIM,
124 STAT_SELECT,
125 STAT_SET,
126 STAT_STOP,
127 STAT_UNTIL,
128 STAT_WHILE,
129 STAT_WHILELOOP,
130 STAT_WITH,
131 STAT_RETVAL
132 } statement_type_t;
134 typedef struct _statement_t {
135 statement_type_t type;
136 unsigned loc;
137 struct _statement_t *next;
138 } statement_t;
140 typedef struct {
141 statement_t stat;
142 call_expression_t *expr;
143 } call_statement_t;
145 typedef struct {
146 statement_t stat;
147 expression_t *left_expr;
148 expression_t *value_expr;
149 } assign_statement_t;
151 typedef struct _dim_list_t {
152 unsigned val;
153 struct _dim_list_t *next;
154 } dim_list_t;
156 typedef struct _dim_decl_t {
157 const WCHAR *name;
158 BOOL is_array;
159 BOOL is_public; /* Used only for class members. */
160 dim_list_t *dims;
161 struct _dim_decl_t *next;
162 } dim_decl_t;
164 typedef struct _dim_statement_t {
165 statement_t stat;
166 dim_decl_t *dim_decls;
167 } dim_statement_t;
169 typedef struct {
170 statement_t stat;
171 const WCHAR *identifier;
172 BOOL preserve;
173 expression_t *dims;
174 } redim_statement_t;
176 typedef struct _arg_decl_t {
177 const WCHAR *name;
178 BOOL by_ref;
179 struct _arg_decl_t *next;
180 } arg_decl_t;
182 typedef struct _function_decl_t {
183 const WCHAR *name;
184 function_type_t type;
185 BOOL is_public;
186 BOOL is_default;
187 arg_decl_t *args;
188 statement_t *body;
189 struct _function_decl_t *next;
190 struct _function_decl_t *next_prop_func;
191 } function_decl_t;
193 typedef struct {
194 statement_t stat;
195 function_decl_t *func_decl;
196 } function_statement_t;
198 typedef struct _class_decl_t {
199 const WCHAR *name;
200 function_decl_t *funcs;
201 dim_decl_t *props;
202 struct _class_decl_t *next;
203 } class_decl_t;
205 typedef struct _elseif_decl_t {
206 expression_t *expr;
207 statement_t *stat;
208 unsigned loc;
209 struct _elseif_decl_t *next;
210 } elseif_decl_t;
212 typedef struct {
213 statement_t stat;
214 expression_t *expr;
215 statement_t *if_stat;
216 elseif_decl_t *elseifs;
217 statement_t *else_stat;
218 } if_statement_t;
220 typedef struct {
221 statement_t stat;
222 expression_t *expr;
223 statement_t *body;
224 } while_statement_t;
226 typedef struct {
227 statement_t stat;
228 const WCHAR *identifier;
229 expression_t *from_expr;
230 expression_t *to_expr;
231 expression_t *step_expr;
232 statement_t *body;
233 } forto_statement_t;
235 typedef struct {
236 statement_t stat;
237 const WCHAR *identifier;
238 expression_t *group_expr;
239 statement_t *body;
240 } foreach_statement_t;
242 typedef struct {
243 statement_t stat;
244 BOOL resume_next;
245 } onerror_statement_t;
247 typedef struct _const_decl_t {
248 const WCHAR *name;
249 expression_t *value_expr;
250 struct _const_decl_t *next;
251 } const_decl_t;
253 typedef struct {
254 statement_t stat;
255 const_decl_t *decls;
256 } const_statement_t;
258 typedef struct _case_clausule_t {
259 expression_t *expr;
260 statement_t *stat;
261 struct _case_clausule_t *next;
262 } case_clausule_t;
264 typedef struct {
265 statement_t stat;
266 expression_t *expr;
267 case_clausule_t *case_clausules;
268 } select_statement_t;
270 typedef struct {
271 statement_t stat;
272 expression_t *expr;
273 statement_t *body;
274 } with_statement_t;
276 typedef struct {
277 statement_t stat;
278 expression_t *expr;
279 } retval_statement_t;
281 typedef struct {
282 const WCHAR *code;
283 const WCHAR *ptr;
284 const WCHAR *end;
286 BOOL option_explicit;
287 BOOL is_html;
288 HRESULT hres;
289 int error_loc;
291 int last_token;
292 unsigned last_nl;
294 statement_t *stats;
295 statement_t *stats_tail;
296 class_decl_t *class_decls;
298 heap_pool_t heap;
299 } parser_ctx_t;
301 HRESULT parse_script(parser_ctx_t*,const WCHAR*,const WCHAR*,DWORD) DECLSPEC_HIDDEN;
302 void parser_release(parser_ctx_t*) DECLSPEC_HIDDEN;
303 int parser_lex(void*,unsigned*,parser_ctx_t*) DECLSPEC_HIDDEN;
304 void *parser_alloc(parser_ctx_t*,size_t) DECLSPEC_HIDDEN;