In .:
[mono.git] / mcs / gmcs / cs-parser.jay
index cf64653d3e42b1f5a27014e4293e3612e6d4e255..ee9c3e9a7eda42721740c80ff8c331af14bc399a 100644 (file)
@@ -95,7 +95,7 @@ namespace Mono.CSharp
                /// Current attribute target
                string current_attr_target;
                
-               /// assembly and module attribute definition is enabled
+               /// assembly and module attribute definitions are enabled
                bool global_attrs_enabled = true;
                bool has_get, has_set;
 
@@ -340,8 +340,7 @@ using_alias_directive
        : USING IDENTIFIER ASSIGN 
          namespace_or_type_name SEMICOLON
          {
-               MemberName name = (MemberName) $4;
-               current_namespace.UsingAlias ((string) $2, name.GetTypeExpression (lexer.Location), lexer.Location);
+               current_namespace.UsingAlias ((string) $2, (MemberName) $4, lexer.Location);
          }
        | USING error {
                CheckIdentifierToken (yyToken);
@@ -351,8 +350,7 @@ using_alias_directive
 using_namespace_directive
        : USING namespace_name SEMICOLON 
          {
-               MemberName ns_name = (MemberName) $2;
-               current_namespace.Using (ns_name.GetTypeExpression (lexer.Location), lexer.Location);
+               current_namespace.Using ((MemberName) $2, lexer.Location);
           }
        ;
 
@@ -412,8 +410,6 @@ namespace_body
          opt_using_directives
          opt_namespace_member_declarations
          CLOSE_BRACE
-         {
-         }
        ;
 
 opt_using_directives
@@ -507,7 +503,7 @@ attribute_sections
                        if (current_attr_target == "module") {
                                CodeGen.Module.AddAttributes (sect);
                                $$ = null;
-                       } else if (current_attr_target == "assembly") {
+                       } else if (current_attr_target != null && current_attr_target.Length > 0) {
                                CodeGen.Assembly.AddAttributes (sect);
                                $$ = null;
                        } else {
@@ -621,7 +617,7 @@ attribute
                Expression left_expr = left == null ? null : left.GetTypeExpression (loc);
 
                if (current_attr_target == "assembly" || current_attr_target == "module")
-                       $$ = new GlobalAttribute (current_container, current_attr_target,
+                       $$ = new GlobalAttribute (current_class, current_attr_target,
                                                  left_expr, identifier, (ArrayList) $3, loc);
                else
                        $$ = new Attribute (current_attr_target, left_expr, identifier, (ArrayList) $3, loc);
@@ -758,9 +754,13 @@ struct_declaration
        : opt_attributes
          opt_modifiers
          opt_partial
-         STRUCT member_name
+         STRUCT
+         {
+               lexer.ConstraintsParsing = true;
+         }
+         member_name
          { 
-               MemberName name = MakeName ((MemberName) $5);
+               MemberName name = MakeName ((MemberName) $6);
                bool partial = (bool) $3;
 
                if (partial) {
@@ -777,20 +777,18 @@ struct_declaration
 
                        current_container.AddClassOrStruct (current_class);
                        current_container = current_class;
-                       RootContext.Tree.RecordDecl (name.GetName (true), current_class);
+                       RootContext.Tree.RecordDecl (current_namespace.NS, name, current_class);
                }
-
-               lexer.ConstraintsParsing = true;
          }
          opt_class_base
          opt_type_parameter_constraints_clauses
          {
                lexer.ConstraintsParsing = false;
 
-               if ($7 != null)
-                       current_class.Bases = (ArrayList) $7;
+               if ($8 != null)
+                       current_class.Bases = (ArrayList) $8;
 
-               current_class.SetParameterInfo ((ArrayList) $8);
+               current_class.SetParameterInfo ((ArrayList) $9);
 
                if (RootContext.Documentation != null)
                        current_class.DocComment = Lexer.consume_doc_comment ();
@@ -858,7 +856,7 @@ constant_declaration
                foreach (VariableDeclaration constant in (ArrayList) $5){
                        Location l = constant.Location;
                        if ((modflags & Modifiers.STATIC) != 0) {
-                               Report.Error (504, l, "The constant '{0}' cannot be marked static", current_container.GetSignatureForError () + '.' + (string) constant.identifier);
+                               Report.Error (504, l, "The constant `{0}' cannot be marked static", current_container.GetSignatureForError () + '.' + (string) constant.identifier);
                                continue;
                        }
 
@@ -954,7 +952,7 @@ field_declaration
          VOID  
          variable_declarators
          SEMICOLON {
-               Report.Error (670, lexer.Location, "void type is not allowed for fields");
+               Report.Error (670, lexer.Location, "Fields cannot have void type");
          }
        ;
 
@@ -984,7 +982,8 @@ variable_declarators
        : variable_declarator 
          {
                ArrayList decl = new ArrayList (4);
-               decl.Add ($1);
+               if ($1 != null)
+                       decl.Add ($1);
                $$ = decl;
          }
        | variable_declarators COMMA variable_declarator
@@ -1007,7 +1006,8 @@ variable_declarator
        | IDENTIFIER OPEN_BRACKET opt_expression CLOSE_BRACKET
          {
                Report.Error (650, lexer.Location, "Syntax error, bad array declarator. To declare a managed array the rank specifier precedes the variable's identifier. " +
-                       "To declare a fixed buffer field, use the fixed keyword before the field type");
+                       "To declare a fixed size buffer field, use the fixed keyword before the field type");
+               $$ = null;
          }
        ;
 
@@ -1041,22 +1041,6 @@ method_declaration
          {
                Method method = (Method) $1;
                Block b = (Block) $3;
-               const int extern_abstract = (Modifiers.EXTERN | Modifiers.ABSTRACT);
-
-               if (b == null){
-                       if ((method.ModFlags & extern_abstract) == 0){
-                               Report.Error (
-                                       501, lexer.Location,  current_container.MakeName (method.Name) +
-                                       "must declare a body because it is not marked abstract or extern");
-                       }
-               } else {
-                       if ((method.ModFlags & Modifiers.EXTERN) != 0){
-                               Report.Error (
-                                       179, lexer.Location, current_container.MakeName (method.Name) +
-                                       " is declared extern, but has a body");
-                       }
-               }
-
                method.Block = (ToplevelBlock) $3;
                current_container.AddMethod (method);
 
@@ -1068,6 +1052,25 @@ method_declaration
          }
        ;
 
+opt_error_modifier
+       : /* empty */
+       | modifiers 
+         {
+               int m = (int) $1;
+               int i = 1;
+
+               while (m != 0){
+                       if ((i & m) != 0){
+                               Report.Error (1585, lexer.Location,
+                                       "Member modifier `{0}' must precede the member type and name",
+                                       Modifiers.Name (i));
+                       }
+                       m &= ~i;
+                       i = i << 1;
+               }
+         }
+       ;
+
 method_header
        : opt_attributes
          opt_modifiers
@@ -1149,8 +1152,7 @@ method_header
          modifiers namespace_or_type_name OPEN_PARENS opt_formal_parameter_list CLOSE_PARENS
          {
                Report.Error (1585, lexer.Location, 
-                       String.Format ("Modifier {0} should appear before type", 
-                               Modifiers.Name ((int) $4)));
+                       "Member modifier `{0}' must precede the member type and name", Modifiers.Name ((int) $4));
                MemberName name = (MemberName) $4;
 
                Method method = new Method (current_class, null, TypeManager.system_void_expr,
@@ -1162,7 +1164,7 @@ method_header
                if (RootContext.Documentation != null)
                        method.DocComment = Lexer.consume_doc_comment ();
 
-               $$ = method;
+               $$ = null;
          }
        ;
 
@@ -1184,7 +1186,7 @@ formal_parameter_list
                Parameter [] pars = new Parameter [pars_list.Count];
                pars_list.CopyTo (pars);
 
-               $$ = new Parameters (pars, null, lexer.Location); 
+               $$ = new Parameters (pars, null); 
          } 
        | fixed_parameters COMMA parameter_array
          {
@@ -1193,7 +1195,7 @@ formal_parameter_list
                Parameter [] pars = new Parameter [pars_list.Count];
                pars_list.CopyTo (pars);
 
-               $$ = new Parameters (pars, (Parameter) $3, lexer.Location); 
+               $$ = new Parameters (pars, (Parameter) $3); 
          }
        | fixed_parameters COMMA ARGLIST
          {
@@ -1202,15 +1204,25 @@ formal_parameter_list
                Parameter [] pars = new Parameter [pars_list.Count];
                pars_list.CopyTo (pars);
 
-               $$ = new Parameters (pars, true, lexer.Location);
+               $$ = new Parameters (pars, true);
+         }
+       | parameter_array COMMA fixed_parameters
+         {
+               Report.Error (231, lexer.Location, "A params parameter must be the last parameter in a formal parameter list");
+               $$ = null;
+         }
+       | ARGLIST COMMA fixed_parameters
+         {
+               Report.Error (257, lexer.Location, "An __arglist parameter must be the last parameter in a formal parameter list");
+               $$ = null;
          }
        | parameter_array 
          {
-               $$ = new Parameters (null, (Parameter) $1, lexer.Location);
+               $$ = new Parameters (null, (Parameter) $1);
          }
        | ARGLIST
          {
-               $$ = new Parameters (null, true, lexer.Location);
+               $$ = new Parameters (null, true);
          }
        ;
 
@@ -1237,7 +1249,15 @@ fixed_parameter
          type
          IDENTIFIER
          {
-               $$ = new Parameter ((Expression) $3, (string) $4, (Parameter.Modifier) $2, (Attributes) $1);
+               $$ = new Parameter ((Expression) $3, (string) $4, (Parameter.Modifier) $2, (Attributes) $1, lexer.Location);
+         }
+       | opt_attributes
+         opt_parameter_modifier
+         type
+         IDENTIFIER OPEN_BRACKET CLOSE_BRACKET
+         {
+               Report.Error (1552, lexer.Location, "Array type specifier, [], must appear before parameter name");
+               $$ = null;
          }
        | opt_attributes
          opt_parameter_modifier
@@ -1278,7 +1298,7 @@ parameter_modifier
 parameter_array
        : opt_attributes PARAMS type IDENTIFIER
          { 
-               $$ = new Parameter ((Expression) $3, (string) $4, Parameter.Modifier.PARAMS, (Attributes) $1);
+               $$ = new Parameter ((Expression) $3, (string) $4, Parameter.Modifier.PARAMS, (Attributes) $1, lexer.Location);
                note ("type must be a single-dimension array type"); 
          }
        | opt_attributes PARAMS parameter_modifier type IDENTIFIER 
@@ -1308,8 +1328,6 @@ property_declaration
                lexer.PropertyParsing = true;
 
                $$ = lexer.Location;
-
-               iterator_container = SimpleIteratorContainer.GetSimple ();
          }
          accessor_declarations 
          {
@@ -1332,14 +1350,11 @@ property_declaration
                if (name.TypeArguments != null)
                        syntax_error (lexer.Location, "a property can't have type arguments");
 
-               prop = new Property (current_container, (Expression) $3, (int) $2, false,
+               prop = new Property (current_class, (Expression) $3, (int) $2, false,
                                     name, (Attributes) $1, get_block, set_block, loc);
-               if (SimpleIteratorContainer.Simple.Yields)
-                       prop.SetYields ();
                
                current_container.AddProperty (prop);
                implicit_value_parameter_type = null;
-               iterator_container = null;
 
                if (RootContext.Documentation != null)
                        prop.DocComment = ConsumeStoredComment ();
@@ -1385,6 +1400,8 @@ get_accessor_declaration
                else 
                        current_local_parameters = indexer_parameters;
                lexer.PropertyParsing = false;
+
+               iterator_container = SimpleIteratorContainer.GetSimple ();
          }
           accessor_body
          {
@@ -1392,14 +1409,21 @@ get_accessor_declaration
                        Report.Error (1007, lexer.Location, "Property accessor already defined");
                        break;
                }
-               $$ = new Accessor ((ToplevelBlock) $5, (int) $2, (Attributes) $1, lexer.Location);
+               Accessor accessor = new Accessor ((ToplevelBlock) $5, (int) $2, (Attributes) $1, lexer.Location);
                has_get = true;
                current_local_parameters = null;
                lexer.PropertyParsing = true;
 
+               if (SimpleIteratorContainer.Simple.Yields)
+                       accessor.SetYields ();
+
+               iterator_container = null;
+
                if (RootContext.Documentation != null)
                        if (Lexer.doc_state == XmlCommentState.Error)
                                Lexer.doc_state = XmlCommentState.NotAllowed;
+
+               $$ = accessor;
          }
        ;
 
@@ -1409,12 +1433,12 @@ set_accessor_declaration
                Parameter [] args;
                Parameter implicit_value_parameter = new Parameter (
                        implicit_value_parameter_type, "value", 
-                       Parameter.Modifier.NONE, null);
+                       Parameter.Modifier.NONE, null, lexer.Location);
 
                if (parsing_indexer == false) {
                        args  = new Parameter [1];
                        args [0] = implicit_value_parameter;
-                       current_local_parameters = new Parameters (args, null, lexer.Location);
+                       current_local_parameters = new Parameters (args, null);
                } else {
                        Parameter [] fpars = indexer_parameters.FixedParameters;
 
@@ -1427,10 +1451,12 @@ set_accessor_declaration
                        } else 
                                args = null;
                        current_local_parameters = new Parameters (
-                               args, indexer_parameters.ArrayParameter, lexer.Location);
+                               args, indexer_parameters.ArrayParameter);
                }
                
                lexer.PropertyParsing = false;
