[mcs] Throw expression cannot be placed after any colon.
[mono.git] / mcs / mcs / cs-tokenizer.cs
index e07fdcaf6e6437c1a4a39bb53cfc2283bdb25918..505173cb4f9e10a70e72432bae7cd9e4bcf323b3 100644 (file)
@@ -893,6 +893,16 @@ namespace Mono.CSharp
                                if (parsing_block == 0)
                                        res = -1;
 
+                               break;
+                       case Token.THROW:
+                               switch (current_token) {
+                               case Token.ARROW:
+                               case Token.OP_COALESCING:
+                               case Token.INTERR:
+                                       res = Token.THROW_EXPR;
+                                       break;
+                               }
+
                                break;
                        }
 
@@ -1267,7 +1277,8 @@ namespace Mono.CSharp
                        else if (the_token == Token.INTERR_NULLABLE || the_token == Token.STAR)
                                goto again;
                        else if (the_token == Token.OP_GENERICS_LT) {
-                               if (!parse_less_than (ref genericDimension))
+                               int unused = 0;
+                               if (!parse_less_than (ref unused))
                                        return false;
                                goto again;
                        } else if (the_token == Token.OPEN_BRACKET) {
@@ -1344,6 +1355,7 @@ namespace Mono.CSharp
                        case Token.THIS:
                        case Token.NEW:
                        case Token.INTERPOLATED_STRING:
+                       case Token.THROW:
                                next_token = Token.INTERR;
                                break;
                                
@@ -2465,6 +2477,12 @@ namespace Mono.CSharp
                                case '\"':
                                        ++str_quote;
                                        break;
+                               case '\\':
+                                       // Skip escaped " character
+                                       c = reader.Read ();
+                                       if (c == -1)
+                                               res = false;
+                                       break;
                                case -1:
                                        res = false;
                                        break;
@@ -2523,7 +2541,6 @@ namespace Mono.CSharp
 
                int TokenizePragmaWarningIdentifier (ref int c, ref bool identifier)
                {
-
                        if ((c >= '0' && c <= '9') || is_identifier_start_character (c)) {
                                int number;
 
@@ -2548,7 +2565,7 @@ namespace Mono.CSharp
                                                id_builder [pos] = (char)c;
 
                                                if (c >= '0' && c <= '9') {
-                                                       if (pos == 6 && id_builder [0] == 'C' && id_builder [1] == 'S') {
+                                                       if (pos == 5 && id_builder [0] == 'C' && id_builder [1] == 'S') {
                                                                // Recognize CSXXXX as C# XXXX warning
                                                                number = 0;
                                                                int pow = 1000;
@@ -2563,6 +2580,9 @@ namespace Mono.CSharp
                                                                        pow /= 10;
                                                                }
                                                        }
+                                               } else if (c == '\n' || c == UnicodeLS || c == UnicodePS) {
+                                                       advance_line ();
+                                                       break;
                                                } else if ((c < 'a' || c > 'z') && (c < 'A' || c > 'Z') && c != '_') {
                                                        break;
                                                }
@@ -4058,6 +4078,9 @@ namespace Mono.CSharp
                                        --braces;
                                        break;
                                case '\\':
+                                       if (parsing_string_interpolation_quoted != null && parsing_string_interpolation_quoted.Peek ())
+                                               break;
+
                                        ++col;
                                        int surrogate;
                                        ch = escape (ch, out surrogate);