2005-11-07 Miguel de Icaza <miguel@novell.com>
[mono.git] / mcs / gmcs / cs-parser.jay
index e6b9826d4d50fbd8e4c87bb5b16a26180f42eb61..125e65d57e580dac4396a9131bdc8c9a8c23962d 100644 (file)
@@ -315,10 +315,31 @@ outer_declarations
         ;
  
 outer_declaration
-        : using_directive
+       : extern_alias_directive
+        | using_directive 
         | namespace_member_declaration
         ;
-  
+
+extern_alias_directives
+       : extern_alias_directive
+       | extern_alias_directives extern_alias_directive;
+
+extern_alias_directive
+       : EXTERN IDENTIFIER IDENTIFIER SEMICOLON
+         {
+               LocatedToken lt = (LocatedToken) $2;
+               string s = lt.Value;
+               if (s != "alias"){
+                       Report.Error (1003, lt.Location, "'alias' expected");
+               } else if (RootContext.Version == LanguageVersion.ISO_1) {
+                       Report.FeatureIsNotStandardized (lt.Location, "external alias");
+               } else {
+                       lt = (LocatedToken) $3; 
+                       current_namespace.UsingExternalAlias (lt.Value, lt.Location);
+               }
+         }
+       ;
 using_directives
        : using_directive 
        | using_directives using_directive
@@ -343,6 +364,7 @@ using_alias_directive
          {
                LocatedToken lt = (LocatedToken) $2;
                current_namespace.UsingAlias (lt.Value, (MemberName) $4, (Location) $1);
+               current_namespace.UsingFound = true;
          }
        | USING error {
                CheckIdentifierToken (yyToken, GetLocation ($2));
@@ -353,6 +375,7 @@ using_namespace_directive
        : USING namespace_name SEMICOLON 
          {
                current_namespace.Using ((MemberName) $2, (Location) $1);
+               current_namespace.UsingFound = true;
           }
        ;
 
@@ -409,6 +432,7 @@ namespace_body
                if (RootContext.Documentation != null)
                        Lexer.doc_state = XmlCommentState.Allowed;
          }
+         opt_extern_alias_directives
          opt_using_directives
          opt_namespace_member_declarations
          CLOSE_BRACE
@@ -419,6 +443,11 @@ opt_using_directives
        | using_directives
        ;
 
+opt_extern_alias_directives
+       : /* empty */
+       | extern_alias_directives
+       ;
+
 opt_namespace_member_declarations
        : /* empty */
        | namespace_member_declarations
@@ -1098,7 +1127,8 @@ method_header
 
                GenericMethod generic = null;
                if (name.TypeArguments != null) {
-                       generic = new GenericMethod (current_namespace, current_class, name);
+                       generic = new GenericMethod (current_namespace, current_class, name,
+                                                    (Expression) $3, (Parameters) $6);
 
                        generic.SetParameterInfo ((ArrayList) $9);
                }
@@ -1133,7 +1163,8 @@ method_header
                Method method;
                GenericMethod generic = null;
                if (name.TypeArguments != null) {
-                       generic = new GenericMethod (current_namespace, current_class, name);
+                       generic = new GenericMethod (current_namespace, current_class, name,
+                                                    TypeManager.system_void_expr, (Parameters) $6);
 
                        generic.SetParameterInfo ((ArrayList) $9);
                }
@@ -1711,7 +1742,8 @@ interface_method_declaration
 
                GenericMethod generic = null;
                if (name.TypeArguments != null) {
-                       generic = new GenericMethod (current_namespace, current_class, name);
+                       generic = new GenericMethod (current_namespace, current_class, name,
+                                                    (Expression) $3, (Parameters) $6);
 
                        generic.SetParameterInfo ((ArrayList) $9);
                }
@@ -1739,7 +1771,8 @@ interface_method_declaration
 
                GenericMethod generic = null;
                if (name.TypeArguments != null) {
-                       generic = new GenericMethod (current_namespace, current_class, name);
+                       generic = new GenericMethod (current_namespace, current_class, name,
+                                                    TypeManager.system_void_expr, (Parameters) $6);
 
                        generic.SetParameterInfo ((ArrayList) $9);
                }
@@ -2743,11 +2776,17 @@ non_expression_type
          }
        | non_expression_type rank_specifier
          {
-               $$ = new ComposedCast ((Expression) $1, (string) $2);
+               Location loc = GetLocation ($1);
+               if (loc.IsNull)
+                       loc = lexer.Location;
+               $$ = new ComposedCast ((Expression) $1, (string) $2, loc);
          }
        | non_expression_type STAR
          {
-               $$ = new ComposedCast ((Expression) $1, "*");
+               Location loc = GetLocation ($1);
+               if (loc.IsNull)
+                       loc = lexer.Location;
+               $$ = new ComposedCast ((Expression) $1, "*", loc);
          }
        | expression rank_specifiers 
          {
@@ -4124,7 +4163,7 @@ local_variable_pointer_type
          }
         | builtin_types STAR
          {
-               $$ = new ComposedCast ((Expression) $1, "*");
+               $$ = new ComposedCast ((Expression) $1, "*", lexer.Location);
          }
         | VOID STAR
          {