+
+               iterator_container = SimpleIteratorContainer.GetSimple ();
          }
          accessor_body
          {
@@ -1438,14 +1464,21 @@ set_accessor_declaration
                        Report.Error (1007, lexer.Location, "Property accessor already defined");
                        break;
                }
-               $$ = new Accessor ((ToplevelBlock) $5, (int) $2, (Attributes) $1, lexer.Location);
+               Accessor accessor = new Accessor ((ToplevelBlock) $5, (int) $2, (Attributes) $1, lexer.Location);
                has_set = true;
                current_local_parameters = null;
                lexer.PropertyParsing = true;
 
+               if (SimpleIteratorContainer.Simple.Yields)
+                       accessor.SetYields ();
+
+               iterator_container = null;
+
                if (RootContext.Documentation != null
                        && Lexer.doc_state == XmlCommentState.Error)
                        Lexer.doc_state = XmlCommentState.NotAllowed;
+
+               $$ = accessor;
          }
        ;
 
@@ -1458,9 +1491,13 @@ interface_declaration
        : opt_attributes
          opt_modifiers
          opt_partial
-         INTERFACE member_name
+         INTERFACE
          {
-               MemberName name = MakeName ((MemberName) $5);
+               lexer.ConstraintsParsing = true;
+         }
+         member_name
+         {
+               MemberName name = MakeName ((MemberName) $6);
                bool partial = (bool) $3;
 
                if (partial) {
@@ -1477,20 +1514,18 @@ interface_declaration
 
                        current_container.AddInterface (current_class);
                        current_container = current_class;
-                       RootContext.Tree.RecordDecl (name.GetName (true), current_class);
+                       RootContext.Tree.RecordDecl (current_namespace.NS, name, current_class);
                }
-
-               lexer.ConstraintsParsing = true;
          }
          opt_class_base
          opt_type_parameter_constraints_clauses
          {
                lexer.ConstraintsParsing = false;
 
-               if ($7 != null)
-                       current_class.Bases = (ArrayList) $7;
+               if ($8 != null)
+                       current_class.Bases = (ArrayList) $8;
 
-               current_class.SetParameterInfo ((ArrayList) $8);
+               current_class.SetParameterInfo ((ArrayList) $9);
 
                if (RootContext.Documentation != null) {
                        current_class.DocComment = Lexer.consume_doc_comment ();
@@ -1536,8 +1571,8 @@ interface_member_declaration
                Method m = (Method) $1;
 
                if (m.IsExplicitImpl)
-                       Report.Error (541, lexer.Location, 
-                               "Explicit interface declaration can only be declared in a class or struct");
+                       Report.Error (541, lexer.Location, "`{0}': explicit interface declaration can only be declared in a class or struct",
+                               m.GetSignatureForError ());
 
                current_container.AddMethod (m);
 
@@ -1552,8 +1587,8 @@ interface_member_declaration
                Property p = (Property) $1;
 
                if (p.IsExplicitImpl)
-                       Report.Error (541, lexer.Location, 
-                               "Explicit interface declaration can only be declared in a class or struct");
+                       Report.Error (541, lexer.Location, "`{0}': explicit interface declaration can only be declared in a class or struct",
+                               p.GetSignatureForError ());
 
                current_container.AddProperty (p);
 
@@ -1566,8 +1601,8 @@ interface_member_declaration
                        Event e = (Event) $1;
 
                        if (e.IsExplicitImpl)
-                               Report.Error (541, lexer.Location, 
-                                   "Explicit interface declaration can only be declared in a class or struct");
+                       Report.Error (541, lexer.Location, "`{0}': explicit interface declaration can only be declared in a class or struct",
+                               e.GetSignatureForError ());
                        
                        current_container.AddEvent (e);
                }
@@ -1583,8 +1618,8 @@ interface_member_declaration
                Indexer i = (Indexer) $1;
 
                if (i.IsExplicitImpl)
-                       Report.Error (541, lexer.Location, 
-                               "Explicit interface declaration can only be declared in a class or struct");
+                       Report.Error (541, lexer.Location, "`{0}': explicit interface declaration can only be declared in a class or struct",
+                               i.GetSignatureForError ());
 
                current_container.AddIndexer (i);
 
@@ -1593,27 +1628,42 @@ interface_member_declaration
          }
        | delegate_declaration
          {
-               Report.Error (524, lexer.Location, "Interfaces can not declare delegates");
+               if ($1 != null) {
+                       Report.Error (524, lexer.Location, "`{0}': Interfaces cannot declare classes, structs, interfaces, delegates, enumerations or constants",
+                               ((MemberCore)$1).GetSignatureForError ());
+               }
          }
        | class_declaration
          {
-               Report.Error (524, lexer.Location, "Interfaces can not declare classes");
+               if ($1 != null) {
+                       Report.Error (524, lexer.Location, "`{0}': Interfaces cannot declare classes, structs, interfaces, delegates, enumerations or constants",
+                               ((MemberCore)$1).GetSignatureForError ());
+               }
          }
        | struct_declaration
          {
-               Report.Error (524, lexer.Location, "Interfaces can not declare structures");
+               if ($1 != null) {
+                       Report.Error (524, lexer.Location, "`{0}': Interfaces cannot declare classes, structs, interfaces, delegates, enumerations or constants",
+                               ((MemberCore)$1).GetSignatureForError ());
+               }
          }
        | enum_declaration 
          {
-               Report.Error (524, lexer.Location, "Interfaces can not declare enumerations");
+               if ($1 != null) {
+                       Report.Error (524, lexer.Location, "`{0}': Interfaces cannot declare classes, structs, interfaces, delegates, enumerations or constants",
+                               ((MemberCore)$1).GetSignatureForError ());
+               }
          }
        | interface_declaration 
          {
-               Report.Error (524, lexer.Location, "Interfaces can not declare interfaces");
+               if ($1 != null) {
+                       Report.Error (524, lexer.Location, "`{0}': Interfaces cannot declare classes, structs, interfaces, delegates, enumerations or constants",
+                               ((MemberCore)$1).GetSignatureForError ());
+               }
          } 
        | constant_declaration
          {
-               Report.Error (525, lexer.Location, "Interfaces cannot contain constants");
+               Report.Error (525, lexer.Location, "Interfaces cannot contain fields or constants");
          }
        ;
 
