Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(302)

Side by Side Diff: sdk/lib/_internal/compiler/implementation/scanner/scanner.dart

Issue 340703003: Prevent double reporting on hex, strings, and multiline comments. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Comments and comments Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 part of scanner; 5 part of scanner;
6 6
7 abstract class Scanner { 7 abstract class Scanner {
8 Token tokenize(); 8 Token tokenize();
9 9
10 factory Scanner(SourceFile file, {bool includeComments: false}) { 10 factory Scanner(SourceFile file, {bool includeComments: false}) {
(...skipping 610 matching lines...) Expand 10 before | Expand all | Expand 10 after
621 next = advance(); // Advance past the $x or $X. 621 next = advance(); // Advance past the $x or $X.
622 bool hasDigits = false; 622 bool hasDigits = false;
623 while (true) { 623 while (true) {
624 next = advance(); 624 next = advance();
625 if (($0 <= next && next <= $9) 625 if (($0 <= next && next <= $9)
626 || ($A <= next && next <= $F) 626 || ($A <= next && next <= $F)
627 || ($a <= next && next <= $f)) { 627 || ($a <= next && next <= $f)) {
628 hasDigits = true; 628 hasDigits = true;
629 } else { 629 } else {
630 if (!hasDigits) { 630 if (!hasDigits) {
631 return unterminated('0x'); 631 unterminated('0x', shouldAdvance: false);
632 return next;
632 } 633 }
633 appendSubstringToken(HEXADECIMAL_INFO, start, true); 634 appendSubstringToken(HEXADECIMAL_INFO, start, true);
634 return next; 635 return next;
635 } 636 }
636 } 637 }
637 return null; 638 return null;
638 } 639 }
639 640
640 int tokenizeDotsOrNumber(int next) { 641 int tokenizeDotsOrNumber(int next) {
641 int start = scanOffset; 642 int start = scanOffset;
(...skipping 300 matching lines...) Expand 10 before | Expand all | Expand 10 after
942 next = tokenizeIdentifier(next, scanOffset, false); 943 next = tokenizeIdentifier(next, scanOffset, false);
943 } else { 944 } else {
944 unterminated(r'$', shouldAdvance: false); 945 unterminated(r'$', shouldAdvance: false);
945 } 946 }
946 beginToken(); // The string interpolation suffix starts here. 947 beginToken(); // The string interpolation suffix starts here.
947 return next; 948 return next;
948 } 949 }
949 950
950 int tokenizeSingleLineRawString(int next, int quoteChar, int start) { 951 int tokenizeSingleLineRawString(int next, int quoteChar, int start) {
951 bool asciiOnly = true; 952 bool asciiOnly = true;
952 next = advance(); // Advance past the quote.
953 while (next != $EOF) { 953 while (next != $EOF) {
954 if (identical(next, quoteChar)) { 954 if (identical(next, quoteChar)) {
955 if (!asciiOnly) handleUnicode(start); 955 if (!asciiOnly) handleUnicode(start);
956 next = advance(); 956 next = advance();
957 appendSubstringToken(STRING_INFO, start, asciiOnly); 957 appendSubstringToken(STRING_INFO, start, asciiOnly);
958 return next; 958 return next;
959 } else if (identical(next, $LF) || identical(next, $CR)) { 959 } else if (identical(next, $LF) || identical(next, $CR)) {
960 if (!asciiOnly) handleUnicode(start); 960 if (!asciiOnly) handleUnicode(start);
961 return unterminatedRawString(quoteChar); 961 return unterminatedRawString(quoteChar);
962 } else if (next > 127) { 962 } else if (next > 127) {
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
1071 } 1071 }
1072 1072
1073 int unterminatedRawString(int quoteChar) { 1073 int unterminatedRawString(int quoteChar) {
1074 return unterminated('r${new String.fromCharCodes([quoteChar])}'); 1074 return unterminated('r${new String.fromCharCodes([quoteChar])}');
1075 } 1075 }
1076 1076
1077 int unterminatedMultiLineString(int quoteChar) { 1077 int unterminatedMultiLineString(int quoteChar) {
1078 return unterminated( 1078 return unterminated(
1079 new String.fromCharCodes([quoteChar, quoteChar, quoteChar])); 1079 new String.fromCharCodes([quoteChar, quoteChar, quoteChar]));
1080 } 1080 }
1081
1081 int unterminatedRawMultiLineString(int quoteChar) { 1082 int unterminatedRawMultiLineString(int quoteChar) {
1082 return unterminated( 1083 return unterminated(
1083 'r${new String.fromCharCodes([quoteChar, quoteChar, quoteChar])}'); 1084 'r${new String.fromCharCodes([quoteChar, quoteChar, quoteChar])}');
1084 } 1085 }
1085 1086
1086 int advanceAfterError(bool shouldAdvance) { 1087 int advanceAfterError(bool shouldAdvance) {
1087 if (atEndOfFile()) return $EOF; 1088 if (atEndOfFile()) return $EOF;
1088 if (shouldAdvance) { 1089 if (shouldAdvance) {
1089 return advance(); // Ensure progress. 1090 return advance(); // Ensure progress.
1090 } else { 1091 } else {
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
1146 1147
1147 PrecedenceInfo closeBraceInfoFor(BeginGroupToken begin) { 1148 PrecedenceInfo closeBraceInfoFor(BeginGroupToken begin) {
1148 return const { 1149 return const {
1149 '(': CLOSE_PAREN_INFO, 1150 '(': CLOSE_PAREN_INFO,
1150 '[': CLOSE_SQUARE_BRACKET_INFO, 1151 '[': CLOSE_SQUARE_BRACKET_INFO,
1151 '{': CLOSE_CURLY_BRACKET_INFO, 1152 '{': CLOSE_CURLY_BRACKET_INFO,
1152 '<': GT_INFO, 1153 '<': GT_INFO,
1153 r'${': CLOSE_CURLY_BRACKET_INFO, 1154 r'${': CLOSE_CURLY_BRACKET_INFO,
1154 }[begin.value]; 1155 }[begin.value];
1155 } 1156 }
OLDNEW
« no previous file with comments | « sdk/lib/_internal/compiler/implementation/scanner/parser.dart ('k') | tests/compiler/dart2js/message_kind_helper.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698