This commit was manufactured by cvs2svn to create branch 'mono-1-0'.
[mono.git] / mcs / gmcs / cs-tokenizer.cs
index 06d76c630867eac19884039e1fe10930a1fcac86..0fdc84b6ce5fe49dc9c9f9832b9d4ac230b0fd3b 100755 (executable)
@@ -1,3 +1,4 @@
+// -*- coding: dos -*-\r
 //\r
 // cs-tokenizer.cs: The Tokenizer for the C# compiler\r
 //                  This also implements the preprocessor\r
@@ -41,7 +42,6 @@ namespace Mono.CSharp
                bool handle_remove_add = false;\r
                bool handle_assembly = false;\r
                bool handle_constraints = false;\r
-               bool handle_typeof = false;\r
 \r
                //\r
                // Whether tokens have been seen on this line\r
@@ -144,16 +144,6 @@ namespace Mono.CSharp
                                handle_constraints = value;\r
                        }\r
                }\r
-\r
-               public bool TypeOfParsing {\r
-                       get {\r
-                               return handle_typeof;\r
-                       }\r
-\r
-                       set {\r
-                               handle_typeof = value;\r
-                       }\r
-               }\r
                \r
                //\r
                // Class variables\r
@@ -313,7 +303,6 @@ namespace Mono.CSharp
                        AddKeyword ("volatile", Token.VOLATILE);\r
                        AddKeyword ("where", Token.WHERE);\r
                        AddKeyword ("while", Token.WHILE);\r
-                       AddKeyword ("partial", Token.PARTIAL);\r
                }\r
 \r
                //\r
@@ -352,7 +341,6 @@ namespace Mono.CSharp
                                return -1;\r
                        if (handle_constraints == false && res == Token.WHERE)\r
                                return -1;\r
-\r
                        return res;\r
                        \r
                }\r
@@ -406,37 +394,21 @@ namespace Mono.CSharp
                static bool is_identifier_part_character (char c)\r
                {\r
                        return (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') || c == '_' || (c >= '0' && c <= '9') || Char.IsLetter (c);\r
-               }\r
-               \r
-               public static bool IsValidIdentifier (string s)\r
-               {\r
-                       if (s == null || s.Length == 0)\r
-                               return false;\r
-                       \r
-                       if (!is_identifier_start_character (s [0]))\r
-                               return false;\r
-                       \r
-                       for (int i = 1; i < s.Length; i ++)\r
-                               if (! is_identifier_part_character (s [i]))\r
-                                       return false;\r
-                       \r
-                       return true;\r
-               }\r
-\r
-               bool parse_generic_dimension (out int dimension)\r
-               {\r
-                       dimension = 1;\r
-\r
-               again:\r
-                       int the_token = token ();\r
-                       if (the_token == Token.OP_GENERICS_GT)\r
-                               return true;\r
-                       else if (the_token == Token.COMMA) {\r
-                               dimension++;\r
-                               goto again;\r
-                       }\r
-\r
-                       return false;\r
+               }
+               
+               public static bool IsValidIdentifier (string s)
+               {
+                       if (s == null || s.Length == 0)
+                               return false;
+                       
+                       if (!is_identifier_start_character (s [0]))
+                               return false;
+                       
+                       for (int i = 1; i < s.Length; i ++)
+                               if (! is_identifier_part_character (s [i]))
+                                       return false;
+                       
+                       return true;
                }\r
 \r
                bool parse_less_than ()\r
@@ -477,14 +449,6 @@ namespace Mono.CSharp
                                if (!parse_less_than ())\r
                                        return false;\r
                                goto again;\r
-                       } else if (the_token == Token.OPEN_BRACKET) {\r
-                       rank_specifiers:\r
-                               the_token = token ();\r
-                               if (the_token == Token.CLOSE_BRACKET)\r
-                                       goto again;\r
-                               else if (the_token == Token.COMMA)\r
-                                       goto rank_specifiers;\r
-                               return false;\r
                        }\r
 \r
                        return false;\r
@@ -549,19 +513,8 @@ namespace Mono.CSharp
                                if (parsing_generic_less_than++ > 0)\r
                                        return Token.OP_GENERICS_LT;\r
 \r