@@ -1626,6 +1676,20 @@ opt_new
          }
        ;
 
+interface_method_declaration_body
+       : OPEN_BRACE
+         {
+               lexer.ConstraintsParsing = false;
+         }
+         opt_statement_list CLOSE_BRACE
+         {
+               Report.Error (531, lexer.Location,
+                             "'{0}': interface members cannot have a definition", $4);
+               $$ = null;
+         }
+       | SEMICOLON
+       ;
+
 interface_method_declaration
        : opt_attributes opt_new type namespace_or_type_name
          OPEN_PARENS opt_formal_parameter_list CLOSE_PARENS
@@ -1633,7 +1697,7 @@ interface_method_declaration
                lexer.ConstraintsParsing = true;
          }
          opt_type_parameter_constraints_clauses
-         SEMICOLON
+         interface_method_declaration_body
          {
                lexer.ConstraintsParsing = false;
 
@@ -1662,7 +1726,7 @@ interface_method_declaration
                lexer.ConstraintsParsing = true;
          }
          opt_type_parameter_constraints_clauses
-         SEMICOLON
+         interface_method_declaration_body
          {
                lexer.ConstraintsParsing = false;
 
@@ -1685,19 +1749,6 @@ interface_method_declaration
                if (RootContext.Documentation != null)
                        ((Method) $$).DocComment = Lexer.consume_doc_comment ();
          }
