msvcrt: Avoid locking the file in _fclose_nolock.
[wine.git] / dlls / vbscript / parse.h
blob2a497038b4bda24694ae5e0c81b77b5f02d37c44
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_SELECT,
117 STAT_SET,
118 STAT_STOP,
119 STAT_UNTIL,
120 STAT_WHILE,
121 STAT_WHILELOOP
122 } statement_type_t;
124 typedef struct _statement_t {
125 statement_type_t type;
126 struct _statement_t *next;
127 } statement_t;
129 typedef struct {
130 statement_t stat;
131 member_expression_t *expr;
132 BOOL is_strict;
133 } call_statement_t;
135 typedef struct {
136 statement_t stat;
137 member_expression_t *member_expr;
138 expression_t *value_expr;
139 } assign_statement_t;
141 typedef struct _dim_list_t {
142 unsigned val;
143 struct _dim_list_t *next;
144 } dim_list_t;
146 typedef struct _dim_decl_t {
147 const WCHAR *name;
148 BOOL is_array;
149 BOOL is_public; /* Used only for class members. */
150 dim_list_t *dims;
151 struct _dim_decl_t *next;
152 } dim_decl_t;
154 typedef struct _dim_statement_t {
155 statement_t stat;
156 dim_decl_t *dim_decls;
157 } dim_statement_t;
159 typedef struct _arg_decl_t {
160 const WCHAR *name;
161 BOOL by_ref;
162 struct _arg_decl_t *next;
163 } arg_decl_t;
165 typedef struct _function_decl_t {
166 const WCHAR *name;
167 function_type_t type;
168 BOOL is_public;
169 arg_decl_t *args;
170 statement_t *body;
171 struct _function_decl_t *next;
172 struct _function_decl_t *next_prop_func;
173 } function_decl_t;
175 typedef struct {
176 statement_t stat;
177 function_decl_t *func_decl;
178 } function_statement_t;
180 typedef struct _class_decl_t {
181 const WCHAR *name;
182 function_decl_t *funcs;
183 dim_decl_t *props;
184 struct _class_decl_t *next;
185 } class_decl_t;
187 typedef struct _elseif_decl_t {
188 expression_t *expr;
189 statement_t *stat;
190 struct _elseif_decl_t *next;
191 } elseif_decl_t;
193 typedef struct {
194 statement_t stat;
195 expression_t *expr;
196 statement_t *if_stat;
197 elseif_decl_t *elseifs;
198 statement_t *else_stat;
199 } if_statement_t;
201 typedef struct {
202 statement_t stat;
203 expression_t *expr;
204 statement_t *body;
205 } while_statement_t;
207 typedef struct {
208 statement_t stat;
209 const WCHAR *identifier;
210 expression_t *from_expr;
211 expression_t *to_expr;
212 expression_t *step_expr;
213 statement_t *body;
214 } forto_statement_t;
216 typedef struct {
217 statement_t stat;
218 const WCHAR *identifier;
219 expression_t *group_expr;
220 statement_t *body;
221 } foreach_statement_t;
223 typedef struct {
224 statement_t stat;
225 BOOL resume_next;
226 } onerror_statement_t;
228 typedef struct _const_decl_t {
229 const WCHAR *name;
230 expression_t *value_expr;
231 struct _const_decl_t *next;
232 } const_decl_t;
234 typedef struct {
235 statement_t stat;
236 const_decl_t *decls;
237 } const_statement_t;
239 typedef struct _case_clausule_t {
240 expression_t *expr;
241 statement_t *stat;
242 struct _case_clausule_t *next;
243 } case_clausule_t;
245 typedef struct {
246 statement_t stat;
247 expression_t *expr;
248 case_clausule_t *case_clausules;
249 } select_statement_t;
251 typedef struct {
252 const WCHAR *code;
253 const WCHAR *ptr;
254 const WCHAR *end;
256 BOOL option_explicit;
257 BOOL parse_complete;
258 BOOL is_html;
259 HRESULT hres;
261 int last_token;
262 unsigned last_nl;
264 statement_t *stats;
265 statement_t *stats_tail;
266 class_decl_t *class_decls;
268 heap_pool_t heap;
269 } parser_ctx_t;
271 HRESULT parse_script(parser_ctx_t*,const WCHAR*,const WCHAR*) DECLSPEC_HIDDEN;
272 void parser_release(parser_ctx_t*) DECLSPEC_HIDDEN;
273 int parser_lex(void*,parser_ctx_t*) DECLSPEC_HIDDEN;
274 void *parser_alloc(parser_ctx_t*,size_t) DECLSPEC_HIDDEN;