msvcp90: Return last index in string::find_last_not_of_cstr_substr if input is empty.
[wine.git] / dlls / vbscript / parse.h
blob4b9781436b339d3cce14d51bc1b456dc1977512a
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 dim_list_t *dims;
150 struct _dim_decl_t *next;
151 } dim_decl_t;
153 typedef struct _dim_statement_t {
154 statement_t stat;
155 dim_decl_t *dim_decls;
156 } dim_statement_t;
158 typedef struct _arg_decl_t {
159 const WCHAR *name;
160 BOOL by_ref;
161 struct _arg_decl_t *next;
162 } arg_decl_t;
164 typedef struct _function_decl_t {
165 const WCHAR *name;
166 function_type_t type;
167 BOOL is_public;
168 arg_decl_t *args;
169 statement_t *body;
170 struct _function_decl_t *next;
171 struct _function_decl_t *next_prop_func;
172 } function_decl_t;
174 typedef struct {
175 statement_t stat;
176 function_decl_t *func_decl;
177 } function_statement_t;
179 typedef struct _class_prop_decl_t {
180 BOOL is_public;
181 const WCHAR *name;
182 struct _class_prop_decl_t *next;
183 } class_prop_decl_t;
185 typedef struct _class_decl_t {
186 const WCHAR *name;
187 function_decl_t *funcs;
188 class_prop_decl_t *props;
189 struct _class_decl_t *next;
190 } class_decl_t;
192 typedef struct _elseif_decl_t {
193 expression_t *expr;
194 statement_t *stat;
195 struct _elseif_decl_t *next;
196 } elseif_decl_t;
198 typedef struct {
199 statement_t stat;
200 expression_t *expr;
201 statement_t *if_stat;
202 elseif_decl_t *elseifs;
203 statement_t *else_stat;
204 } if_statement_t;
206 typedef struct {
207 statement_t stat;
208 expression_t *expr;
209 statement_t *body;
210 } while_statement_t;
212 typedef struct {
213 statement_t stat;
214 const WCHAR *identifier;
215 expression_t *from_expr;
216 expression_t *to_expr;
217 expression_t *step_expr;
218 statement_t *body;
219 } forto_statement_t;
221 typedef struct {
222 statement_t stat;
223 const WCHAR *identifier;
224 expression_t *group_expr;
225 statement_t *body;
226 } foreach_statement_t;
228 typedef struct {
229 statement_t stat;
230 BOOL resume_next;
231 } onerror_statement_t;
233 typedef struct _const_decl_t {
234 const WCHAR *name;
235 expression_t *value_expr;
236 struct _const_decl_t *next;
237 } const_decl_t;
239 typedef struct {
240 statement_t stat;
241 const_decl_t *decls;
242 } const_statement_t;
244 typedef struct _case_clausule_t {
245 expression_t *expr;
246 statement_t *stat;
247 struct _case_clausule_t *next;
248 } case_clausule_t;
250 typedef struct {
251 statement_t stat;
252 expression_t *expr;
253 case_clausule_t *case_clausules;
254 } select_statement_t;
256 typedef struct {
257 const WCHAR *code;
258 const WCHAR *ptr;
259 const WCHAR *end;
261 BOOL option_explicit;
262 BOOL parse_complete;
263 BOOL is_html;
264 HRESULT hres;
266 int last_token;
267 unsigned last_nl;
269 statement_t *stats;
270 statement_t *stats_tail;
271 class_decl_t *class_decls;
273 heap_pool_t heap;
274 } parser_ctx_t;
276 HRESULT parse_script(parser_ctx_t*,const WCHAR*,const WCHAR*) DECLSPEC_HIDDEN;
277 void parser_release(parser_ctx_t*) DECLSPEC_HIDDEN;
278 int parser_lex(void*,parser_ctx_t*) DECLSPEC_HIDDEN;
279 void *parser_alloc(parser_ctx_t*,size_t) DECLSPEC_HIDDEN;