-       | opt_attributes opt_new type namespace_or_type_name
-         OPEN_PARENS opt_formal_parameter_list CLOSE_PARENS
-         {
-               lexer.ConstraintsParsing = true;
-         }
-         opt_type_parameter_constraints_clauses
-         OPEN_BRACE opt_statement_list CLOSE_BRACE
-         {
-               lexer.ConstraintsParsing = false;
-               Report.Error (531, lexer.Location, "'{0}': interface members cannot have a definition", $4);
-               $$ = null;
-         }
-
        ;
 
 interface_property_declaration
@@ -1711,12 +1762,18 @@ interface_property_declaration
          CLOSE_BRACE
          {
                if ($3 == TypeManager.system_void_expr) {
-                       Report.Error (547, lexer.Location, "'{0}': property cannot have void type", $4);
+                       Report.Error (547, lexer.Location, "`{0}': property or indexer cannot have void type", $4);
                        break;
                }
 
-               if ($7 == null)
+               if ($7 == null) {
+                       Property p = new Property (current_class, (Expression) $3, (int) $2, true,
+                                  new MemberName ((string) $4), (Attributes) $1,
+                                  null, null, lexer.Location);
+
+                       Report.Error (548, lexer.Location, "`{0}': property or indexer must have at least one accessor", p.GetSignatureForError ());
                        break;
+               }
 
                 InterfaceAccessorInfo pinfo = (InterfaceAccessorInfo) $7;
 
@@ -1739,8 +1796,8 @@ interface_accessors
        { $$ = new InterfaceAccessorInfo (true, false, (Attributes) $1, null, (int) $2, 0, lexer.Location, lexer.Location); }
        | opt_attributes opt_modifiers GET OPEN_BRACE
         {  
-               Report.Error (531, lexer.Location, "'{0}': interface members cannot have a definition", ".get");
-               $$ = null;
+               Report.Error (531, lexer.Location, "`{0}': interface members cannot have a definition", ".get");
+               $$ = new InterfaceAccessorInfo (true, false, (Attributes) $1, null, (int) $2, 0, lexer.Location, lexer.Location);
         }
        | opt_attributes opt_modifiers SET SEMICOLON            
        { $$ = new InterfaceAccessorInfo (false, true, null, (Attributes) $1, 0, (int) $2, lexer.Location, lexer.Location); }
@@ -1750,7 +1807,7 @@ interface_accessors
          { $$ = new InterfaceAccessorInfo (true, true, (Attributes) $5, (Attributes) $1, (int) $6, (int) $2, lexer.Location, lexer.Location); }
        |
          {
-               Report.Error (548, lexer.Location, "'{0}' : property or indexer must have at least one accessor", "");
+               $$ = null;
          }
        ;
 
@@ -1768,7 +1825,7 @@ interface_event_declaration
                $$ = null;
          }
        | opt_attributes opt_new EVENT type IDENTIFIER ASSIGN  {
-               Report.Error (68, lexer.Location, "Event declarations on interfaces can not be initialized.");
+               Report.Error (68, lexer.Location, "`{0}.{1}': event in interface cannot have initializer", current_container.Name, $5);
                $$ = null;
          }
        | opt_attributes opt_new EVENT type IDENTIFIER OPEN_BRACE
