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
24 #include "wine/debug.h"
26 WINE_DEFAULT_DEBUG_CHANNEL(vbscript);
29 #define YYLEX_PARAM ctx
30 #define YYPARSE_PARAM ctx
32 static int parser_error(const char*);
34 static void parse_complete(parser_ctx_t*,BOOL);
36 static void source_add_statement(parser_ctx_t*,statement_t*);
37 static void source_add_class(parser_ctx_t*,class_decl_t*);
39 static void *new_expression(parser_ctx_t*,expression_type_t,size_t);
40 static expression_t *new_bool_expression(parser_ctx_t*,VARIANT_BOOL);
41 static expression_t *new_string_expression(parser_ctx_t*,const WCHAR*);
42 static expression_t *new_long_expression(parser_ctx_t*,expression_type_t,LONG);
43 static expression_t *new_double_expression(parser_ctx_t*,double);
44 static expression_t *new_unary_expression(parser_ctx_t*,expression_type_t,expression_t*);
45 static expression_t *new_binary_expression(parser_ctx_t*,expression_type_t,expression_t*,expression_t*);
46 static expression_t *new_new_expression(parser_ctx_t*,const WCHAR*);
48 static member_expression_t *new_member_expression(parser_ctx_t*,expression_t*,const WCHAR*);
50 static void *new_statement(parser_ctx_t*,statement_type_t,size_t);
51 static statement_t *new_call_statement(parser_ctx_t*,member_expression_t*);
52 static statement_t *new_assign_statement(parser_ctx_t*,member_expression_t*,expression_t*);
53 static statement_t *new_set_statement(parser_ctx_t*,member_expression_t*,expression_t*);
54 static statement_t *new_dim_statement(parser_ctx_t*,dim_decl_t*);
55 static statement_t *new_while_statement(parser_ctx_t*,statement_type_t,expression_t*,statement_t*);
56 static statement_t *new_if_statement(parser_ctx_t*,expression_t*,statement_t*,elseif_decl_t*,statement_t*);
57 static statement_t *new_function_statement(parser_ctx_t*,function_decl_t*);
59 static dim_decl_t *new_dim_decl(parser_ctx_t*,const WCHAR*,dim_decl_t*);
60 static elseif_decl_t *new_elseif_decl(parser_ctx_t*,expression_t*,statement_t*);
61 static function_decl_t *new_function_decl(parser_ctx_t*,const WCHAR*,function_type_t,unsigned,arg_decl_t*,statement_t*);
62 static arg_decl_t *new_argument_decl(parser_ctx_t*,const WCHAR*,BOOL);
64 static class_decl_t *new_class_decl(parser_ctx_t*);
65 static class_decl_t *add_class_function(parser_ctx_t*,class_decl_t*,function_decl_t*);
66 static class_decl_t *add_variant_prop(parser_ctx_t*,class_decl_t*,const WCHAR*,unsigned);
68 #define STORAGE_IS_PRIVATE 1
69 #define STORAGE_IS_DEFAULT 2
71 #define CHECK_ERROR if(((parser_ctx_t*)ctx)->hres != S_OK) YYABORT
80 statement_t *statement;
81 expression_t *expression;
82 member_expression_t *member;
83 elseif_decl_t *elseif;
85 function_decl_t *func_decl;
87 class_decl_t *class_decl;
94 %token tEOF tNL tREM tEMPTYBRACKETS
96 %token tNOT tAND tOR tXOR tEQV tIMP tNEQ
97 %token tIS tLTEQ tGTEQ tMOD
98 %token tCALL tDIM tSUB tFUNCTION tPROPERTY tGET tLET
99 %token tIF tELSE tELSEIF tEND tTHEN tEXIT
100 %token tWHILE tWEND tDO tLOOP tUNTIL
102 %token tOPTION tEXPLICIT
104 %token tNOTHING tEMPTY tNULL
105 %token tCLASS tSET tNEW tPUBLIC tPRIVATE tDEFAULT tME
106 %token tERROR tNEXT tON tRESUME tGOTO
107 %token <string> tIdentifier tString
108 %token <lng> tLong tShort
111 %type <statement> Statement StatementNl StatementsNl StatementsNl_opt IfStatement Else_opt
112 %type <expression> Expression LiteralExpression PrimaryExpression EqualityExpression CallExpression
113 %type <expression> ConcatExpression AdditiveExpression ModExpression IntdivExpression MultiplicativeExpression ExpExpression
114 %type <expression> NotExpression UnaryExpression AndExpression OrExpression XorExpression EqvExpression
115 %type <member> MemberExpression
116 %type <expression> Arguments_opt ArgumentList_opt ArgumentList
117 %type <bool> OptionExplicit_opt DoType
118 %type <arg_decl> ArgumentsDecl_opt ArgumentDeclList ArgumentDecl
119 %type <func_decl> FunctionDecl PropertyDecl
120 %type <elseif> ElseIfs_opt ElseIfs ElseIf
121 %type <class_decl> ClassDeclaration ClassBody
122 %type <uint> Storage Storage_opt
123 %type <dim_decl> DimDeclList
128 : OptionExplicit_opt SourceElements tEOF { parse_complete(ctx, $1); }
131 : /* empty */ { $$ = FALSE; }
132 | tOPTION tEXPLICIT tNL { $$ = TRUE; }
136 | SourceElements StatementNl { source_add_statement(ctx, $2); }
137 | SourceElements ClassDeclaration { source_add_class(ctx, $2); }
140 : /* empty */ { $$ = NULL; }
141 | StatementsNl { $$ = $1; }
144 : StatementNl { $$ = $1; }
145 | StatementNl StatementsNl { $1->next = $2; $$ = $1; }
148 : Statement tNL { $$ = $1; }
151 : MemberExpression ArgumentList_opt { $1->args = $2; $$ = new_call_statement(ctx, $1); CHECK_ERROR; }
152 | tCALL MemberExpression Arguments_opt { $2->args = $3; $$ = new_call_statement(ctx, $2); CHECK_ERROR; }
153 | MemberExpression Arguments_opt '=' Expression
154 { $1->args = $2; $$ = new_assign_statement(ctx, $1, $4); CHECK_ERROR; }
155 | tDIM DimDeclList { $$ = new_dim_statement(ctx, $2); CHECK_ERROR; }
156 | IfStatement { $$ = $1; }
157 | tWHILE Expression tNL StatementsNl_opt tWEND
158 { $$ = new_while_statement(ctx, STAT_WHILE, $2, $4); CHECK_ERROR; }
159 | tDO DoType Expression tNL StatementsNl_opt tLOOP
160 { $$ = new_while_statement(ctx, $2 ? STAT_WHILELOOP : STAT_UNTIL, $3, $5);
162 | tDO tNL StatementsNl_opt tLOOP DoType Expression
163 { $$ = new_while_statement(ctx, $5 ? STAT_DOWHILE : STAT_DOUNTIL, $6, $3);
165 | FunctionDecl { $$ = new_function_statement(ctx, $1); CHECK_ERROR; }
166 | tEXIT tDO { $$ = new_statement(ctx, STAT_EXITDO, 0); CHECK_ERROR; }
167 | tEXIT tFUNCTION { $$ = new_statement(ctx, STAT_EXITFUNC, 0); CHECK_ERROR; }
168 | tEXIT tPROPERTY { $$ = new_statement(ctx, STAT_EXITPROP, 0); CHECK_ERROR; }
169 | tEXIT tSUB { $$ = new_statement(ctx, STAT_EXITSUB, 0); CHECK_ERROR; }
170 | tSET MemberExpression Arguments_opt '=' Expression
171 { $2->args = $3; $$ = new_set_statement(ctx, $2, $5); CHECK_ERROR; }
172 | tSTOP { $$ = new_statement(ctx, STAT_STOP, 0); CHECK_ERROR; }
175 : tIdentifier { $$ = new_member_expression(ctx, NULL, $1); CHECK_ERROR; }
176 | CallExpression '.' tIdentifier { $$ = new_member_expression(ctx, $1, $3); CHECK_ERROR; }
178 DimDeclList /* FIXME: Support arrays */
179 : tIdentifier { $$ = new_dim_decl(ctx, $1, NULL); CHECK_ERROR; }
180 | tIdentifier ',' DimDeclList { $$ = new_dim_decl(ctx, $1, $3); CHECK_ERROR; }
183 : tWHILE { $$ = TRUE; }
184 | tUNTIL { $$ = FALSE; }
187 : tIF Expression tTHEN tNL StatementsNl ElseIfs_opt Else_opt tEND tIF
188 { $$ = new_if_statement(ctx, $2, $5, $6, $7); CHECK_ERROR; }
189 /* FIXME: short if statement */
192 : /* empty */ { $$ = NULL; }
193 | ElseIfs { $$ = $1; }
196 : ElseIf { $$ = $1; }
197 | ElseIf ElseIfs { $1->next = $2; $$ = $1; }
200 : tELSEIF Expression tTHEN tNL StatementsNl
201 { $$ = new_elseif_decl(ctx, $2, $5); }
204 : /* empty */ { $$ = NULL; }
205 | tELSE tNL StatementsNl { $$ = $3; }
208 : EmptyBrackets_opt { $$ = NULL; }
209 | '(' ArgumentList ')' { $$ = $2; }
212 : EmptyBrackets_opt { $$ = NULL; }
213 | ArgumentList { $$ = $1; }
216 : Expression { $$ = $1; }
217 | Expression ',' ArgumentList { $1->next = $3; $$ = $1; }
224 : EqvExpression { $$ = $1; }
225 | Expression tIMP EqvExpression { $$ = new_binary_expression(ctx, EXPR_IMP, $1, $3); CHECK_ERROR; }
228 : XorExpression { $$ = $1; }
229 | EqvExpression tEQV XorExpression { $$ = new_binary_expression(ctx, EXPR_EQV, $1, $3); CHECK_ERROR; }
232 : OrExpression { $$ = $1; }
233 | XorExpression tXOR OrExpression { $$ = new_binary_expression(ctx, EXPR_XOR, $1, $3); CHECK_ERROR; }
236 : AndExpression { $$ = $1; }
237 | OrExpression tOR AndExpression { $$ = new_binary_expression(ctx, EXPR_OR, $1, $3); CHECK_ERROR; }
240 : NotExpression { $$ = $1; }
241 | AndExpression tAND NotExpression { $$ = new_binary_expression(ctx, EXPR_AND, $1, $3); CHECK_ERROR; }
244 : EqualityExpression { $$ = $1; }
245 | tNOT NotExpression { $$ = new_unary_expression(ctx, EXPR_NOT, $2); CHECK_ERROR; }
248 : ConcatExpression { $$ = $1; }
249 | EqualityExpression '=' ConcatExpression { $$ = new_binary_expression(ctx, EXPR_EQUAL, $1, $3); CHECK_ERROR; }
250 | EqualityExpression tNEQ ConcatExpression { $$ = new_binary_expression(ctx, EXPR_NEQUAL, $1, $3); CHECK_ERROR; }
251 | EqualityExpression '>' ConcatExpression { $$ = new_binary_expression(ctx, EXPR_GT, $1, $3); CHECK_ERROR; }
252 | EqualityExpression '<' ConcatExpression { $$ = new_binary_expression(ctx, EXPR_LT, $1, $3); CHECK_ERROR; }
253 | EqualityExpression tGTEQ ConcatExpression { $$ = new_binary_expression(ctx, EXPR_GTEQ, $1, $3); CHECK_ERROR; }
254 | EqualityExpression tLTEQ ConcatExpression { $$ = new_binary_expression(ctx, EXPR_LTEQ, $1, $3); CHECK_ERROR; }
255 | EqualityExpression tIS ConcatExpression { $$ = new_binary_expression(ctx, EXPR_IS, $1, $3); CHECK_ERROR; }
258 : AdditiveExpression { $$ = $1; }
259 | ConcatExpression '&' AdditiveExpression { $$ = new_binary_expression(ctx, EXPR_CONCAT, $1, $3); CHECK_ERROR; }
262 : ModExpression { $$ = $1; }
263 | AdditiveExpression '+' ModExpression { $$ = new_binary_expression(ctx, EXPR_ADD, $1, $3); CHECK_ERROR; }
264 | AdditiveExpression '-' ModExpression { $$ = new_binary_expression(ctx, EXPR_SUB, $1, $3); CHECK_ERROR; }
267 : IntdivExpression { $$ = $1; }
268 | ModExpression tMOD IntdivExpression { $$ = new_binary_expression(ctx, EXPR_MOD, $1, $3); CHECK_ERROR; }
271 : MultiplicativeExpression { $$ = $1; }
272 | IntdivExpression '\\' MultiplicativeExpression
273 { $$ = new_binary_expression(ctx, EXPR_IDIV, $1, $3); CHECK_ERROR; }
275 MultiplicativeExpression
276 : ExpExpression { $$ = $1; }
277 | MultiplicativeExpression '*' ExpExpression
278 { $$ = new_binary_expression(ctx, EXPR_MUL, $1, $3); CHECK_ERROR; }
279 | MultiplicativeExpression '/' ExpExpression
280 { $$ = new_binary_expression(ctx, EXPR_DIV, $1, $3); CHECK_ERROR; }
283 : UnaryExpression { $$ = $1; }
284 | ExpExpression '^' UnaryExpression { $$ = new_binary_expression(ctx, EXPR_EXP, $1, $3); CHECK_ERROR; }
287 : LiteralExpression { $$ = $1; }
288 | CallExpression { $$ = $1; }
289 | tNEW tIdentifier { $$ = new_new_expression(ctx, $2); CHECK_ERROR; }
290 | '-' UnaryExpression { $$ = new_unary_expression(ctx, EXPR_NEG, $2); CHECK_ERROR; }
293 : PrimaryExpression { $$ = $1; }
294 | MemberExpression Arguments_opt { $1->args = $2; $$ = &$1->expr; }
297 : tTRUE { $$ = new_bool_expression(ctx, VARIANT_TRUE); CHECK_ERROR; }
298 | tFALSE { $$ = new_bool_expression(ctx, VARIANT_FALSE); CHECK_ERROR; }
299 | tString { $$ = new_string_expression(ctx, $1); CHECK_ERROR; }
300 | tShort { $$ = new_long_expression(ctx, EXPR_USHORT, $1); CHECK_ERROR; }
301 | '0' { $$ = new_long_expression(ctx, EXPR_USHORT, 0); CHECK_ERROR; }
302 | tLong { $$ = new_long_expression(ctx, EXPR_ULONG, $1); CHECK_ERROR; }
303 | tDouble { $$ = new_double_expression(ctx, $1); CHECK_ERROR; }
304 | tEMPTY { $$ = new_expression(ctx, EXPR_EMPTY, 0); CHECK_ERROR; }
305 | tNULL { $$ = new_expression(ctx, EXPR_NULL, 0); CHECK_ERROR; }
306 | tNOTHING { $$ = new_expression(ctx, EXPR_NOTHING, 0); CHECK_ERROR; }
309 : '(' Expression ')' { $$ = $2; }
310 | tME { $$ = new_expression(ctx, EXPR_ME, 0); CHECK_ERROR; }
313 : tCLASS tIdentifier tNL ClassBody tEND tCLASS tNL { $4->name = $2; $$ = $4; }
316 : /* empty */ { $$ = new_class_decl(ctx); }
317 | FunctionDecl tNL ClassBody { $$ = add_class_function(ctx, $3, $1); CHECK_ERROR; }
318 | Storage tIdentifier tNL ClassBody { $$ = add_variant_prop(ctx, $4, $2, $1); CHECK_ERROR; }
319 | PropertyDecl tNL ClassBody { $$ = add_class_function(ctx, $3, $1); CHECK_ERROR; }
322 : Storage_opt tPROPERTY tGET tIdentifier EmptyBrackets_opt tNL StatementsNl_opt tEND tPROPERTY
323 { $$ = new_function_decl(ctx, $4, FUNC_PROPGET, $1, NULL, $7); CHECK_ERROR; }
324 | Storage_opt tPROPERTY tLET tIdentifier '(' ArgumentDecl ')' tNL StatementsNl_opt tEND tPROPERTY
325 { $$ = new_function_decl(ctx, $4, FUNC_PROPLET, $1, $6, $9); CHECK_ERROR; }
326 | Storage_opt tPROPERTY tSET tIdentifier '(' ArgumentDecl ')' tNL StatementsNl_opt tEND tPROPERTY
327 { $$ = new_function_decl(ctx, $4, FUNC_PROPSET, $1, $6, $9); CHECK_ERROR; }
330 : Storage_opt tSUB tIdentifier ArgumentsDecl_opt tNL StatementsNl_opt tEND tSUB
331 { $$ = new_function_decl(ctx, $3, FUNC_SUB, $1, $4, $6); CHECK_ERROR; }
332 | Storage_opt tFUNCTION tIdentifier ArgumentsDecl_opt tNL StatementsNl_opt tEND tFUNCTION
333 { $$ = new_function_decl(ctx, $3, FUNC_FUNCTION, $1, $4, $6); CHECK_ERROR; }
336 : /* empty*/ { $$ = 0; }
337 | Storage { $$ = $1; }
340 : tPUBLIC tDEFAULT { $$ = STORAGE_IS_DEFAULT; }
341 | tPUBLIC { $$ = 0; }
342 | tPRIVATE { $$ = STORAGE_IS_PRIVATE; }
345 : EmptyBrackets_opt { $$ = NULL; }
346 | '(' ArgumentDeclList ')' { $$ = $2; }
349 : ArgumentDecl { $$ = $1; }
350 | ArgumentDecl ',' ArgumentDeclList { $1->next = $3; $$ = $1; }
353 : tIdentifier { $$ = new_argument_decl(ctx, $1, TRUE); }
354 | tBYREF tIdentifier { $$ = new_argument_decl(ctx, $2, TRUE); }
355 | tBYVAL tIdentifier { $$ = new_argument_decl(ctx, $2, FALSE); }
359 static int parser_error(const char *str)
364 static void source_add_statement(parser_ctx_t *ctx, statement_t *stat)
367 ctx->stats_tail->next = stat;
368 ctx->stats_tail = stat;
370 ctx->stats = ctx->stats_tail = stat;
374 static void source_add_class(parser_ctx_t *ctx, class_decl_t *class_decl)
376 class_decl->next = ctx->class_decls;
377 ctx->class_decls = class_decl;
380 static void parse_complete(parser_ctx_t *ctx, BOOL option_explicit)
382 ctx->parse_complete = TRUE;
383 ctx->option_explicit = option_explicit;
386 static void *new_expression(parser_ctx_t *ctx, expression_type_t type, size_t size)
390 expr = parser_alloc(ctx, size ? size : sizeof(*expr));
399 static expression_t *new_bool_expression(parser_ctx_t *ctx, VARIANT_BOOL value)
401 bool_expression_t *expr;
403 expr = new_expression(ctx, EXPR_BOOL, sizeof(*expr));
411 static expression_t *new_string_expression(parser_ctx_t *ctx, const WCHAR *value)
413 string_expression_t *expr;
415 expr = new_expression(ctx, EXPR_STRING, sizeof(*expr));
423 static expression_t *new_long_expression(parser_ctx_t *ctx, expression_type_t type, LONG value)
425 int_expression_t *expr;
427 expr = new_expression(ctx, type, sizeof(*expr));
435 static expression_t *new_double_expression(parser_ctx_t *ctx, double value)
437 double_expression_t *expr;
439 expr = new_expression(ctx, EXPR_DOUBLE, sizeof(*expr));
447 static expression_t *new_unary_expression(parser_ctx_t *ctx, expression_type_t type, expression_t *subexpr)
449 unary_expression_t *expr;
451 expr = new_expression(ctx, type, sizeof(*expr));
455 expr->subexpr = subexpr;
459 static expression_t *new_binary_expression(parser_ctx_t *ctx, expression_type_t type, expression_t *left, expression_t *right)
461 binary_expression_t *expr;
463 expr = new_expression(ctx, type, sizeof(*expr));
472 static member_expression_t *new_member_expression(parser_ctx_t *ctx, expression_t *obj_expr, const WCHAR *identifier)
474 member_expression_t *expr;
476 expr = new_expression(ctx, EXPR_MEMBER, sizeof(*expr));
480 expr->obj_expr = obj_expr;
481 expr->identifier = identifier;
486 static expression_t *new_new_expression(parser_ctx_t *ctx, const WCHAR *identifier)
488 string_expression_t *expr;
490 expr = new_expression(ctx, EXPR_NEW, sizeof(*expr));
494 expr->value = identifier;
498 static void *new_statement(parser_ctx_t *ctx, statement_type_t type, size_t size)
502 stat = parser_alloc(ctx, size ? size : sizeof(*stat));
511 static statement_t *new_call_statement(parser_ctx_t *ctx, member_expression_t *expr)
513 call_statement_t *stat;
515 stat = new_statement(ctx, STAT_CALL, sizeof(*stat));
523 static statement_t *new_assign_statement(parser_ctx_t *ctx, member_expression_t *left, expression_t *right)
525 assign_statement_t *stat;
527 stat = new_statement(ctx, STAT_ASSIGN, sizeof(*stat));
531 stat->member_expr = left;
532 stat->value_expr = right;
536 static statement_t *new_set_statement(parser_ctx_t *ctx, member_expression_t *left, expression_t *right)
538 assign_statement_t *stat;
540 stat = new_statement(ctx, STAT_SET, sizeof(*stat));
544 stat->member_expr = left;
545 stat->value_expr = right;
549 static dim_decl_t *new_dim_decl(parser_ctx_t *ctx, const WCHAR *name, dim_decl_t *next)
553 decl = parser_alloc(ctx, sizeof(*decl));
562 static statement_t *new_dim_statement(parser_ctx_t *ctx, dim_decl_t *decls)
564 dim_statement_t *stat;
566 stat = new_statement(ctx, STAT_DIM, sizeof(*stat));
570 stat->dim_decls = decls;
574 static elseif_decl_t *new_elseif_decl(parser_ctx_t *ctx, expression_t *expr, statement_t *stat)
578 decl = parser_alloc(ctx, sizeof(*decl));
588 static statement_t *new_while_statement(parser_ctx_t *ctx, statement_type_t type, expression_t *expr, statement_t *body)
590 while_statement_t *stat;
592 stat = new_statement(ctx, type, sizeof(*stat));
601 static statement_t *new_if_statement(parser_ctx_t *ctx, expression_t *expr, statement_t *if_stat, elseif_decl_t *elseif_decl,
602 statement_t *else_stat)
604 if_statement_t *stat;
606 stat = new_statement(ctx, STAT_IF, sizeof(*stat));
611 stat->if_stat = if_stat;
612 stat->elseifs = elseif_decl;
613 stat->else_stat = else_stat;
617 static arg_decl_t *new_argument_decl(parser_ctx_t *ctx, const WCHAR *name, BOOL by_ref)
619 arg_decl_t *arg_decl;
621 arg_decl = parser_alloc(ctx, sizeof(*arg_decl));
625 arg_decl->name = name;
626 arg_decl->by_ref = by_ref;
627 arg_decl->next = NULL;
631 static function_decl_t *new_function_decl(parser_ctx_t *ctx, const WCHAR *name, function_type_t type,
632 unsigned storage_flags, arg_decl_t *arg_decl, statement_t *body)
634 function_decl_t *decl;
636 if(storage_flags & STORAGE_IS_DEFAULT) {
637 if(type == FUNC_PROPGET) {
640 FIXME("Invalid default property\n");
646 decl = parser_alloc(ctx, sizeof(*decl));
652 decl->is_public = !(storage_flags & STORAGE_IS_PRIVATE);
653 decl->args = arg_decl;
656 decl->next_prop_func = NULL;
660 static statement_t *new_function_statement(parser_ctx_t *ctx, function_decl_t *decl)
662 function_statement_t *stat;
664 stat = new_statement(ctx, STAT_FUNC, sizeof(*stat));
668 stat->func_decl = decl;
672 static class_decl_t *new_class_decl(parser_ctx_t *ctx)
674 class_decl_t *class_decl;
676 class_decl = parser_alloc(ctx, sizeof(*class_decl));
680 class_decl->funcs = NULL;
681 class_decl->props = NULL;
682 class_decl->next = NULL;
686 static class_decl_t *add_class_function(parser_ctx_t *ctx, class_decl_t *class_decl, function_decl_t *decl)
688 function_decl_t *iter;
690 for(iter = class_decl->funcs; iter; iter = iter->next) {
691 if(!strcmpiW(iter->name, decl->name)) {
692 if(decl->type == FUNC_SUB || decl->type == FUNC_FUNCTION) {
693 FIXME("Redefinition of %s::%s\n", debugstr_w(class_decl->name), debugstr_w(decl->name));
699 if(iter->type == decl->type) {
700 FIXME("Redefinition of %s::%s\n", debugstr_w(class_decl->name), debugstr_w(decl->name));
704 if(!iter->next_prop_func)
706 iter = iter->next_prop_func;
709 iter->next_prop_func = decl;
714 decl->next = class_decl->funcs;
715 class_decl->funcs = decl;
719 static class_decl_t *add_variant_prop(parser_ctx_t *ctx, class_decl_t *class_decl, const WCHAR *identifier, unsigned storage_flags)
721 class_prop_decl_t *prop;
723 if(storage_flags & STORAGE_IS_DEFAULT) {
724 FIXME("variant prop van't be default value\n");
729 prop = parser_alloc(ctx, sizeof(*prop));
733 prop->name = identifier;
734 prop->is_public = !(storage_flags & STORAGE_IS_PRIVATE);
735 prop->next = class_decl->props;
736 class_decl->props = prop;
740 void *parser_alloc(parser_ctx_t *ctx, size_t size)
744 ret = vbsheap_alloc(&ctx->heap, size);
746 ctx->hres = E_OUTOFMEMORY;
750 HRESULT parse_script(parser_ctx_t *ctx, const WCHAR *code)
752 ctx->code = ctx->ptr = code;
753 ctx->end = ctx->code + strlenW(ctx->code);
755 vbsheap_init(&ctx->heap);
757 ctx->parse_complete = FALSE;
760 ctx->last_token = tNL;
762 ctx->stats = ctx->stats_tail = NULL;
763 ctx->class_decls = NULL;
764 ctx->option_explicit = FALSE;
768 if(FAILED(ctx->hres))
770 if(!ctx->parse_complete) {
771 FIXME("parser failed on parsing %s\n", debugstr_w(ctx->ptr));
778 void parser_release(parser_ctx_t *ctx)
780 vbsheap_free(&ctx->heap);