jscript: Use bytecode for '>>=' expression.
[wine/multimedia.git] / dlls / vbscript / parse.h
blobe58e7f3351776d12cacd098ec963e7824cfe3637
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_CONCAT,
24 EXPR_DIV,
25 EXPR_DOUBLE,
26 EXPR_EMPTY,
27 EXPR_EQUAL,
28 EXPR_EQV,
29 EXPR_EXP,
30 EXPR_GT,
31 EXPR_GTEQ,
32 EXPR_IDIV,
33 EXPR_IMP,
34 EXPR_IS,
35 EXPR_LT,
36 EXPR_LTEQ,
37 EXPR_ME,
38 EXPR_MEMBER,
39 EXPR_MOD,
40 EXPR_MUL,
41 EXPR_NEG,
42 EXPR_NEQUAL,
43 EXPR_NEW,
44 EXPR_NOT,
45 EXPR_NOTHING,
46 EXPR_NULL,
47 EXPR_OR,
48 EXPR_STRING,
49 EXPR_SUB,
50 EXPR_ULONG,
51 EXPR_USHORT,
52 EXPR_XOR
53 } expression_type_t;
55 typedef struct _expression_t {
56 expression_type_t type;
57 struct _expression_t *next;
58 } expression_t;
60 typedef struct {
61 expression_t expr;
62 VARIANT_BOOL value;
63 } bool_expression_t;
65 typedef struct {
66 expression_t expr;
67 LONG value;
68 } int_expression_t;
70 typedef struct {
71 expression_t expr;
72 double value;
73 } double_expression_t;
75 typedef struct {
76 expression_t expr;
77 const WCHAR *value;
78 } string_expression_t;
80 typedef struct {
81 expression_t expr;
82 expression_t *subexpr;
83 } unary_expression_t;
85 typedef struct {
86 expression_t expr;
87 expression_t *left;
88 expression_t *right;
89 } binary_expression_t;
91 typedef struct {
92 expression_t expr;
93 expression_t *obj_expr;
94 const WCHAR *identifier;
95 expression_t *args;
96 } member_expression_t;
98 typedef enum {
99 STAT_ASSIGN,
100 STAT_CALL,
101 STAT_CONST,
102 STAT_DIM,
103 STAT_DOUNTIL,
104 STAT_DOWHILE,
105 STAT_EXITDO,
106 STAT_EXITFOR,
107 STAT_EXITFUNC,
108 STAT_EXITPROP,
109 STAT_EXITSUB,
110 STAT_FORTO,
111 STAT_FUNC,
112 STAT_IF,
113 STAT_ONERROR,
114 STAT_SET,
115 STAT_STOP,
116 STAT_UNTIL,
117 STAT_WHILE,
118 STAT_WHILELOOP
119 } statement_type_t;
121 typedef struct _statement_t {
122 statement_type_t type;
123 struct _statement_t *next;
124 } statement_t;
126 typedef struct {
127 statement_t stat;
128 member_expression_t *expr;
129 } call_statement_t;
131 typedef struct {
132 statement_t stat;
133 member_expression_t *member_expr;
134 expression_t *value_expr;
135 } assign_statement_t;
137 typedef struct _dim_decl_t {
138 const WCHAR *name;
139 struct _dim_decl_t *next;
140 } dim_decl_t;
142 typedef struct _dim_statement_t {
143 statement_t stat;
144 dim_decl_t *dim_decls;
145 } dim_statement_t;
147 typedef struct _arg_decl_t {
148 const WCHAR *name;
149 BOOL by_ref;
150 struct _arg_decl_t *next;
151 } arg_decl_t;
153 typedef struct _function_decl_t {
154 const WCHAR *name;
155 function_type_t type;
156 BOOL is_public;
157 arg_decl_t *args;
158 statement_t *body;
159 struct _function_decl_t *next;
160 struct _function_decl_t *next_prop_func;
161 } function_decl_t;
163 typedef struct {
164 statement_t stat;
165 function_decl_t *func_decl;
166 } function_statement_t;
168 typedef struct _class_prop_decl_t {
169 BOOL is_public;
170 const WCHAR *name;
171 struct _class_prop_decl_t *next;
172 } class_prop_decl_t;
174 typedef struct _class_decl_t {
175 const WCHAR *name;
176 function_decl_t *funcs;
177 class_prop_decl_t *props;
178 struct _class_decl_t *next;
179 } class_decl_t;
181 typedef struct _elseif_decl_t {
182 expression_t *expr;
183 statement_t *stat;
184 struct _elseif_decl_t *next;
185 } elseif_decl_t;
187 typedef struct {
188 statement_t stat;
189 expression_t *expr;
190 statement_t *if_stat;
191 elseif_decl_t *elseifs;
192 statement_t *else_stat;
193 } if_statement_t;
195 typedef struct {
196 statement_t stat;
197 expression_t *expr;
198 statement_t *body;
199 } while_statement_t;
201 typedef struct {
202 statement_t stat;
203 const WCHAR *identifier;
204 expression_t *from_expr;
205 expression_t *to_expr;
206 expression_t *step_expr;
207 statement_t *body;
208 } forto_statement_t;
210 typedef struct {
211 statement_t stat;
212 BOOL resume_next;
213 } onerror_statement_t;
215 typedef struct _const_decl_t {
216 const WCHAR *name;
217 expression_t *value_expr;
218 struct _const_decl_t *next;
219 } const_decl_t;
221 typedef struct {
222 statement_t stat;
223 const_decl_t *decls;
224 } const_statement_t;
226 typedef struct {
227 const WCHAR *code;
228 const WCHAR *ptr;
229 const WCHAR *end;
231 BOOL option_explicit;
232 BOOL parse_complete;
233 HRESULT hres;
235 int last_token;
236 unsigned last_nl;
238 statement_t *stats;
239 statement_t *stats_tail;
240 class_decl_t *class_decls;
242 vbsheap_t heap;
243 } parser_ctx_t;
245 HRESULT parse_script(parser_ctx_t*,const WCHAR*) DECLSPEC_HIDDEN;
246 void parser_release(parser_ctx_t*) DECLSPEC_HIDDEN;
247 int parser_lex(void*,parser_ctx_t*) DECLSPEC_HIDDEN;
248 void *parser_alloc(parser_ctx_t*,size_t) DECLSPEC_HIDDEN;