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; }
253 : AdditiveExpression { $$ = $1; }
254 | ConcatExpression '&' AdditiveExpression { $$ = new_binary_expression(ctx, EXPR_CONCAT, $1, $3); CHECK_ERROR; }
257 : ModExpression { $$ = $1; }
258 | AdditiveExpression '+' ModExpression { $$ = new_binary_expression(ctx, EXPR_ADD, $1, $3); CHECK_ERROR; }
259 | AdditiveExpression '-' ModExpression { $$ = new_binary_expression(ctx, EXPR_SUB, $1, $3); CHECK_ERROR; }
262 : IntdivExpression { $$ = $1; }
263 | ModExpression tMOD IntdivExpression { $$ = new_binary_expression(ctx, EXPR_MOD, $1, $3); CHECK_ERROR; }
266 : MultiplicativeExpression { $$ = $1; }
267 | IntdivExpression '\\' MultiplicativeExpression
268 { $$ = new_binary_expression(ctx, EXPR_IDIV, $1, $3); CHECK_ERROR; }
270 MultiplicativeExpression
271 : ExpExpression { $$ = $1; }
272 | MultiplicativeExpression '*' ExpExpression
273 { $$ = new_binary_expression(ctx, EXPR_MUL, $1, $3); CHECK_ERROR; }
274 | MultiplicativeExpression '/' ExpExpression
275 { $$ = new_binary_expression(ctx, EXPR_DIV, $1, $3); CHECK_ERROR; }
278 : UnaryExpression { $$ = $1; }
279 | ExpExpression '^' UnaryExpression { $$ = new_binary_expression(ctx, EXPR_EXP, $1, $3); CHECK_ERROR; }
282 : LiteralExpression { $$ = $1; }
283 | CallExpression { $$ = $1; }
284 | tNEW tIdentifier { $$ = new_new_expression(ctx, $2); CHECK_ERROR; }
285 | '-' UnaryExpression { $$ = new_unary_expression(ctx, EXPR_NEG, $2); CHECK_ERROR; }
288 : PrimaryExpression { $$ = $1; }
289 | MemberExpression Arguments_opt { $1->args = $2; $$ = &$1->expr; }
292 : tTRUE { $$ = new_bool_expression(ctx, VARIANT_TRUE); CHECK_ERROR; }
293 | tFALSE { $$ = new_bool_expression(ctx, VARIANT_FALSE); CHECK_ERROR; }
294 | tString { $$ = new_string_expression(ctx, $1); CHECK_ERROR; }
295 | tShort { $$ = new_long_expression(ctx, EXPR_USHORT, $1); CHECK_ERROR; }
296 | '0' { $$ = new_long_expression(ctx, EXPR_USHORT, 0); CHECK_ERROR; }
297 | tLong { $$ = new_long_expression(ctx, EXPR_ULONG, $1); CHECK_ERROR; }
298 | tDouble { $$ = new_double_expression(ctx, $1); CHECK_ERROR; }
299 | tEMPTY { $$ = new_expression(ctx, EXPR_EMPTY, 0); CHECK_ERROR; }
300 | tNULL { $$ = new_expression(ctx, EXPR_NULL, 0); CHECK_ERROR; }
301 | tNOTHING { $$ = new_expression(ctx, EXPR_NOTHING, 0); CHECK_ERROR; }
304 : '(' Expression ')' { $$ = $2; }
307 : tCLASS tIdentifier tNL ClassBody tEND tCLASS tNL { $4->name = $2; $$ = $4; }
310 : /* empty */ { $$ = new_class_decl(ctx); }
311 | FunctionDecl tNL ClassBody { $$ = add_class_function(ctx, $3, $1); CHECK_ERROR; }
312 | Storage tIdentifier tNL ClassBody { $$ = add_variant_prop(ctx, $4, $2, $1); CHECK_ERROR; }
313 | PropertyDecl tNL ClassBody { $$ = add_class_function(ctx, $3, $1); CHECK_ERROR; }
316 : Storage_opt tPROPERTY tGET tIdentifier EmptyBrackets_opt tNL StatementsNl_opt tEND tPROPERTY
317 { $$ = new_function_decl(ctx, $4, FUNC_PROPGET, $1, NULL, $7); CHECK_ERROR; }
318 | Storage_opt tPROPERTY tLET tIdentifier '(' ArgumentDecl ')' tNL StatementsNl_opt tEND tPROPERTY
319 { $$ = new_function_decl(ctx, $4, FUNC_PROPLET, $1, $6, $9); CHECK_ERROR; }
320 | Storage_opt tPROPERTY tSET tIdentifier '(' ArgumentDecl ')' tNL StatementsNl_opt tEND tPROPERTY
321 { $$ = new_function_decl(ctx, $4, FUNC_PROPSET, $1, $6, $9); CHECK_ERROR; }
324 : Storage_opt tSUB tIdentifier ArgumentsDecl_opt tNL StatementsNl_opt tEND tSUB
325 { $$ = new_function_decl(ctx, $3, FUNC_SUB, $1, $4, $6); CHECK_ERROR; }
326 | Storage_opt tFUNCTION tIdentifier ArgumentsDecl_opt tNL StatementsNl_opt tEND tFUNCTION
327 { $$ = new_function_decl(ctx, $3, FUNC_FUNCTION, $1, $4, $6); CHECK_ERROR; }
330 : /* empty*/ { $$ = 0; }
331 | Storage { $$ = $1; }
334 : tPUBLIC tDEFAULT { $$ = STORAGE_IS_DEFAULT; }
335 | tPUBLIC { $$ = 0; }
336 | tPRIVATE { $$ = STORAGE_IS_PRIVATE; }
339 : EmptyBrackets_opt { $$ = NULL; }
340 | '(' ArgumentDeclList ')' { $$ = $2; }
343 : ArgumentDecl { $$ = $1; }
344 | ArgumentDecl ',' ArgumentDeclList { $1->next = $3; $$ = $1; }
347 : tIdentifier { $$ = new_argument_decl(ctx, $1, TRUE); }
348 | tBYREF tIdentifier { $$ = new_argument_decl(ctx, $2, TRUE); }
349 | tBYVAL tIdentifier { $$ = new_argument_decl(ctx, $2, FALSE); }
353 static int parser_error(const char *str)
358 static void source_add_statement(parser_ctx_t *ctx, statement_t *stat)
361 ctx->stats_tail->next = stat;
362 ctx->stats_tail = stat;
364 ctx->stats = ctx->stats_tail = stat;
368 static void source_add_class(parser_ctx_t *ctx, class_decl_t *class_decl)
370 class_decl->next = ctx->class_decls;
371 ctx->class_decls = class_decl;
374 static void parse_complete(parser_ctx_t *ctx, BOOL option_explicit)
376 ctx->parse_complete = TRUE;
377 ctx->option_explicit = option_explicit;
380 static void *new_expression(parser_ctx_t *ctx, expression_type_t type, size_t size)
384 expr = parser_alloc(ctx, size ? size : sizeof(*expr));
393 static expression_t *new_bool_expression(parser_ctx_t *ctx, VARIANT_BOOL value)
395 bool_expression_t *expr;
397 expr = new_expression(ctx, EXPR_BOOL, sizeof(*expr));
405 static expression_t *new_string_expression(parser_ctx_t *ctx, const WCHAR *value)
407 string_expression_t *expr;
409 expr = new_expression(ctx, EXPR_STRING, sizeof(*expr));
417 static expression_t *new_long_expression(parser_ctx_t *ctx, expression_type_t type, LONG value)
419 int_expression_t *expr;
421 expr = new_expression(ctx, type, sizeof(*expr));
429 static expression_t *new_double_expression(parser_ctx_t *ctx, double value)
431 double_expression_t *expr;
433 expr = new_expression(ctx, EXPR_DOUBLE, sizeof(*expr));
441 static expression_t *new_unary_expression(parser_ctx_t *ctx, expression_type_t type, expression_t *subexpr)
443 unary_expression_t *expr;
445 expr = new_expression(ctx, type, sizeof(*expr));
449 expr->subexpr = subexpr;
453 static expression_t *new_binary_expression(parser_ctx_t *ctx, expression_type_t type, expression_t *left, expression_t *right)
455 binary_expression_t *expr;
457 expr = new_expression(ctx, type, sizeof(*expr));
466 static member_expression_t *new_member_expression(parser_ctx_t *ctx, expression_t *obj_expr, const WCHAR *identifier)
468 member_expression_t *expr;
470 expr = new_expression(ctx, EXPR_MEMBER, sizeof(*expr));
474 expr->obj_expr = obj_expr;
475 expr->identifier = identifier;
480 static expression_t *new_new_expression(parser_ctx_t *ctx, const WCHAR *identifier)
482 string_expression_t *expr;
484 expr = new_expression(ctx, EXPR_NEW, sizeof(*expr));
488 expr->value = identifier;
492 static void *new_statement(parser_ctx_t *ctx, statement_type_t type, size_t size)
496 stat = parser_alloc(ctx, size ? size : sizeof(*stat));
505 static statement_t *new_call_statement(parser_ctx_t *ctx, member_expression_t *expr)
507 call_statement_t *stat;
509 stat = new_statement(ctx, STAT_CALL, sizeof(*stat));
517 static statement_t *new_assign_statement(parser_ctx_t *ctx, member_expression_t *left, expression_t *right)
519 assign_statement_t *stat;
521 stat = new_statement(ctx, STAT_ASSIGN, sizeof(*stat));
525 stat->member_expr = left;
526 stat->value_expr = right;
530 static statement_t *new_set_statement(parser_ctx_t *ctx, member_expression_t *left, expression_t *right)
532 assign_statement_t *stat;
534 stat = new_statement(ctx, STAT_SET, sizeof(*stat));
538 stat->member_expr = left;
539 stat->value_expr = right;
543 static dim_decl_t *new_dim_decl(parser_ctx_t *ctx, const WCHAR *name, dim_decl_t *next)
547 decl = parser_alloc(ctx, sizeof(*decl));
556 static statement_t *new_dim_statement(parser_ctx_t *ctx, dim_decl_t *decls)
558 dim_statement_t *stat;
560 stat = new_statement(ctx, STAT_DIM, sizeof(*stat));
564 stat->dim_decls = decls;
568 static elseif_decl_t *new_elseif_decl(parser_ctx_t *ctx, expression_t *expr, statement_t *stat)
572 decl = parser_alloc(ctx, sizeof(*decl));
582 static statement_t *new_while_statement(parser_ctx_t *ctx, statement_type_t type, expression_t *expr, statement_t *body)
584 while_statement_t *stat;
586 stat = new_statement(ctx, type, sizeof(*stat));
595 static statement_t *new_if_statement(parser_ctx_t *ctx, expression_t *expr, statement_t *if_stat, elseif_decl_t *elseif_decl,
596 statement_t *else_stat)
598 if_statement_t *stat;
600 stat = new_statement(ctx, STAT_IF, sizeof(*stat));
605 stat->if_stat = if_stat;
606 stat->elseifs = elseif_decl;
607 stat->else_stat = else_stat;
611 static arg_decl_t *new_argument_decl(parser_ctx_t *ctx, const WCHAR *name, BOOL by_ref)
613 arg_decl_t *arg_decl;
615 arg_decl = parser_alloc(ctx, sizeof(*arg_decl));
619 arg_decl->name = name;
620 arg_decl->by_ref = by_ref;
621 arg_decl->next = NULL;
625 static function_decl_t *new_function_decl(parser_ctx_t *ctx, const WCHAR *name, function_type_t type,
626 unsigned storage_flags, arg_decl_t *arg_decl, statement_t *body)
628 function_decl_t *decl;
630 if(storage_flags & STORAGE_IS_DEFAULT) {
631 if(type == FUNC_PROPGET) {
634 FIXME("Invalid default property\n");
640 decl = parser_alloc(ctx, sizeof(*decl));
646 decl->is_public = !(storage_flags & STORAGE_IS_PRIVATE);
647 decl->args = arg_decl;
650 decl->next_prop_func = NULL;
654 static statement_t *new_function_statement(parser_ctx_t *ctx, function_decl_t *decl)
656 function_statement_t *stat;
658 stat = new_statement(ctx, STAT_FUNC, sizeof(*stat));
662 stat->func_decl = decl;
666 static class_decl_t *new_class_decl(parser_ctx_t *ctx)
668 class_decl_t *class_decl;
670 class_decl = parser_alloc(ctx, sizeof(*class_decl));
674 class_decl->funcs = NULL;
675 class_decl->props = NULL;
676 class_decl->next = NULL;
680 static class_decl_t *add_class_function(parser_ctx_t *ctx, class_decl_t *class_decl, function_decl_t *decl)
682 function_decl_t *iter;
684 for(iter = class_decl->funcs; iter; iter = iter->next) {
685 if(!strcmpiW(iter->name, decl->name)) {
686 if(decl->type == FUNC_SUB || decl->type == FUNC_FUNCTION) {
687 FIXME("Redefinition of %s::%s\n", debugstr_w(class_decl->name), debugstr_w(decl->name));
693 if(iter->type == decl->type) {
694 FIXME("Redefinition of %s::%s\n", debugstr_w(class_decl->name), debugstr_w(decl->name));
698 if(!iter->next_prop_func)
700 iter = iter->next_prop_func;
703 iter->next_prop_func = decl;
708 decl->next = class_decl->funcs;
709 class_decl->funcs = decl;
713 static class_decl_t *add_variant_prop(parser_ctx_t *ctx, class_decl_t *class_decl, const WCHAR *identifier, unsigned storage_flags)
715 class_prop_decl_t *prop;
717 if(storage_flags & STORAGE_IS_DEFAULT) {
718 FIXME("variant prop van't be default value\n");
723 prop = parser_alloc(ctx, sizeof(*prop));
727 prop->name = identifier;
728 prop->is_public = !(storage_flags & STORAGE_IS_PRIVATE);
729 prop->next = class_decl->props;
730 class_decl->props = prop;
734 void *parser_alloc(parser_ctx_t *ctx, size_t size)
738 ret = vbsheap_alloc(&ctx->heap, size);
740 ctx->hres = E_OUTOFMEMORY;
744 HRESULT parse_script(parser_ctx_t *ctx, const WCHAR *code)
746 ctx->code = ctx->ptr = code;
747 ctx->end = ctx->code + strlenW(ctx->code);
749 vbsheap_init(&ctx->heap);
751 ctx->parse_complete = FALSE;
754 ctx->last_token = tNL;
756 ctx->stats = ctx->stats_tail = NULL;
757 ctx->class_decls = NULL;
758 ctx->option_explicit = FALSE;
762 if(FAILED(ctx->hres))
764 if(!ctx->parse_complete) {
765 FIXME("parser failed on parsing %s\n", debugstr_w(ctx->ptr));
772 void parser_release(parser_ctx_t *ctx)
774 vbsheap_free(&ctx->heap);