2002-08-19 Martin Baulig <martin@gnome.org>
[mono.git] / mcs / mcs / cs-tokenizer.cs
index 2e88c234cd482a7d3207dce1d22c83709ef0aa4c..5cecc98b7a77df8e6d41357b4fd16936a5c8b744 100755 (executable)
@@ -988,6 +988,19 @@ namespace Mono.CSharp
                                return;\r
                        }\r
 \r
+                       char[] whitespace = { ' ', '\t' };\r
+                       if (arg.IndexOfAny (whitespace) != -1){\r
+                               Report.Error(1025, Location, "Single-line comment or end-of-line expected");\r
+                               return;\r
+                       }\r
+\r
+                       foreach (char c in arg){\r
+                               if (!Char.IsLetter (c) && (c != '_')){\r
+                                       Report.Error(1001, Location, "Identifier expected");\r
+                                       return;\r
+                               }\r
+                       }\r
+\r
                        if (is_define){\r
                                if (defines == null)\r
                                        defines = new Hashtable ();\r
@@ -1194,6 +1207,11 @@ namespace Mono.CSharp
                        \r
                        get_cmd_arg (out cmd, out arg);\r
 \r
+                       // Eat any trailing whitespaces and single-line comments\r
+                       if (arg.IndexOf ("//") != -1)\r
+                               arg = arg.Substring (0, arg.IndexOf ("//"));\r
+                       arg = arg.TrimEnd (' ', '\t');\r
+\r
                        //\r
                        // The first group of pre-processing instructions is always processed\r
                        //\r
@@ -1499,7 +1517,7 @@ namespace Mono.CSharp
                                        any_token_seen |= tokens_seen;\r
                                        tokens_seen = false;\r
                                        if (c == -1)\r
-                                               Report.Error (1027, Location, "#endif expected");\r
+                                               Report.Error (1027, Location, "#endif/#endregion expected");\r
                                        continue;\r
                                }\r
                                \r
@@ -1579,8 +1597,9 @@ namespace Mono.CSharp
                                return Token.ERROR;\r
                        }\r
 \r
-                       if (ifstack != null && ifstack.Count > 1)\r
-                               Report.Error (1027, Location, "#endif expected");\r
+                       if (ifstack != null && ifstack.Count >= 1)\r
+                               Report.Error (1027, Location, "#endif/#endregion expected");\r
+\r
                        return Token.EOF;\r
                }\r
        }\r