2006-11-20 Marek Safar <marek.safar@gmail.com>
authorMarek Safar <marek.safar@gmail.com>
Mon, 20 Nov 2006 18:13:03 +0000 (18:13 -0000)
committerMarek Safar <marek.safar@gmail.com>
Mon, 20 Nov 2006 18:13:03 +0000 (18:13 -0000)
* cs-tokenizer.cs,
* cs-parser.jay: Better error message when partial keyword is misplaced.

svn path=/trunk/mcs/; revision=68205

mcs/mcs/ChangeLog
mcs/mcs/cs-parser.jay
mcs/mcs/cs-tokenizer.cs

index 8c40efdd8ced95863f2b4f3783cb6918c1a8a07d..003b2f5e5d73ca61bf5eb5114f3bef7684c3e7dd 100644 (file)
@@ -1,3 +1,8 @@
+2006-11-20  Marek Safar  <marek.safar@gmail.com>
+
+       * cs-tokenizer.cs,
+       * cs-parser.jay: Better error message when partial keyword is misplaced.
+
 2006-11-19  Gert Driesen  <drieseng@users.sourceforge.net>
 
        A fix for bug #79810
index 4432bd6d660dc4dac9184dc5a915e1964722b71d..92ab90e648f1bc203a64b548ca221bfe954df465 100644 (file)
@@ -2367,7 +2367,6 @@ indexer_declarator
 enum_declaration
        : opt_attributes
          opt_modifiers
-         opt_partial
          ENUM IDENTIFIER 
          opt_enum_base {
                if (RootContext.Documentation != null)
@@ -2376,16 +2375,11 @@ enum_declaration
          enum_body
          opt_semicolon
          {
-               LocatedToken lt = (LocatedToken) $5;
+               LocatedToken lt = (LocatedToken) $4;
                Location enum_location = lt.Location;
 
-               if ($3 != null) {
-                       Report.Error (267, lt.Location, "The partial modifier can only appear immediately before `class', `struct' or `interface'");
-                       break;  // assumes that the parser put us in a switch
-               }
-
                MemberName name = MakeName (new MemberName (lt.Value, enum_location));
-               Enum e = new Enum (current_namespace, current_class, (Expression) $6, (int) $2,
+               Enum e = new Enum (current_namespace, current_class, (Expression) $5, (int) $2,
                                   name, (Attributes) $1);
                
                if (RootContext.Documentation != null)
@@ -2393,7 +2387,7 @@ enum_declaration
 
 
                EnumMember em = null;
-               foreach (VariableDeclaration ev in (ArrayList) $8) {
+               foreach (VariableDeclaration ev in (ArrayList) $7) {
                        em = new EnumMember (e, em, (Expression) ev.expression_or_array_initializer,
                                new MemberName (ev.identifier, ev.Location), ev.OptAttributes);
 
@@ -3571,7 +3565,7 @@ opt_modifiers
        : /* empty */           { $$ = (int) 0; }
        | modifiers
        ;
-
+       
 modifiers
        : modifier
        | modifiers modifier
@@ -3585,7 +3579,7 @@ modifiers
                }
                $$ = (int) (m1 | m2);
          }
-        ;
+      ;
 
 modifier
        : NEW                   { $$ = Modifiers.NEW; }
index 4efc236f228990c17aafe269103672038071443a..9e4fcc5220e610b4dff50fec4a49f0ac409b1e2e 100644 (file)
@@ -1866,8 +1866,7 @@ namespace Mono.CSharp
                                int next_token = token ();
                                bool ok = (next_token == Token.CLASS) ||
                                        (next_token == Token.STRUCT) ||
-                                       (next_token == Token.INTERFACE) ||
-                                       (next_token == Token.ENUM); // "partial" is a keyword in 'partial enum', even though it's not valid
+                                       (next_token == Token.INTERFACE);
 
                                reader.Position = old;
                                ref_line = old_ref_line;
@@ -1876,10 +1875,10 @@ namespace Mono.CSharp
 
                                if (ok)
                                        return res;
-                               else {
-                                       val = new LocatedToken (Location, "partial");
-                                       return Token.IDENTIFIER;
-                               }
+
+                               Report.Error (267, Location, "The `partial' modifier can be used only immediately before keyword `class', `struct', or `interface'");
+                               val = new LocatedToken (Location, "partial");
+                               return Token.IDENTIFIER;
                        }
 
                        return res;