diff --git a/tools/qfcc/source/qc-lex.l b/tools/qfcc/source/qc-lex.l index a601e80b0..978796527 100644 --- a/tools/qfcc/source/qc-lex.l +++ b/tools/qfcc/source/qc-lex.l @@ -88,7 +88,6 @@ void add_frame_macro (char *token); const char *make_string (char *token); extern YYSTYPE yylval; -extern int element_flag; %} @@ -219,10 +218,6 @@ m ([\-+]?) } [!(){}.*/&|^~+\-=\[\];,#%?:] { - if (yytext[0] == '{' && element_flag) { - element_flag = 0; - return ELE_START; - } return yytext[0]; } diff --git a/tools/qfcc/source/qc-parse.y b/tools/qfcc/source/qc-parse.y index 1faae51a2..d62a80478 100644 --- a/tools/qfcc/source/qc-parse.y +++ b/tools/qfcc/source/qc-parse.y @@ -154,7 +154,7 @@ expr_t *argv_expr (void); %type type non_field_type type_name def simple_def struct_def %type struct_def_item ivar_decl ivar_declarator def_item def_list -%type struct_def_list ivars func_type non_func_type +%type struct_def_list ivars func_type non_func_type func_def %type function_decl %type param param_list %type def_name opt_initializer methoddef var_initializer @@ -198,8 +198,6 @@ struct_t *current_ivars; scope_t *current_scope; storage_class_t current_storage = st_global; -int element_flag; - %} %expect 4 @@ -241,7 +239,7 @@ simple_defs simple_def : non_func_type { $$ = $1; } def_list ';' { } - | func_type { $$ = $1; } def_list ';' { } + | func_type { $$ = $1; } func_def ';' { } ; storage_class @@ -410,6 +408,34 @@ def_item } ; +func_def + : def_name '=' '#' fexpr + { + $4 = constant_expr ($4); + build_builtin_function ($1, $4); + } + | def_name '=' opt_state_expr + { $$ = current_storage; } + { $$ = $1; } + begin_function statement_block { $$ = $4; } end_function + { + build_function ($6); + if ($3) { + $3->next = $7; + emit_function ($6, $3); + } else { + emit_function ($6, $7); + } + finish_function ($6); + } + | def_name + { + if ($1 && !$1->local + && $1->type->type != ev_func) + def_initialized ($1); + } + ; + def_name : NAME { @@ -427,8 +453,8 @@ def_name opt_initializer : /*empty*/ { } - | { element_flag = $0->type->type != ev_func; $$ = $0; } - var_initializer { element_flag = 0; } + | { $$ = $0; } + var_initializer { } ; var_initializer @@ -457,28 +483,11 @@ var_initializer } } } - | '=' ELE_START { current_init = new_block_expr (); } element_list '}' + | '=' '{' { current_init = new_block_expr (); } element_list '}' { init_elements ($0, $4); current_init = 0; } - | '=' '#' fexpr - { - $3 = constant_expr ($3); - build_builtin_function ($0, $3); - } - | '=' opt_state_expr { $$ = current_storage; } { $$ = $0; } - begin_function statement_block { $$ = $3; } end_function - { - build_function ($5); - if ($2) { - $2->next = $6; - emit_function ($5, $2); - } else { - emit_function ($5, $6); - } - finish_function ($5); - } ; opt_state_expr