[VBSCRIPT] Sync with Wine Staging 1.7.37. CORE-9246
[reactos.git] / reactos / dll / win32 / 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_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_NOARG, /* not a real expression */
46 EXPR_NOT,
47 EXPR_NOTHING,
48 EXPR_NULL,
49 EXPR_OR,
50 EXPR_STRING,
51 EXPR_SUB,
52 EXPR_ULONG,
53 EXPR_USHORT,
54 EXPR_XOR
55 } expression_type_t;
56
57 typedef struct _expression_t {
58 expression_type_t type;
59 struct _expression_t *next;
60 } expression_t;
61
62 typedef struct {
63 expression_t expr;
64 VARIANT_BOOL value;
65 } bool_expression_t;
66
67 typedef struct {
68 expression_t expr;
69 LONG value;
70 } int_expression_t;
71
72 typedef struct {
73 expression_t expr;
74 double value;
75 } double_expression_t;
76
77 typedef struct {
78 expression_t expr;
79 const WCHAR *value;
80 } string_expression_t;
81
82 typedef struct {
83 expression_t expr;
84 expression_t *subexpr;
85 } unary_expression_t;
86
87 typedef struct {
88 expression_t expr;
89 expression_t *left;
90 expression_t *right;
91 } binary_expression_t;
92
93 typedef struct {
94 expression_t expr;
95 expression_t *obj_expr;
96 const WCHAR *identifier;
97 expression_t *args;
98 } member_expression_t;
99
100 typedef enum {
101 STAT_ASSIGN,
102 STAT_CALL,
103 STAT_CONST,
104 STAT_DIM,
105 STAT_DOUNTIL,
106 STAT_DOWHILE,
107 STAT_EXITDO,
108 STAT_EXITFOR,
109 STAT_EXITFUNC,
110 STAT_EXITPROP,
111 STAT_EXITSUB,
112 STAT_FOREACH,
113 STAT_FORTO,
114 STAT_FUNC,
115 STAT_IF,
116 STAT_ONERROR,
117 STAT_SELECT,
118 STAT_SET,
119 STAT_STOP,
120 STAT_UNTIL,
121 STAT_WHILE,
122 STAT_WHILELOOP
123 } statement_type_t;
124
125 typedef struct _statement_t {
126 statement_type_t type;
127 struct _statement_t *next;
128 } statement_t;
129
130 typedef struct {
131 statement_t stat;
132 member_expression_t *expr;
133 BOOL is_strict;
134 } call_statement_t;
135
136 typedef struct {
137 statement_t stat;
138 member_expression_t *member_expr;
139 expression_t *value_expr;
140 } assign_statement_t;
141
142 typedef struct _dim_list_t {
143 unsigned val;
144 struct _dim_list_t *next;
145 } dim_list_t;
146
147 typedef struct _dim_decl_t {
148 const WCHAR *name;
149 BOOL is_array;
150 BOOL is_public; /* Used only for class members. */
151 dim_list_t *dims;
152 struct _dim_decl_t *next;
153 } dim_decl_t;
154
155 typedef struct _dim_statement_t {
156 statement_t stat;
157 dim_decl_t *dim_decls;
158 } dim_statement_t;
159
160 typedef struct _arg_decl_t {
161 const WCHAR *name;
162 BOOL by_ref;
163 struct _arg_decl_t *next;
164 } arg_decl_t;
165
166 typedef struct _function_decl_t {
167 const WCHAR *name;
168 function_type_t type;
169 BOOL is_public;
170 arg_decl_t *args;
171 statement_t *body;
172 struct _function_decl_t *next;
173 struct _function_decl_t *next_prop_func;
174 } function_decl_t;
175
176 typedef struct {
177 statement_t stat;
178 function_decl_t *func_decl;
179 } function_statement_t;
180
181 typedef struct _class_decl_t {
182 const WCHAR *name;
183 function_decl_t *funcs;
184 dim_decl_t *props;
185 struct _class_decl_t *next;
186 } class_decl_t;
187
188 typedef struct _elseif_decl_t {
189 expression_t *expr;
190 statement_t *stat;
191 struct _elseif_decl_t *next;
192 } elseif_decl_t;
193
194 typedef struct {
195 statement_t stat;
196 expression_t *expr;
197 statement_t *if_stat;
198 elseif_decl_t *elseifs;
199 statement_t *else_stat;
200 } if_statement_t;
201
202 typedef struct {
203 statement_t stat;
204 expression_t *expr;
205 statement_t *body;
206 } while_statement_t;
207
208 typedef struct {
209 statement_t stat;
210 const WCHAR *identifier;
211 expression_t *from_expr;
212 expression_t *to_expr;
213 expression_t *step_expr;
214 statement_t *body;
215 } forto_statement_t;
216
217 typedef struct {
218 statement_t stat;
219 const WCHAR *identifier;
220 expression_t *group_expr;
221 statement_t *body;
222 } foreach_statement_t;
223
224 typedef struct {
225 statement_t stat;
226 BOOL resume_next;
227 } onerror_statement_t;
228
229 typedef struct _const_decl_t {
230 const WCHAR *name;
231 expression_t *value_expr;
232 struct _const_decl_t *next;
233 } const_decl_t;
234
235 typedef struct {
236 statement_t stat;
237 const_decl_t *decls;
238 } const_statement_t;
239
240 typedef struct _case_clausule_t {
241 expression_t *expr;
242 statement_t *stat;
243 struct _case_clausule_t *next;
244 } case_clausule_t;
245
246 typedef struct {
247 statement_t stat;
248 expression_t *expr;
249 case_clausule_t *case_clausules;
250 } select_statement_t;
251
252 typedef struct {
253 const WCHAR *code;
254 const WCHAR *ptr;
255 const WCHAR *end;
256
257 BOOL option_explicit;
258 BOOL parse_complete;
259 BOOL is_html;
260 HRESULT hres;
261
262 int last_token;
263 unsigned last_nl;
264
265 statement_t *stats;
266 statement_t *stats_tail;
267 class_decl_t *class_decls;
268
269 heap_pool_t heap;
270 } parser_ctx_t;
271
272 HRESULT parse_script(parser_ctx_t*,const WCHAR*,const WCHAR*) DECLSPEC_HIDDEN;
273 void parser_release(parser_ctx_t*) DECLSPEC_HIDDEN;
274 int parser_lex(void*,parser_ctx_t*) DECLSPEC_HIDDEN;
275 void *parser_alloc(parser_ctx_t*,size_t) DECLSPEC_HIDDEN;