Chromium Code Reviews| Index: pkg/analyzer/lib/src/generated/parser.dart |
| diff --git a/pkg/analyzer/lib/src/generated/parser.dart b/pkg/analyzer/lib/src/generated/parser.dart |
| index 4a4823fea536e72d1d6ec0e7ba9f9169bcccb007..aef91b7c05ec653e599428ecfb9757b427095fbc 100644 |
| --- a/pkg/analyzer/lib/src/generated/parser.dart |
| +++ b/pkg/analyzer/lib/src/generated/parser.dart |
| @@ -3441,14 +3441,14 @@ class Parser { |
| if (StringUtilities.startsWith4(lexeme, 0, 0x72, 0x22, 0x22, 0x22) || |
| StringUtilities.startsWith4(lexeme, 0, 0x72, 0x27, 0x27, 0x27)) { |
| isRaw = true; |
| - start += 4; |
| + start = _skipInitialWhitespace(lexeme, start + 4); |
| } else if (StringUtilities.startsWith2(lexeme, 0, 0x72, 0x22) || |
| StringUtilities.startsWith2(lexeme, 0, 0x72, 0x27)) { |
| isRaw = true; |
| start += 2; |
| } else if (StringUtilities.startsWith3(lexeme, 0, 0x22, 0x22, 0x22) || |
| StringUtilities.startsWith3(lexeme, 0, 0x27, 0x27, 0x27)) { |
| - start += 3; |
| + start = _skipInitialWhitespace(lexeme, start + 3); |
| } else if (StringUtilities.startsWithChar(lexeme, 0x22) || |
| StringUtilities.startsWithChar(lexeme, 0x27)) { |
| start += 1; |
| @@ -3481,6 +3481,35 @@ class Parser { |
| } |
| /** |
| + * Given the [lexeme] for a multi-line string whose content begins at the |
| + * given [start] index, return the index of the first character that is |
| + * included in the value of the string. According to the specification: |
| + * |
| + * If the first line of a multiline string consists solely of the whitespace |
| + * characters defined by the production WHITESPACE 20.1), possibly prefixed |
| + * by \, then that line is ignored, including the new line at its end. |
| + */ |
| + int _skipInitialWhitespace(String lexeme, int start) { |
| + int length = lexeme.length; |
| + int index = start; |
| + while (index < length) { |
| + int currentChar = lexeme.codeUnitAt(index); |
| + if (currentChar == 0x0D) { |
| + if (index + 1 < length && lexeme.codeUnitAt(index) == 0x0A) { |
| + return index + 2; |
| + } |
| + return index + 1; |
| + } else if (currentChar == 0x0A) { |
| + return index + 1; |
| + } else if (currentChar != 0x09 && currentChar != 0x20 && currentChar != 0x5C) { |
|
Paul Berry
2015/03/26 17:59:13
As discussed in person, this doesn't match the VM
|
| + return start; |
| + } |
| + index++; |
| + } |
| + return index; |
| + } |
| + |
| + /** |
| * Convert the given [method] declaration into the nearest valid top-level |
| * function declaration (that is, the function declaration that most closely |
| * captures the components of the given method declaration). |