X-Git-Url: http://wien.tomnetworks.com/gitweb/?a=blobdiff_plain;f=mcs%2Fmcs%2Fcs-tokenizer.cs;h=1915a07240b379fdf4443385f6bd5a0af1e07783;hb=efd53c8e2f1823568309a2920091b724be0feff8;hp=518e2c5ab8f6d659c4aa15361c6eb008b935d96f;hpb=a0f6764ca7a02243e3f9790417ba071a77083abc;p=mono.git diff --git a/mcs/mcs/cs-tokenizer.cs b/mcs/mcs/cs-tokenizer.cs index 518e2c5ab8f..1915a07240b 100644 --- a/mcs/mcs/cs-tokenizer.cs +++ b/mcs/mcs/cs-tokenizer.cs @@ -240,6 +240,7 @@ namespace Mono.CSharp public bool parsing_catch_when; int parsing_string_interpolation; + int string_interpolation_section; Stack parsing_string_interpolation_quoted; public bool parsing_interpolation_format; @@ -411,6 +412,7 @@ namespace Mono.CSharp public int current_token; public object val; public int parsing_string_interpolation; + public int string_interpolation_section; public Stack parsing_string_interpolation_quoted; public Position (Tokenizer t) @@ -430,9 +432,11 @@ namespace Mono.CSharp ifstack = new Stack (clone); } parsing_generic_less_than = t.parsing_generic_less_than; + string_interpolation_section = t.string_interpolation_section; current_token = t.current_token; val = t.val; parsing_string_interpolation = t.parsing_string_interpolation; + string_interpolation_section = t.string_interpolation_section; if (t.parsing_string_interpolation_quoted != null && t.parsing_string_interpolation_quoted.Count != 0) { var clone = t.parsing_string_interpolation_quoted.ToArray (); Array.Reverse (clone); @@ -1091,6 +1095,7 @@ namespace Mono.CSharp case Token.DECIMAL: case Token.BOOL: case Token.STRING: + case Token.SBYTE: return Token.OPEN_PARENS_CAST; } } @@ -2518,7 +2523,6 @@ namespace Mono.CSharp int TokenizePragmaWarningIdentifier (ref int c, ref bool identifier) { - if ((c >= '0' && c <= '9') || is_identifier_start_character (c)) { int number; @@ -2543,7 +2547,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; @@ -2558,6 +2562,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; } @@ -3373,18 +3380,26 @@ namespace Mono.CSharp case '{': val = ltb.Create (current_source, ref_line, col); + + if (parsing_string_interpolation > 0) + ++string_interpolation_section; + return Token.OPEN_BRACE; case '}': if (parsing_string_interpolation > 0) { - --parsing_string_interpolation; - bool quoted; - if (parsing_string_interpolation_quoted != null && parsing_string_interpolation_quoted.Count > 0) { - quoted = parsing_string_interpolation_quoted.Pop (); - } else { - quoted = false; + if (string_interpolation_section == 0) { + --parsing_string_interpolation; + bool quoted; + if (parsing_string_interpolation_quoted != null && parsing_string_interpolation_quoted.Count > 0) { + quoted = parsing_string_interpolation_quoted.Pop (); + } else { + quoted = false; + } + + return TokenizeInterpolatedString (quoted); } - return TokenizeInterpolatedString (quoted); + --string_interpolation_section; } val = ltb.Create (current_source, ref_line, col); @@ -4045,6 +4060,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); @@ -4089,8 +4107,6 @@ namespace Mono.CSharp private void handle_one_line_xml_comment () { int c; - while ((c = peek_char ()) == ' ') - get_char (); // skip heading whitespaces. while ((c = peek_char ()) != -1 && c != '\n' && c != '\r') { xml_comment_buffer.Append ((char) get_char ()); }