This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
ObjC parser simplification
- To: gcc-patches at gcc dot gnu dot org
- Subject: ObjC parser simplification
- From: Neil Booth <neil at daikokuya dot demon dot co dot uk>
- Date: Tue, 15 May 2001 23:01:36 +0100
- Cc: Stan Shebs <shebs at apple dot com>
This patch removes two areas of duplication in the ObjC parser; nearly
identical code handled the'-' and '+' method type specifiers. It
factors them out into a separate production, and collapses both
duplications into one of each.
Bootstrapped x86 Linux. OK to commit?
Neil.
* c-parse.in (methodtype): New production.
(methoddef, methodproto): Collapse separate '-' and '+'
handlers into 1.
Index: c-parse.in
===================================================================
RCS file: /cvs/gcc/gcc/gcc/c-parse.in,v
retrieving revision 1.88
diff -u -p -r1.88 c-parse.in
--- c-parse.in 2001/05/12 17:58:41 1.88
+++ c-parse.in 2001/05/15 21:47:51
@@ -2946,44 +2946,27 @@ ivar_declarator:
}
;
-methoddef:
+methodtype:
'+'
- {
- remember_protocol_qualifiers ();
- if (objc_implementation_context)
- objc_inherit_code = CLASS_METHOD_DECL;
- else
- fatal_error ("method definition not in class context");
- }
- methoddecl
- {
- forget_protocol_qualifiers ();
- add_class_method (objc_implementation_context, $3);
- start_method_def ($3);
- objc_method_context = $3;
- }
- optarglist
- {
- continue_method_def ();
- }
- compstmt_or_error
- {
- finish_method_def ();
- objc_method_context = NULL_TREE;
- }
-
+ { objc_inherit_code = CLASS_METHOD_DECL; }
| '-'
+ { objc_inherit_code = INSTANCE_METHOD_DECL; }
+ ;
+
+methoddef:
+ methodtype
{
remember_protocol_qualifiers ();
- if (objc_implementation_context)
- objc_inherit_code = INSTANCE_METHOD_DECL;
- else
+ if (!objc_implementation_context)
fatal_error ("method definition not in class context");
}
methoddecl
{
forget_protocol_qualifiers ();
- add_instance_method (objc_implementation_context, $3);
+ if (objc_inherit_code == CLASS_METHOD_DECL)
+ add_class_method (objc_implementation_context, $3);
+ else
+ add_instance_method (objc_implementation_context, $3);
start_method_def ($3);
objc_method_context = $3;
}
@@ -3020,31 +3003,19 @@ semi_or_error:
;
methodproto:
- '+'
- {
- /* Remember protocol qualifiers in prototypes. */
- remember_protocol_qualifiers ();
- objc_inherit_code = CLASS_METHOD_DECL;
- }
- methoddecl
- {
- /* Forget protocol qualifiers here. */
- forget_protocol_qualifiers ();
- add_class_method (objc_interface_context, $3);
- }
- semi_or_error
-
- | '-'
+ methodtype
{
/* Remember protocol qualifiers in prototypes. */
remember_protocol_qualifiers ();
- objc_inherit_code = INSTANCE_METHOD_DECL;
}
methoddecl
{
/* Forget protocol qualifiers here. */
forget_protocol_qualifiers ();
- add_instance_method (objc_interface_context, $3);
+ if (objc_inherit_code == CLASS_METHOD_DECL)
+ add_class_method (objc_interface_context, $3);
+ else
+ add_instance_method (objc_interface_context, $3);
}
semi_or_error
;