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

Unified Diff: pkg/front_end/lib/src/fasta/scanner/utf8_bytes_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/utf8_bytes_scanner.dart
diff --git a/pkg/front_end/lib/src/fasta/scanner/utf8_bytes_scanner.dart b/pkg/front_end/lib/src/fasta/scanner/utf8_bytes_scanner.dart
index 0ab8ca2226dc925f8de2cdfa0a9835208ed72413..b4088b3d4fd33ab5c7efae6f9bb560ff197deb5f 100644
--- a/pkg/front_end/lib/src/fasta/scanner/utf8_bytes_scanner.dart
+++ b/pkg/front_end/lib/src/fasta/scanner/utf8_bytes_scanner.dart
@@ -6,7 +6,9 @@ library fasta.scanner.utf8_bytes_scanner;
import 'dart:convert' show UNICODE_BOM_CHARACTER_RUNE, UTF8;
-import '../../scanner/token.dart' show TokenType;
+import '../../scanner/token.dart' show SyntheticStringToken, TokenType;
+
+import '../../scanner/token.dart' as analyzer show StringToken;
import '../scanner.dart' show unicodeReplacementCharacter;
@@ -198,7 +200,8 @@ class Utf8BytesScanner extends ArrayBasedScanner {
}
@override
- StringToken createSubstringToken(TokenType type, int start, bool asciiOnly,
+ analyzer.StringToken createSubstringToken(
+ TokenType type, int start, bool asciiOnly,
[int extraOffset = 0]) {
return new StringToken.fromUtf8Bytes(
type, bytes, start, byteOffset + extraOffset, asciiOnly, tokenStart,
@@ -206,6 +209,14 @@ class Utf8BytesScanner extends ArrayBasedScanner {
}
@override
+ analyzer.StringToken createSyntheticSubstringToken(
+ TokenType type, int start, bool asciiOnly, String closingQuotes) {
+ String source = StringToken.decodeUtf8(bytes, start, byteOffset, asciiOnly);
+ return new SyntheticStringToken(
+ type, source + closingQuotes, start, source.length);
+ }
+
+ @override
CommentToken createCommentToken(TokenType type, int start, bool asciiOnly,
[int extraOffset = 0]) {
return new CommentToken.fromUtf8Bytes(

Powered by Google App Engine
This is Rietveld 408576698