@@ -1794,8 +1851,15 @@ interface_indexer_declaration
          { lexer.PropertyParsing = false; }
          CLOSE_BRACE
          {
-               if ($10 == null)
+               if ($10 == null) {
+                       Indexer i = new Indexer (current_class, (Expression) $3,
+                                 new MemberName (TypeContainer.DefaultIndexerName),
+                                 (int) $2, true, (Parameters) $6, (Attributes) $1,
+                                 null, null, lexer.Location);
+
+                       Report.Error (548, lexer.Location, "`{0}': property or indexer must have at least one accessor", i.GetSignatureForError ());
                        break;
+               }
 
                InterfaceAccessorInfo info = (InterfaceAccessorInfo) $10;
 
@@ -1822,13 +1886,13 @@ operator_declaration
                
                Parameter [] param_list = new Parameter [decl.arg2type != null ? 2 : 1];
 
-               param_list[0] = new Parameter (decl.arg1type, decl.arg1name, Parameter.Modifier.NONE, null);
+               param_list[0] = new Parameter (decl.arg1type, decl.arg1name, Parameter.Modifier.NONE, null, decl.location);
                if (decl.arg2type != null)
-                       param_list[1] = new Parameter (decl.arg2type, decl.arg2name, Parameter.Modifier.NONE, null);
+                       param_list[1] = new Parameter (decl.arg2type, decl.arg2name, Parameter.Modifier.NONE, null, decl.location);
 
                Operator op = new Operator (
                        current_class, decl.optype, decl.ret_type, (int) $2, 
-                       new Parameters (param_list, null, decl.location),
+                       new Parameters (param_list, null),
                        (ToplevelBlock) $5, (Attributes) $1, decl.location);
 
                if (RootContext.Documentation != null) {
@@ -1867,9 +1931,9 @@ operator_declarator
                Parameter [] pars = new Parameter [1];
                Expression type = (Expression) $5;
 
-               pars [0] = new Parameter (type, (string) $6, Parameter.Modifier.NONE, null);
+               pars [0] = new Parameter (type, (string) $6, Parameter.Modifier.NONE, null, lexer.Location);
 
-               current_local_parameters = new Parameters (pars, null, lexer.Location);
+               current_local_parameters = new Parameters (pars, null);
 
                if (RootContext.Documentation != null) {
                        tmpComment = Lexer.consume_doc_comment ();
@@ -1892,10 +1956,10 @@ operator_declarator
                Expression typeL = (Expression) $5;
                Expression typeR = (Expression) $8;
 
-              pars [0] = new Parameter (typeL, (string) $6, Parameter.Modifier.NONE, null);
-              pars [1] = new Parameter (typeR, (string) $9, Parameter.Modifier.NONE, null);
+              pars [0] = new Parameter (typeL, (string) $6, Parameter.Modifier.NONE, null, lexer.Location);
+              pars [1] = new Parameter (typeR, (string) $9, Parameter.Modifier.NONE, null, lexer.Location);
 
-              current_local_parameters = new Parameters (pars, null, lexer.Location);
+              current_local_parameters = new Parameters (pars, null);
 
                if (RootContext.Documentation != null) {
                        tmpComment = Lexer.consume_doc_comment ();
@@ -1914,10 +1978,17 @@ operator_declarator
                type IDENTIFIER
          CLOSE_PARENS
        {
-               Report.Error (1534, lexer.Location, "Overloaded binary operator '{0}' takes two parameters", $3);
+               Report.Error (1534, lexer.Location, "Overloaded binary operator `{0}' takes two parameters",
+                       Operator.GetName ((Operator.OpType) $3));
+               $$ = null;
+       }
+       | type OPERATOR overloadable_operator 
+         OPEN_PARENS CLOSE_PARENS
+       {
+               Report.Error (1535, lexer.Location, "Overloaded unary operator `{0}' takes one parameter",
+                       Operator.GetName ((Operator.OpType) $3));
                $$ = null;
        }
-
        ;
 
 overloadable_operator
@@ -1953,9 +2024,9 @@ conversion_operator_declarator
          {
                Parameter [] pars = new Parameter [1];
 
-               pars [0] = new Parameter ((Expression) $5, (string) $6, Parameter.Modifier.NONE, null);
+               pars [0] = new Parameter ((Expression) $5, (string) $6, Parameter.Modifier.NONE, null, lexer.Location);
 
-               current_local_parameters = new Parameters (pars, null, lexer.Location);  
+               current_local_parameters = new Parameters (pars, null);  
                  
                if (RootContext.Documentation != null) {
                        tmpComment = Lexer.consume_doc_comment ();
@@ -1969,9 +2040,9 @@ conversion_operator_declarator
          {
                Parameter [] pars = new Parameter [1];
 
-               pars [0] = new Parameter ((Expression) $5, (string) $6, Parameter.Modifier.NONE, null);
+               pars [0] = new Parameter ((Expression) $5, (string) $6, Parameter.Modifier.NONE, null, lexer.Location);
 
-               current_local_parameters = new Parameters (pars, null, lexer.Location);  
+               current_local_parameters = new Parameters (pars, null);  
                  
                if (RootContext.Documentation != null) {
                        tmpComment = Lexer.consume_doc_comment ();
@@ -2008,24 +2079,22 @@ constructor_declaration
                if (c.Name == current_container.Basename){
                        if ((c.ModFlags & Modifiers.STATIC) != 0){
                                if ((c.ModFlags & Modifiers.Accessibility) != 0){
-                                       Report.Error (
-                                               515, c.Location, String.Format (
-                                               "`{0}.{1}': static constructor can not have access modifiers",
-                                               c.Name, current_container.Name));
+                                       Report.Error (515, c.Location,
+                                               "`{0}': access modifiers are not allowed on static constructors",
+                                               c.GetSignatureForError ());
                                }
        
                                c.ModFlags = Modifiers.Check (Constructor.AllowedModifiers, (int) $2, Modifiers.PRIVATE, c.Location);   
        
                                if (c.Initializer != null){
-                                       Report.Error (
-                                               514, c.Location, 
-                                               "Static constructors can not have an explicit this or base " +
-                                               "constructor invocations");
+                                       Report.Error (514, c.Location,
+                                               "`{0}': static constructor cannot have an explicit `this' or `base' constructor call",
+                                               c.GetSignatureForError ());
                                }
        
                                if (!c.Parameters.Empty){
-                                       Report.Error (
-                                               132, c.Location, "Static constructors should not have parameters");
+                                       Report.Error (132, c.Location,
+                                               "`{0}': The static constructor must be parameterless", c.GetSignatureForError ());
                                }
                        } else {
                                c.ModFlags = Modifiers.Check (Constructor.AllowedModifiers, (int) $2, Modifiers.PRIVATE, c.Location);
@@ -2075,11 +2144,11 @@ opt_constructor_initializer
 constructor_initializer
        : COLON BASE OPEN_PARENS opt_argument_list CLOSE_PARENS
          {
-               $$ = new ConstructorBaseInitializer ((ArrayList) $4, current_local_parameters, lexer.Location);
+               $$ = new ConstructorBaseInitializer ((ArrayList) $4, lexer.Location);
          }
        | COLON THIS OPEN_PARENS opt_argument_list CLOSE_PARENS
          {
-               $$ = new ConstructorThisInitializer ((ArrayList) $4, current_local_parameters, lexer.Location);
+               $$ = new ConstructorThisInitializer ((ArrayList) $4, lexer.Location);
          }
        | COLON error {
                Report.Error (1018, lexer.Location, "Keyword this or base expected");
@@ -2103,10 +2172,10 @@ destructor_declaration
          }
          IDENTIFIER OPEN_PARENS CLOSE_PARENS block
          {
-               if ((string) $5 != current_container.Basename){
+               if ((string) $5 != current_container.MemberName.Name){
                        Report.Error (574, lexer.Location, "Name of destructor must match name of class");
                } else if (current_container.Kind != Kind.Class){
-                       Report.Error (575, lexer.Location, "Destructors are only allowed in class types");
+                       Report.Error (575, lexer.Location, "Only class types can contain destructor");
                } else {
                        Location l = lexer.Location;
 
@@ -2116,17 +2185,9 @@ destructor_declaration
                        else
                                m |= Modifiers.PROTECTED | Modifiers.OVERRIDE;
                         
-                        if ((m & Modifiers.UNSAFE) != 0){
-                                if (!RootContext.Unsafe){
-                                        Report.Error (227, l,
-                                             "Unsafe code requires the -unsafe command " +
-                                             "line option to be specified");
-                                }
-                        }
-                        
                        Method d = new Destructor (
                                current_class, TypeManager.system_void_expr, m, "Finalize", 
-                               new Parameters (null, null, l), (Attributes) $1, l);
+                               new Parameters (null, null), (Attributes) $1, l);
                        if (RootContext.Documentation != null)
                                d.DocComment = ConsumeStoredComment ();
                  
@@ -2173,15 +2234,15 @@ event_declaration
          CLOSE_BRACE
          {
                Location loc = (Location) $7;
+               MemberName name = (MemberName) $5;
 
                if ($9 == null){
-                       Report.Error (65, lexer.Location, "Event must have both add and remove accesors");
+                       Report.Error (65, lexer.Location, "`{0}.{1}': event property must have both add and remove accessors",
+                               current_container.Name, name);
                        $$ = null;
                } else {
                        Pair pair = (Pair) $9;
                        
-                       MemberName name = (MemberName) $5;
-
                        if (name.TypeArguments != null)
                                syntax_error (lexer.Location, "an event can't have type arguments");
 
@@ -2198,11 +2259,11 @@ event_declaration
                        implicit_value_parameter_type = null;
                }
          }
-       | opt_attributes opt_modifiers EVENT type namespace_or_type_name OPEN_PARENS opt_formal_parameter_list CLOSE_PARENS block {
+       | opt_attributes opt_modifiers EVENT type namespace_or_type_name error {
                MemberName mn = (MemberName) $5;
 
                if (mn.Left != null)
-                       Report.Error (71, lexer.Location, "Explicit implementation of events requires property syntax");
+                       Report.Error (71, lexer.Location, "An explicit interface implementation of an event must use property syntax");
                else 
                        Report.Error (71, lexer.Location, "Event declaration should use property syntax");
 
@@ -2236,11 +2297,11 @@ add_accessor_declaration
                Parameter [] args = new Parameter [1];
                Parameter implicit_value_parameter = new Parameter (
                        implicit_value_parameter_type, "value", 
-                       Parameter.Modifier.NONE, null);
+                       Parameter.Modifier.NONE, null, lexer.Location);
 
                args [0] = implicit_value_parameter;
                
-               current_local_parameters = new Parameters (args, null, lexer.Location);  
+               current_local_parameters = new Parameters (args, null);  
                lexer.EventParsing = false;
          }
           block
@@ -2249,7 +2310,7 @@ add_accessor_declaration
                lexer.EventParsing = true;
          }
        | opt_attributes ADD error {
-               Report.Error (73, lexer.Location, "Add or remove accessor must have a body");
+               Report.Error (73, lexer.Location, "An add or remove accessor must have a body");
                $$ = null;
          }
        | opt_attributes modifiers ADD {
@@ -2264,11 +2325,11 @@ remove_accessor_declaration
                Parameter [] args = new Parameter [1];
                Parameter implicit_value_parameter = new Parameter (
                        implicit_value_parameter_type, "value", 
-                       Parameter.Modifier.NONE, null);
+                       Parameter.Modifier.NONE, null, lexer.Location);
 
                args [0] = implicit_value_parameter;
                
-               current_local_parameters = new Parameters (args, null, lexer.Location);  
+               current_local_parameters = new Parameters (args, null);  
                lexer.EventParsing = false;
          }
           block
@@ -2277,7 +2338,7 @@ remove_accessor_declaration
                lexer.EventParsing = true;
          }
        | opt_attributes REMOVE error {
-               Report.Error (73, lexer.Location, "Add or remove accessor must have a body");
+               Report.Error (73, lexer.Location, "An add or remove accessor must have a body");
                $$ = null;
          }
        | opt_attributes modifiers REMOVE {
@@ -2298,6 +2359,7 @@ indexer_declaration
                parsing_indexer  = true;
                
                indexer_parameters = decl.param_list;
+               iterator_container = SimpleIteratorContainer.GetSimple ();
          }
           accessor_declarations 
          {
@@ -2329,6 +2391,7 @@ indexer_declaration
                indexer = new Indexer (current_class, decl.type, name,
                                       (int) $2, false, decl.param_list, (Attributes) $1,
                                       get_block, set_block, loc);
+
                if (RootContext.Documentation != null)
                        indexer.DocComment = ConsumeStoredComment ();
 
@@ -2382,6 +2445,7 @@ indexer_declarator
 enum_declaration
        : opt_attributes
          opt_modifiers
+         opt_partial
          ENUM IDENTIFIER 
          opt_enum_base {
                if (RootContext.Documentation != null)
@@ -2389,26 +2453,32 @@ enum_declaration
          }
          enum_body
          opt_semicolon
-         { 
+         {
+               bool partial = (bool) $3;
+
+               if (partial) {
+                       Report.Error (267, lexer.Location, "The partial modifier can only appear immediately before `class', `struct' or `interface'");
+                       break;  // assumes that the parser put us in a switch
+               }
+
                Location enum_location = lexer.Location;
 
-               MemberName full_name = MakeName (new MemberName ((string) $4));
-               Enum e = new Enum (current_namespace, current_class, (Expression) $5, (int) $2,
-                                  full_name, (Attributes) $1, enum_location);
+               MemberName name = MakeName (new MemberName ((string) $5));
+               Enum e = new Enum (current_namespace, current_class, (Expression) $6, (int) $2,
+                                  name, (Attributes) $1, enum_location);
                
                if (RootContext.Documentation != null)
                        e.DocComment = enumTypeComment;
 
-               foreach (VariableDeclaration ev in (ArrayList) $7) {
+               foreach (VariableDeclaration ev in (ArrayList) $8) {
                        e.AddEnumMember (ev.identifier, 
                                         (Expression) ev.expression_or_array_initializer,
                                         ev.Location, ev.OptAttributes,
                                         ev.DocComment);
                }
 
-               string name = full_name.GetName ();
                current_container.AddEnum (e);
-               RootContext.Tree.RecordDecl (name, e);
+               RootContext.Tree.RecordDecl (current_namespace.NS, name, e);
                $$ = e;
 
          }
@@ -2494,13 +2564,17 @@ enum_member_declaration
 delegate_declaration
        : opt_attributes
          opt_modifiers
-         DELEGATE type member_name
+         DELEGATE
+         {
+               lexer.ConstraintsParsing = true;
+         }
+         type member_name
          OPEN_PARENS opt_formal_parameter_list CLOSE_PARENS
          {
                Location l = lexer.Location;
-               MemberName name = MakeName ((MemberName) $5);
-               Delegate del = new Delegate (current_namespace, current_class, (Expression) $4,
-                                            (int) $2, name, (Parameters) $7, (Attributes) $1, l);
+               MemberName name = MakeName ((MemberName) $6);
+               Delegate del = new Delegate (current_namespace, current_class, (Expression) $5,
+                                            (int) $2, name, (Parameters) $8, (Attributes) $1, l);
 
                if (RootContext.Documentation != null) {
                        del.DocComment = Lexer.consume_doc_comment ();
@@ -2508,11 +2582,9 @@ delegate_declaration
                }
 
                current_container.AddDelegate (del);
-               RootContext.Tree.RecordDecl (name.GetName (true), del);
+               RootContext.Tree.RecordDecl (current_namespace.NS, name, del);
 
                current_delegate = del;
-
-               lexer.ConstraintsParsing = true;
          }
          opt_type_parameter_constraints_clauses
          {
@@ -2520,7 +2592,7 @@ delegate_declaration
          }
          SEMICOLON
          {
-               current_delegate.SetParameterInfo ((ArrayList) $9);
+               current_delegate.SetParameterInfo ((ArrayList) $10);
                $$ = current_delegate;
 
                current_delegate = null;
@@ -2871,7 +2943,7 @@ argument_list
                $$ = list;
          }
        | argument_list error {
-               CheckToken (1026, yyToken, ", or ) expected");
+               CheckToken (1026, yyToken, "Expected `,' or `)'");
          }
        ;
 
@@ -3027,7 +3099,7 @@ array_creation_expression
          }          
        | NEW type error 
          {
-               Report.Error (1526, lexer.Location, "new expression requires () or [] after type");
+               Report.Error (1526, lexer.Location, "new expression requires () or [] after type");
          }
        ;
 
@@ -3218,7 +3290,7 @@ anonymous_method_expression
                Location loc = (Location) $3;
                top_current_block = (Block) oob_stack.Pop ();
                current_block = (Block) oob_stack.Pop ();
-                       if (RootContext.Version == LanguageVersion.ISO_1){
+               if (RootContext.Version == LanguageVersion.ISO_1){
                                Report.FeatureIsNotStandardized (lexer.Location, "anonymous methods");
                                $$ = null;
                } else  {
@@ -3246,7 +3318,7 @@ anonymous_method_signature
                        ArrayList par_list = (ArrayList) $2;
                        Parameter [] pars = new Parameter [par_list.Count];
                        par_list.CopyTo (pars);
-                       $$ = new Parameters (pars, null, lexer.Location);
+                       $$ = new Parameters (pars, null);
                }
          }
        ;
@@ -3273,10 +3345,10 @@ anonymous_method_parameter_list
 
 anonymous_method_parameter
        : opt_parameter_modifier type IDENTIFIER {
-               $$ = new Parameter ((Expression) $2, (string) $3, (Parameter.Modifier) $1, null);
+               $$ = new Parameter ((Expression) $2, (string) $3, (Parameter.Modifier) $1, null, lexer.Location);
          }
        | PARAMS type IDENTIFIER {
-               Report.Error (1670, lexer.Location, "params modifier not allowed in anonymous method declaration");
+               Report.Error (1670, lexer.Location, "The `params' modifier is not allowed in anonymous method declaration");
                $$ = null;
          }
        ;
@@ -3419,16 +3491,23 @@ shift_expression
 
 opt_error
        : /* empty */
+         {
+               $$ = false;
+         }
        | error
          {
                lexer.PutbackNullable ();
+               $$ = true;
          }
        ;
 
 nullable_type_or_conditional
        : type opt_error
          {
-               $$ = $1;
+               if (((bool) $2) && ($1 is ComposedCast))
+                       $$ = ((ComposedCast) $1).RemoveNullable ();
+               else
+                       $$ = $1;
          }
        ;
 
@@ -3644,9 +3723,13 @@ class_declaration
        : opt_attributes
          opt_modifiers
          opt_partial
-         CLASS member_name
+         CLASS
+         {
+               lexer.ConstraintsParsing = true;
+         }
+         member_name
          {
-               MemberName name = MakeName ((MemberName) $5);
+               MemberName name = MakeName ((MemberName) $6);
                bool partial = (bool) $3;
                int mod_flags = (int) $2;
 
@@ -3670,26 +3753,24 @@ class_declaration
 
                        current_container.AddClassOrStruct (current_class);
                        current_container = current_class;
-                       RootContext.Tree.RecordDecl (name.GetName (true), current_class);
+                       RootContext.Tree.RecordDecl (current_namespace.NS, name, current_class);
                }
-
-               lexer.ConstraintsParsing = true;
          }
          opt_class_base
          opt_type_parameter_constraints_clauses
          {
                lexer.ConstraintsParsing = false;
 
-               if ($7 != null) {
+               if ($8 != null) {
                        if (current_class.Name == "System.Object") {
                                Report.Error (537, current_class.Location,
                                              "The class System.Object cannot have a base " +
                                              "class or implement an interface.");
                        }
-                       current_class.Bases = (ArrayList) $7;
+                       current_class.Bases = (ArrayList) $8;
                }
 
-               current_class.SetParameterInfo ((ArrayList) $8);
+               current_class.SetParameterInfo ((ArrayList) $9);
 
                if (RootContext.Documentation != null) {
                        current_class.DocComment = Lexer.consume_doc_comment ();
@@ -3728,7 +3809,7 @@ modifiers
 
                if ((m1 & m2) != 0) {
                        Location l = lexer.Location;
-                       Report.Error (1004, l, "Duplicate modifier: `" + Modifiers.Name (m2) + "'");
+                       Report.Error (1004, l, "Duplicate `{0}' modifier", Modifiers.Name (m2));
                }
                $$ = (int) (m1 | m2);
          }
@@ -3833,8 +3914,7 @@ block
                        current_block = new ToplevelBlock ((ToplevelBlock) top_current_block, current_local_parameters, lexer.Location);
                        top_current_block = current_block;
                } else {
-                       current_block = new Block (current_block, current_local_parameters,
-                                                  lexer.Location, Location.Null);
+                       current_block = new Block (current_block, lexer.Location, Location.Null);
                }
          } 
          opt_statement_list CLOSE_BRACE 
@@ -3894,12 +3974,12 @@ embedded_statement
        : valid_declaration_statement
        | declaration_statement
          {
-                 Report.Error (1023, lexer.Location, "An embedded statement may not be a declaration.");
+                 Report.Error (1023, lexer.Location, "An embedded statement may not be a declaration or labeled statement");
                  $$ = null;
          }
        | labeled_statement
          {
-                 Report.Error (1023, lexer.Location, "An embedded statement may not be a labeled statement.");
+                 Report.Error (1023, lexer.Location, "An embedded statement may not be a declaration or labeled statement");
                  $$ = null;
          }
        ;
@@ -4246,8 +4326,7 @@ for_statement
 
                                LocalInfo vi;
 
-                               vi = current_block.AddVariable (
-                                       type, decl.identifier, current_local_parameters, decl.Location);
+                               vi = current_block.AddVariable (type, decl.identifier, decl.Location);
                                if (vi == null)
                                        continue;
 
@@ -4357,9 +4436,9 @@ foreach_statement
                Location l = lexer.Location;
                LocalInfo vi;
 
-               vi = foreach_block.AddVariable ((Expression) $3, (string) $4, current_local_parameters, l);
+               vi = foreach_block.AddVariable ((Expression) $3, (string) $4, l);
                if (vi != null) {
-                       vi.ReadOnly = true;
+                       vi.SetReadOnlyContext (LocalInfo.ReadOnlyContext.Foreach);
 
                        // Get a writable reference to this read-only variable.
                        //
@@ -4413,7 +4492,7 @@ continue_statement
 goto_statement
        : GOTO IDENTIFIER SEMICOLON 
          {
-               $$ = new Goto (current_block, (string) $2, lexer.Location);
+               $$ = new Goto ((string) $2, lexer.Location);
          }
        | GOTO CASE constant_expression SEMICOLON
          {
@@ -4500,7 +4579,7 @@ try_statement
                        Catch cc = (Catch) c [i];
                        if (cc.IsGeneral) {
                                if (i != c.Count - 1)
-                                       Report.Error (1017, cc.loc, "Empty catch block must be the last in a series of catch blocks");
+                                       Report.Error (1017, cc.loc, "Try statement already has an empty catch block");
                                g = cc;
                                c.RemoveAt (i);
                                i--;
@@ -4633,10 +4712,7 @@ unchecked_statement
 unsafe_statement
        : UNSAFE 
        {
-               if (!RootContext.Unsafe){
-                       Report.Error (227, lexer.Location, 
-                               "Unsafe code can only be used if --unsafe is used");
-               }
+               RootContext.CheckUnsafeOption (lexer.Location);
        } block {
                $$ = new Unsafe ((Block) $3);
        }
@@ -4659,11 +4735,11 @@ fixed_statement
                        Pair p = (Pair) list [i];
                        LocalInfo v;
 
-                       v = current_block.AddVariable (type, (string) p.First,current_local_parameters, l);
+                       v = current_block.AddVariable (type, (string) p.First, l);
                        if (v == null)
                                continue;
 
-                       v.ReadOnly = true;
+                       v.SetReadOnlyContext (LocalInfo.ReadOnlyContext.Fixed);
                        v.Pinned = true;
                        p.First = v;
                        list [i] = p;
@@ -4744,12 +4820,10 @@ using_statement
 
                        foreach (VariableDeclaration decl in var_declarators){
 
-                               LocalInfo vi    = current_block.AddVariable (
-                                       type, decl.identifier, 
-                                       current_local_parameters, decl.Location);
+                               LocalInfo vi = current_block.AddVariable (type, decl.identifier, decl.Location);
                                if (vi == null)
                                        continue;
-                               vi.ReadOnly = true;
+                               vi.SetReadOnlyContext (LocalInfo.ReadOnlyContext.Using);
 
                                Expression expr;
                                if (decl.expression_or_array_initializer is Expression){
@@ -4840,15 +4914,10 @@ public class InterfaceAccessorInfo {
         public InterfaceAccessorInfo (bool has_get, bool has_set,
                                       Attributes get_attrs, Attributes set_attrs, int get_mod, int set_mod, Location get_loc, Location set_loc)
         {
-               if (get_mod != 0)
-                       Report.Error (275, get_loc, "Accessibility modifiers can not be used on accessors in interfaces");
-               if (set_mod != 0)
-                       Report.Error (275, set_loc, "Accessibility modifiers can not be used on accessors in interfaces");
-                       
                if (has_get)
-                       Get = new Accessor (null, 0, get_attrs, get_loc);
+                       Get = new Accessor (null, get_mod, get_attrs, get_loc);
                if (has_set)
-                       Set = new Accessor (null, 0, set_attrs, set_loc);
+                       Set = new Accessor (null, set_mod, set_attrs, set_loc);
         }
 
 }
@@ -4917,7 +4986,7 @@ public class OperatorDeclaration {
 void Error_ExpectingTypeName (Location l, Expression expr)
 {
        if (expr is Invocation){
-               Report.Error (1002, l, "; expected");
+               Report.Error (1002, l, "Expecting `;'");
        } else {
                Report.Error (-1, l, "Invalid Type definition");
        }
@@ -4947,11 +5016,11 @@ TypeContainer pop_current_class ()
 MemberName
 MakeName (MemberName class_name)
 {
-       string ns = current_namespace.FullName;
+       Namespace ns = current_namespace.NS;
 
        if (current_container.Name == ""){
-               if (ns != "")
-                       return new MemberName (new MemberName (ns), class_name);
+               if (ns.Name != "")
+                       return new MemberName (ns.MemberName, class_name);
                else
                        return class_name;
        } else {
@@ -4986,7 +5055,7 @@ Block declare_local_variables (Expression type, ArrayList variable_declarators,
 
        foreach (VariableDeclaration decl in variable_declarators){
 
-               if (implicit_block.AddVariable (type, decl.identifier, current_local_parameters, decl.Location) != null) {
+               if (implicit_block.AddVariable (type, decl.identifier, decl.Location) != null) {
                        if (decl.expression_or_array_initializer != null){
                                if (inits == null)
                                        inits = new ArrayList (4);
@@ -5032,8 +5101,7 @@ Block declare_local_constants (Expression type, ArrayList declarators)
                implicit_block = current_block;
 
        foreach (VariableDeclaration decl in declarators){
-               implicit_block.AddConstant (type, decl.identifier, (Expression) decl.expression_or_array_initializer,
-                                                 current_local_parameters, decl.Location);
+               implicit_block.AddConstant (type, decl.identifier, (Expression) decl.expression_or_array_initializer, decl.Location);
        }
        
        return implicit_block;
@@ -5112,11 +5180,6 @@ void syntax_error (Location l, string msg)
        Report.Error (1003, l, "Syntax error, " + msg);
 }
 
-void output (string s)
-{
-       Console.WriteLine (s);
-}
-
 void note (string s)
 {
        // Used to put annotations
@@ -5163,6 +5226,8 @@ public void parse ()
                if (yacc_verbose_flag > 0)
                        Console.WriteLine (e);
        }
+
+       RootContext.Tree.Types.NamespaceEntry = null;
 }
 
 void CheckToken (int error, int yyToken, string msg)