Commit 4ca91d21 authored by Jürg Billeter's avatar Jürg Billeter Committed by Jürg Billeter
Browse files

remove support of old construction syntax

2007-03-03  Jürg Billeter  <j@bitron.ch>

	* vala/parser.y: remove support of old construction syntax

svn path=/trunk/; revision=212
parent 774705f4
2007-03-03 Jürg Billeter <j@bitron.ch>
* vala/parser.y: remove support of old construction syntax
2007-03-03 Jürg Billeter <j@bitron.ch>
* Switch to new construction syntax
......
......@@ -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 <str> STRING_LITERAL "string"
%type <str> comment
%type <str> opt_identifier
%type <literal> literal
%type <literal> boolean_literal
%type <type_reference> type_name
......@@ -329,6 +327,7 @@ static void yyerror (YYLTYPE *locp, ValaParser *parser, const char *msg);
%type <list> fixed_parameters
%type <formal_parameter> fixed_parameter
%type <signal> signal_declaration
%type <constructor> constructor_declaration
%type <destructor> destructor_declaration
%type <list> opt_attributes
%type <list> 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
{
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment