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

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

Issue 2984713002: Fix scanning of unterminated strings (Closed)
Patch Set: address comments Created 3 years, 5 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 | « no previous file | pkg/front_end/lib/src/fasta/scanner/string_scanner.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 9b113e038660d0492e643e79d2cb8cc2e59ba402..4765edf929dea3ae669dc0f9a0a6b52910978e00 100644
--- a/pkg/front_end/lib/src/fasta/scanner/abstract_scanner.dart
+++ b/pkg/front_end/lib/src/fasta/scanner/abstract_scanner.dart
@@ -1034,8 +1034,9 @@ abstract class AbstractScanner implements Scanner {
identical(next, $CR) ||
identical(next, $EOF))) {
if (!asciiOnly) handleUnicode(start);
- return unterminatedString(quoteChar, start,
+ unterminatedString(quoteChar, start,
asciiOnly: asciiOnly, isMultiLine: false, isRaw: false);
+ return next;
}
if (next > 127) asciiOnly = false;
next = advance();
@@ -1102,16 +1103,18 @@ abstract class AbstractScanner implements Scanner {
return next;
} else if (identical(next, $LF) || identical(next, $CR)) {
if (!asciiOnly) handleUnicode(start);
- return unterminatedString(quoteChar, start,
+ unterminatedString(quoteChar, start,
asciiOnly: asciiOnly, isMultiLine: false, isRaw: true);
+ return next;
} else if (next > 127) {
asciiOnly = false;
}
next = advance();
}
if (!asciiOnly) handleUnicode(start);
- return unterminatedString(quoteChar, start,
+ unterminatedString(quoteChar, start,
asciiOnly: asciiOnly, isMultiLine: false, isRaw: true);
+ return next;
}
int tokenizeMultiLineRawString(int quoteChar, int start) {
@@ -1149,8 +1152,9 @@ abstract class AbstractScanner implements Scanner {
}
}
if (!asciiOnlyLine) handleUnicode(unicodeStart);
- return unterminatedString(quoteChar, start,
+ unterminatedString(quoteChar, start,
asciiOnly: asciiOnlyLine, isMultiLine: true, isRaw: true);
+ return next;
}
int tokenizeMultiLineString(int quoteChar, int start, bool raw) {
@@ -1201,8 +1205,9 @@ abstract class AbstractScanner implements Scanner {
next = advance();
}
if (!asciiOnlyLine) handleUnicode(unicodeStart);
- return unterminatedString(quoteChar, start,
+ unterminatedString(quoteChar, start,
asciiOnly: asciiOnlyString, isMultiLine: true, isRaw: false);
+ return next;
}
int unexpected(int character) {
@@ -1215,15 +1220,14 @@ abstract class AbstractScanner implements Scanner {
return advanceAfterError(shouldAdvance);
}
- int unterminatedString(int quoteChar, int start,
+ void unterminatedString(int quoteChar, int start,
{bool asciiOnly, bool isMultiLine, bool isRaw}) {
String suffix = new String.fromCharCodes(
isMultiLine ? [quoteChar, quoteChar, quoteChar] : [quoteChar]);
String prefix = isRaw ? 'r$suffix' : suffix;
appendSyntheticSubstringToken(TokenType.STRING, start, asciiOnly, suffix);
- beginToken();
- return unterminated(prefix);
+ unterminated(prefix, shouldAdvance: false);
}
int advanceAfterError(bool shouldAdvance) {
« no previous file with comments | « no previous file | pkg/front_end/lib/src/fasta/scanner/string_scanner.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698