From 4ca91d212aa0d26164a341c8194ff350c9b852c7 Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=BCrg=20Billeter?= Date: Sat, 3 Mar 2007 16:15:33 +0000 Subject: [PATCH] remove support of old construction syntax MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit 2007-03-03 Jürg Billeter * vala/parser.y: remove support of old construction syntax svn path=/trunk/; revision=212 --- vala/ChangeLog | 4 +++ vala/vala/parser.y | 103 +++++++++++++++++------------------------------------ 2 files changed, 36 insertions(+), 71 deletions(-) diff --git a/vala/ChangeLog b/vala/ChangeLog index 60d8e86..8c8f0b4 100644 --- a/vala/ChangeLog +++ b/vala/ChangeLog @@ -1,5 +1,9 @@ 2007-03-03 Jürg Billeter + * vala/parser.y: remove support of old construction syntax + +2007-03-03 Jürg Billeter + * Switch to new construction syntax 2007-03-03 Jürg Billeter diff --git a/vala/vala/parser.y b/vala/vala/parser.y index 00eb30b..1543d4c 100644 --- a/vala/vala/parser.y +++ b/vala/vala/parser.y @@ -79,8 +79,7 @@ static void yyerror (YYLTYPE *locp, ValaParser *parser, const char *msg); ValaCallback *callback; ValaConstant *constant; ValaField *field; - // TODO change back to ValaMethod after construction syntax transition - ValaCodeNode *method; + ValaMethod *method; ValaFormalParameter *formal_parameter; ValaProperty *property; ValaPropertyAccessor *property_accessor; @@ -203,7 +202,6 @@ static void yyerror (YYLTYPE *locp, ValaParser *parser, const char *msg); %token STRING_LITERAL "string" %type comment -%type opt_identifier %type literal %type boolean_literal %type type_name @@ -329,6 +327,7 @@ static void yyerror (YYLTYPE *locp, ValaParser *parser, const char *msg); %type fixed_parameters %type fixed_parameter %type signal_declaration +%type constructor_declaration %type destructor_declaration %type opt_attributes %type attributes @@ -362,14 +361,6 @@ opt_comma | COMMA ; -opt_identifier - : /* empty */ - { - $$ = NULL; - } - | IDENTIFIER - ; - literal : boolean_literal | INTEGER_LITERAL @@ -2099,12 +2090,7 @@ class_member_declaration { /* skip declarations with errors */ if ($1 != NULL) { - // TODO remove after construction syntax transition - if (VALA_IS_CONSTRUCTOR($1)) { - vala_class_set_constructor (current_class, $1); - } else { - vala_class_add_method (current_class, $1); - } + vala_class_add_method (current_class, $1); g_object_unref ($1); } } @@ -2124,6 +2110,14 @@ class_member_declaration g_object_unref ($1); } } + | constructor_declaration + { + /* skip declarations with errors */ + if ($1 != NULL) { + vala_class_set_constructor (current_class, $1); + g_object_unref ($1); + } + } | destructor_declaration { /* skip declarations with errors */ @@ -2252,12 +2246,7 @@ method_declaration : method_header method_body { $$ = $1; - // TODO remove after construction syntax transition - if (VALA_IS_CONSTRUCTOR($$)) { - vala_constructor_set_body ($$, $2); - } else { - vala_method_set_body ($$, VALA_BLOCK($2)); - } + vala_method_set_body ($$, VALA_BLOCK($2)); if ($2 != NULL) { g_object_unref ($2); } @@ -2281,7 +2270,7 @@ method_header $$ = vala_method_new ($6, $5, src); g_object_unref (src); if ($3 != 0) { - VALA_METHOD($$)->access = $3; + $$->access = $3; } if (($4 & VALA_MODIFIER_STATIC) == VALA_MODIFIER_STATIC) { vala_method_set_instance ($$, FALSE); @@ -2310,65 +2299,26 @@ method_header } | comment opt_attributes opt_access_modifier opt_modifiers IDENTIFIER opt_name_specifier OPEN_PARENS opt_formal_parameter_list CLOSE_PARENS { - if ($3 != 0) { - GList *l; - - ValaSourceReference *src = src_com(@5, $1); - $$ = vala_method_new ($6, NULL, src); - g_free ($5); - g_free ($6); - g_object_unref (src); - vala_method_set_construction ($$, TRUE); - vala_method_set_instance ($$, FALSE); - if ($3 != 0) { - VALA_METHOD($$)->access = $3; - } - VALA_CODE_NODE($$)->attributes = $2; - - if ($8 != NULL) { - for (l = $8; l != NULL; l = l->next) { - vala_method_add_parameter ($$, l->data); - g_object_unref (l->data); - } - g_list_free ($8); - } - } else { - // TODO remove after construction syntax transition - ValaSourceReference *src = src_com(@5, $1); - $$ = vala_constructor_new (src); - g_object_unref (src); - g_free ($5); - g_free ($6); - } - } - | comment opt_attributes opt_access_modifier CONSTRUCT - { - ValaSourceReference *src = src_com(@4, $1); - $$ = vala_constructor_new (src); - g_object_unref (src); - } - // TODO remove after construction syntax transition - | comment opt_attributes opt_access_modifier CONSTRUCT opt_identifier OPEN_PARENS opt_formal_parameter_list CLOSE_PARENS - { - GList *l; + GList *l; - ValaSourceReference *src = src_com(@4, $1); - $$ = vala_method_new ($5, NULL, src); + ValaSourceReference *src = src_com(@5, $1); + $$ = vala_method_new ($6, NULL, src); g_free ($5); + g_free ($6); g_object_unref (src); vala_method_set_construction ($$, TRUE); vala_method_set_instance ($$, FALSE); if ($3 != 0) { - VALA_METHOD($$)->access = $3; + $$->access = $3; } VALA_CODE_NODE($$)->attributes = $2; - if ($7 != NULL) { - for (l = $7; l != NULL; l = l->next) { + if ($8 != NULL) { + for (l = $8; l != NULL; l = l->next) { vala_method_add_parameter ($$, l->data); g_object_unref (l->data); } - g_list_free ($7); + g_list_free ($8); } } ; @@ -2562,6 +2512,17 @@ signal_declaration } ; +constructor_declaration + : comment opt_attributes CONSTRUCT block + { + ValaSourceReference *src = src_com(@3, $1); + $$ = vala_constructor_new (src); + g_object_unref (src); + vala_constructor_set_body ($$, $4); + g_object_unref ($4); + } + ; + destructor_declaration : comment opt_attributes opt_access_modifier opt_modifiers TILDE IDENTIFIER OPEN_PARENS CLOSE_PARENS block { -- 2.7.4