In mcs and gmcs:
[mono.git] / mcs / mcs / cs-tokenizer.cs
index 657a57980cf7de20c9507a850814cd4cc313cc3d..c94047322cf4444794735fb0e6dc442a7ca07b5e 100644 (file)
@@ -405,7 +405,7 @@ namespace Mono.CSharp
                        // FIXME: This could be `Location.Push' but we have to
                        // find out why the MS compiler allows this
                        //
-                       Mono.CSharp.Location.Push (file, 0);
+                       Mono.CSharp.Location.Push (file);
                }
 
                static bool is_identifier_start_character (char c)
@@ -696,12 +696,12 @@ namespace Mono.CSharp
                        return seen_digits;
                }
 
-               bool is_hex (int e)
+               static bool is_hex (int e)
                {
                        return (e >= '0' && e <= '9') || (e >= 'A' && e <= 'F') || (e >= 'a' && e <= 'f');
                }
                                
-               int real_type_suffix (int c)
+               static int real_type_suffix (int c)
                {
                        int t;
 
@@ -743,7 +743,7 @@ namespace Mono.CSharp
                                                        // if we have not seen anything in between
                                                        // report this error
                                                        //
-                                                       Report.Warning (78, Location, "The 'l' suffix is easily confused with the digit '1' (use 'L' for clarity)");
+                                                       Report.Warning (78, 4, Location, "The 'l' suffix is easily confused with the digit '1' (use 'L' for clarity)");
                                                }
                                                //
                                                // This goto statement causes the MS CLR 2.0 beta 1 csc to report an error, so
@@ -835,6 +835,11 @@ namespace Mono.CSharp
                                val = 0ul;
                                return Token.LITERAL_INTEGER;
                        }
+                       catch (FormatException) {
+                               Report.Error (1013, Location, "Invalid number");
+                               val = 0ul;
+                               return Token.LITERAL_INTEGER;
+                       }
                }
                
                int adjust_real (int t)
@@ -853,7 +858,7 @@ namespace Mono.CSharp
                                break;
                        case Token.LITERAL_FLOAT:
                                try {
-                                       val = (float) System.Double.Parse (s, styles, csharp_format_info);
+                                       val = float.Parse (s, styles, csharp_format_info);
                                } catch (OverflowException) {
                                        val = 0.0f;     
                                        Report.Error (594, Location, error_details, "float");
@@ -1077,7 +1082,7 @@ namespace Mono.CSharp
                                        goto default;
                                return v;
                        default:
-                               Report.Error (1009, Location, "Unrecognized escape sequence `\\{0}'", (char)d);
+                               Report.Error (1009, Location, "Unrecognized escape sequence `\\{0}'", ((char)d).ToString ());
                                return d;
                        }
                        getChar ();
@@ -1155,7 +1160,7 @@ namespace Mono.CSharp
                        return val;
                }
 
-               bool IsCastToken (int token)
+               static bool IsCastToken (int token)
                {
                        switch (token) {
                        case Token.BANG:
@@ -1265,13 +1270,13 @@ namespace Mono.CSharp
                //
                bool PreProcessLine (string arg)
                {
-                       if (arg == "")
+                       if (arg.Length == 0)
                                return false;
 
                        if (arg == "default"){
                                ref_line = line;
                                ref_name = file_name;
-                               Location.Push (ref_name, line);
+                               Location.Push (ref_name);
                                return true;
                        } else if (arg == "hidden"){
                                //
@@ -1293,7 +1298,7 @@ namespace Mono.CSharp
                                        ref_name = Location.LookupFile (name);
                                        file_name.HasLineDirective = true;
                                        ref_name.HasLineDirective = true;
-                                       Location.Push (ref_name, ref_line);
+                                       Location.Push (ref_name);
                                } else {
                                        ref_line = System.Int32.Parse (arg);
                                }
@@ -1309,7 +1314,7 @@ namespace Mono.CSharp
                //
                void PreProcessDefinition (bool is_define, string arg)
                {
-                       if (arg == "" || arg == "true" || arg == "false"){
+                       if (arg.Length == 0 || arg == "true" || arg == "false"){
                                Report.Error (1001, Location, "Missing identifer to pre-processor directive");
                                return;
                        }
@@ -1375,7 +1380,7 @@ namespace Mono.CSharp
                                Hashtable w_table = Report.warning_ignore_table;
                                foreach (int code in codes) {
                                        if (w_table != null && w_table.Contains (code))
-                                               Report.Warning (1635, 1, Location, "Cannot restore warning 'CS{0:0000}' because it was disabled globally", code);
+                                               Report.Warning (1635, 1, Location, String.Format ("Cannot restore warning `CS{0:0000}' because it was disabled globally", code));
                                        Report.RegisterWarningRegion (Location).WarningEnable (Location, code);
                                }
                                return;
@@ -1399,7 +1404,7 @@ namespace Mono.CSharp
                                        values[index++] = int.Parse (string_code, System.Globalization.CultureInfo.InvariantCulture);
                                }
                                catch (FormatException) {
-                                       Report.Warning (1692, Location, "Invalid number");
+                                       Report.Warning (1692, 1, Location, "Invalid number");
                                }
                        }
                        return values;
@@ -1637,13 +1642,13 @@ namespace Mono.CSharp
                                goto case "endif";
                                
                        case "if":
-                               if (arg == ""){
+                               if (arg.Length == 0){
                                        Error_InvalidDirective ();
                                        return true;
                                }
                                bool taking = false;
                                if (ifstack == null)
-                                       ifstack = new Stack ();
+                                       ifstack = new Stack (2);
 
                                if (ifstack.Count == 0){
                                        taking = true;
@@ -1787,7 +1792,7 @@ namespace Mono.CSharp
                                return true;
 
                        case "warning":
-                               Report.Warning (1030, Location, "#warning: `{0}'", arg);
+                               Report.Warning (1030, 1, Location, "#warning: `{0}'", arg);
                                return true;
                        }
 
@@ -1929,9 +1934,14 @@ namespace Mono.CSharp
                                identifiers [pos] = new CharArrayHashtable (pos);
 
                        val = new String (id_builder, 0, pos);
-                       if (RootContext.Version == LanguageVersion.ISO_1 && id_builder [0] == '_' && id_builder [1] == '_') {
-                               Report.Error (1638, Location, 
-                                       "`{0}': Any identifier with double underscores cannot be used when ISO language version mode is specified", val);
+                       if (RootContext.Version == LanguageVersion.ISO_1) {
+                               for (int i = 1; i < id_builder.Length; i += 3) {
+                                       if (id_builder [i] == '_' && (id_builder [i - 1] == '_' || id_builder [i + 1] == '_')) {
+                                               Report.Error (1638, Location, 
+                                                       "`{0}': Any identifier with double underscores cannot be used when ISO language version mode is specified", val.ToString ());
+                                               break;
+                                       }
+                               }
                        }
 
                        char [] chars = new char [pos];
@@ -2305,7 +2315,7 @@ namespace Mono.CSharp
                                if ((state & REGION) != 0)
                                        Report.Error (1038, Location, "#endregion directive expected");
                                else 
-                                       Report.Error (1027, "Expected `#endif' directive");
+                                       Report.Error (1027, Location, "Expected `#endif' directive");
                        }
                                
                }