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

Unified Diff: pkg/front_end/lib/src/fasta/scanner/abstract_scanner.dart

Issue 2907093002: Revert "improve fasta unterminated string recovery" (Closed)
Patch Set: Created 3 years, 7 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « pkg/front_end/lib/src/fasta/quote.dart ('k') | pkg/front_end/lib/src/scanner/token.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/front_end/lib/src/fasta/scanner/abstract_scanner.dart
diff --git a/pkg/front_end/lib/src/fasta/scanner/abstract_scanner.dart b/pkg/front_end/lib/src/fasta/scanner/abstract_scanner.dart
index 2d072322b1b53eff4873c69bbc5c44a99bdf1a36..d4a97e0f255a561ece55c8425760c39f873f68e4 100644
--- a/pkg/front_end/lib/src/fasta/scanner/abstract_scanner.dart
+++ b/pkg/front_end/lib/src/fasta/scanner/abstract_scanner.dart
@@ -8,8 +8,7 @@ import 'dart:collection' show ListMixin;
import 'dart:typed_data' show Uint16List, Uint32List;
-import '../../scanner/token.dart'
- show BeginToken, SyntheticStringToken, Token, TokenType;
+import '../../scanner/token.dart' show BeginToken, Token, TokenType;
import '../scanner.dart'
show ErrorToken, Keyword, Scanner, buildUnexpectedCharacterToken;
@@ -1025,7 +1024,7 @@ abstract class AbstractScanner implements Scanner {
identical(next, $CR) ||
identical(next, $EOF))) {
if (!asciiOnly) handleUnicode(start);
- return unterminatedString(quoteChar, start, asciiOnly);
+ return unterminatedString(quoteChar);
}
if (next > 127) asciiOnly = false;
next = advance();
@@ -1090,14 +1089,14 @@ abstract class AbstractScanner implements Scanner {
return next;
} else if (identical(next, $LF) || identical(next, $CR)) {
if (!asciiOnly) handleUnicode(start);
- return unterminatedRawString(quoteChar, start, asciiOnly);
+ return unterminatedRawString(quoteChar);
} else if (next > 127) {
asciiOnly = false;
}
next = advance();
}
if (!asciiOnly) handleUnicode(start);
- return unterminatedRawString(quoteChar, start, asciiOnly);
+ return unterminatedRawString(quoteChar);
}
int tokenizeMultiLineRawString(int quoteChar, int start) {
@@ -1135,7 +1134,7 @@ abstract class AbstractScanner implements Scanner {
}
}
if (!asciiOnlyLine) handleUnicode(unicodeStart);
- return unterminatedRawMultiLineString(quoteChar, start, asciiOnlyLine);
+ return unterminatedRawMultiLineString(quoteChar);
}
int tokenizeMultiLineString(int quoteChar, int start, bool raw) {
@@ -1186,7 +1185,7 @@ abstract class AbstractScanner implements Scanner {
next = advance();
}
if (!asciiOnlyLine) handleUnicode(unicodeStart);
- return unterminatedMultiLineString(quoteChar, start, asciiOnlyString);
+ return unterminatedMultiLineString(quoteChar);
}
int unexpected(int character) {
@@ -1199,40 +1198,22 @@ abstract class AbstractScanner implements Scanner {
return advanceAfterError(shouldAdvance);
}
- void terminateUnterminatedString(
- int start, bool asciiOnlyString, String suffix) {
- if (start < scanOffset) {
- appendSubstringToken(TokenType.STRING, start, asciiOnlyString);
- }
- beginToken();
- appendToken(
- new SyntheticStringToken(TokenType.STRING, suffix, tokenStart, 0));
- }
-
- int unterminatedString(int quoteChar, int start, bool asciiOnlyString) {
- String suffix = new String.fromCharCodes([quoteChar]);
- terminateUnterminatedString(start, asciiOnlyString, suffix);
- return unterminated(suffix);
+ int unterminatedString(int quoteChar) {
+ return unterminated(new String.fromCharCodes([quoteChar]));
}
- int unterminatedRawString(int quoteChar, int start, bool asciiOnlyString) {
- String suffix = new String.fromCharCodes([quoteChar]);
- terminateUnterminatedString(start, asciiOnlyString, suffix);
- return unterminated('r$suffix');
+ int unterminatedRawString(int quoteChar) {
+ return unterminated('r${new String.fromCharCodes([quoteChar])}');
}
- int unterminatedMultiLineString(
- int quoteChar, int start, bool asciiOnlyString) {
- String suffix = new String.fromCharCodes([quoteChar, quoteChar, quoteChar]);
- terminateUnterminatedString(start, asciiOnlyString, suffix);
- return unterminated(suffix);
+ int unterminatedMultiLineString(int quoteChar) {
+ return unterminated(
+ new String.fromCharCodes([quoteChar, quoteChar, quoteChar]));
}
- int unterminatedRawMultiLineString(
- int quoteChar, int start, bool asciiOnlyString) {
- String suffix = new String.fromCharCodes([quoteChar, quoteChar, quoteChar]);
- terminateUnterminatedString(start, asciiOnlyString, suffix);
- return unterminated('r$suffix');
+ int unterminatedRawMultiLineString(int quoteChar) {
+ return unterminated(
+ 'r${new String.fromCharCodes([quoteChar, quoteChar, quoteChar])}');
}
int advanceAfterError(bool shouldAdvance) {
« no previous file with comments | « pkg/front_end/lib/src/fasta/quote.dart ('k') | pkg/front_end/lib/src/scanner/token.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698