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

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

Issue 2915093002: improve fasta unterminated string recovery (Closed)
Patch Set: fix dartdoc 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
Index: pkg/front_end/lib/src/fasta/scanner/array_based_scanner.dart
diff --git a/pkg/front_end/lib/src/fasta/scanner/array_based_scanner.dart b/pkg/front_end/lib/src/fasta/scanner/array_based_scanner.dart
index 1eb5ffb39151ac09fb1dfd829ca73ee356586dcb..756dea6601276417e187645441de0b2c9c766fe7 100644
--- a/pkg/front_end/lib/src/fasta/scanner/array_based_scanner.dart
+++ b/pkg/front_end/lib/src/fasta/scanner/array_based_scanner.dart
@@ -17,7 +17,7 @@ import '../../scanner/token.dart'
TokenType,
TokenWithComment;
-import 'token.dart' show StringToken;
+import '../../scanner/token.dart' as analyzer show StringToken;
import 'token_constants.dart'
show
@@ -222,11 +222,19 @@ abstract class ArrayBasedScanner extends AbstractScanner {
appendToken(token);
}
+ @override
void appendSubstringToken(TokenType type, int start, bool asciiOnly,
[int extraOffset = 0]) {
appendToken(createSubstringToken(type, start, asciiOnly, extraOffset));
}
+ @override
+ void appendSyntheticSubstringToken(
+ TokenType type, int start, bool asciiOnly, String closingQuotes) {
+ appendToken(
+ createSyntheticSubstringToken(type, start, asciiOnly, closingQuotes));
+ }
+
/**
* Returns a new substring from the scan offset [start] to the current
* [scanOffset] plus the [extraOffset]. For example, if the current
@@ -236,10 +244,21 @@ abstract class ArrayBasedScanner extends AbstractScanner {
* Note that [extraOffset] can only be used if the covered character(s) are
* known to be ASCII.
*/
- StringToken createSubstringToken(TokenType type, int start, bool asciiOnly,
+ analyzer.StringToken createSubstringToken(
+ TokenType type, int start, bool asciiOnly,
[int extraOffset = 0]);
/**
+ * Returns a new synthetic substring from the scan offset [start]
+ * to the current [scanOffset] plus the [closingQuotes].
+ * The [closingQuotes] are appended to the unterminated string
+ * literal's lexeme but the returned token's length will *not* include
+ * those closing quotes so as to be true to the original source.
+ */
+ analyzer.StringToken createSyntheticSubstringToken(
+ TokenType type, int start, bool asciiOnly, String closingQuotes);
+
+ /**
* This method is called to discard '<' from the "grouping" stack.
*
* [PartialParser.skipExpression] relies on the fact that we do not

Powered by Google App Engine
This is Rietveld 408576698