-                               int old = reader.Position;\r
-                               if (handle_typeof) {\r
-                                       int dimension;\r
-                                       if (parse_generic_dimension (out dimension)) {\r
-                                               val = dimension;\r
-                                               return Token.GENERIC_DIMENSION;\r
-                                       }\r
-                                       reader.Position = old;\r
-                                       putback_char = -1;\r
-                               }\r
-\r
                                // Save current position and parse next token.\r
-                               old = reader.Position;\r
+                               int old = reader.Position;\r
                                bool is_generic_lt = parse_less_than ();\r
                                reader.Position = old;\r
                                putback_char = -1;\r
@@ -799,12 +752,15 @@ namespace Mono.CSharp
                                                break;\r
 \r
                                        case 'l':\r
-                                               if (!is_unsigned && (RootContext.WarningLevel >= 4)){\r
+                                               if (!is_unsigned){\r
                                                        //\r
                                                        // if we have not seen anything in between\r
                                                        // report this error\r
                                                        //\r
-                                                       Report.Warning (78, Location, "The 'l' suffix is easily confused with the digit '1' (use 'L' for clarity)");\r
+                                                       Report.Warning (\r
+                                                               78, Location,\r
+                                                       "the 'l' suffix is easily confused with digit `1'," +\r
+                                                       " use 'L' for clarity");\r
                                                }\r
                                                goto case 'L';\r
                                                \r
@@ -1597,7 +1553,7 @@ namespace Mono.CSharp
                        switch (cmd){\r
                        case "pragma":\r
                                if (RootContext.V2)\r
-                                       return caller_is_taking;\r
+                                       return true;\r
                                break;\r
                                \r
                        case "line":\r
@@ -1605,7 +1561,7 @@ namespace Mono.CSharp
                                        Report.Error (\r
                                                1576, Location,\r
                                                "Argument to #line directive is missing or invalid");\r
-                               return caller_is_taking;\r
+                               return true;\r
 \r
                        case "region":\r
                                region_directive = true;\r
@@ -1765,7 +1721,7 @@ namespace Mono.CSharp
                                return true;\r
 \r
                        case "warning":\r
-                               Report.Warning (1030, Location, "#warning: '{0}'", arg);\r
+                               Report.Warning (1030, Location, "#warning: '" + arg + "'");\r
                                return true;\r
                        }\r
 \r
@@ -1812,36 +1768,6 @@ namespace Mono.CSharp
                        return Token.EOF;\r
                }\r
 \r
-               private int consume_identifier (int s)\r
-               {\r
-                       int res = consume_identifier (s, false);\r
-\r
-                       if (res == Token.PARTIAL) {\r
-                               // Save current position and parse next token.\r
-                               int old = reader.Position;\r
-                               int old_putback = putback_char;\r
-\r
-                               putback_char = -1;\r
-\r
-                               int next_token = token ();\r
-                               bool ok = (next_token == Token.CLASS) ||\r
-                                       (next_token == Token.STRUCT) ||\r
-                                       (next_token == Token.INTERFACE);\r
-\r
-                               reader.Position = old;\r
-                               putback_char = old_putback;\r
-\r
-                               if (ok)\r
-                                       return res;\r
-                               else {\r
-                                       val = "partial";\r
-                                       return Token.IDENTIFIER;\r
-                               }\r
-                       }\r
-\r
-                       return res;\r
-               }\r
-\r
                private int consume_identifier (int s, bool quoted) \r
                {\r
                        int pos = 1;\r
@@ -1869,9 +1795,9 @@ namespace Mono.CSharp
                        // Optimization: avoids doing the keyword lookup\r
                        // on uppercase letters and _\r
                        //\r
-                       if (!quoted && (s >= 'a' || s == '_')){\r
+                       if (s >= 'a' || s == '_'){\r
                                int keyword = GetKeyword (id_builder, pos);\r
-                               if (keyword != -1)\r
+                               if (keyword != -1 && !quoted)\r
                                return keyword;\r
                        }\r
 \r
@@ -2038,7 +1964,7 @@ namespace Mono.CSharp
 \r
                        if (is_identifier_start_character ((char)c)){\r
                                tokens_seen = true;\r
-                                       return consume_identifier (c);\r
+                               return consume_identifier (c, false);\r
                        }\r
 \r
                is_punct_label:\r