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

Side by Side Diff: pkg/front_end/lib/src/fasta/scanner/string_scanner.dart

Issue 2915093002: improve fasta unterminated string recovery (Closed)
Patch Set: fix dartdoc Created 3 years, 6 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
OLDNEW
1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2011, 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 library dart2js.scanner.string_scanner; 5 library dart2js.scanner.string_scanner;
6 6
7 import '../../scanner/token.dart' show TokenType; 7 import '../../scanner/token.dart' show SyntheticStringToken, TokenType;
8
9 import '../../scanner/token.dart' as analyzer show StringToken;
8 10
9 import 'array_based_scanner.dart' show ArrayBasedScanner; 11 import 'array_based_scanner.dart' show ArrayBasedScanner;
10 12
11 import 'token.dart' show CommentToken, DartDocToken, StringToken; 13 import 'token.dart' show CommentToken, DartDocToken, StringToken;
12 14
13 /** 15 /**
14 * Scanner that reads from a String and creates tokens that points to 16 * Scanner that reads from a String and creates tokens that points to
15 * substrings. 17 * substrings.
16 */ 18 */
17 class StringScanner extends ArrayBasedScanner { 19 class StringScanner extends ArrayBasedScanner {
(...skipping 20 matching lines...) Expand all
38 int advance() => string.codeUnitAt(++scanOffset); 40 int advance() => string.codeUnitAt(++scanOffset);
39 int peek() => string.codeUnitAt(scanOffset + 1); 41 int peek() => string.codeUnitAt(scanOffset + 1);
40 42
41 int get stringOffset => scanOffset; 43 int get stringOffset => scanOffset;
42 44
43 int currentAsUnicode(int next) => next; 45 int currentAsUnicode(int next) => next;
44 46
45 void handleUnicode(int startScanOffset) {} 47 void handleUnicode(int startScanOffset) {}
46 48
47 @override 49 @override
48 StringToken createSubstringToken(TokenType type, int start, bool asciiOnly, 50 analyzer.StringToken createSubstringToken(
51 TokenType type, int start, bool asciiOnly,
49 [int extraOffset = 0]) { 52 [int extraOffset = 0]) {
50 return new StringToken.fromSubstring( 53 return new StringToken.fromSubstring(
51 type, string, start, scanOffset + extraOffset, tokenStart, 54 type, string, start, scanOffset + extraOffset, tokenStart,
52 canonicalize: true, precedingComments: comments); 55 canonicalize: true, precedingComments: comments);
53 } 56 }
54 57
55 @override 58 @override
59 analyzer.StringToken createSyntheticSubstringToken(
60 TokenType type, int start, bool asciiOnly, String closingQuotes) {
61 String source = string.substring(start, scanOffset);
62 return new SyntheticStringToken(
63 type, source + closingQuotes, start, source.length);
64 }
65
66 @override
56 CommentToken createCommentToken(TokenType type, int start, bool asciiOnly, 67 CommentToken createCommentToken(TokenType type, int start, bool asciiOnly,
57 [int extraOffset = 0]) { 68 [int extraOffset = 0]) {
58 return new CommentToken.fromSubstring( 69 return new CommentToken.fromSubstring(
59 type, string, start, scanOffset + extraOffset, tokenStart, 70 type, string, start, scanOffset + extraOffset, tokenStart,
60 canonicalize: true); 71 canonicalize: true);
61 } 72 }
62 73
63 @override 74 @override
64 DartDocToken createDartDocToken(TokenType type, int start, bool asciiOnly, 75 DartDocToken createDartDocToken(TokenType type, int start, bool asciiOnly,
65 [int extraOffset = 0]) { 76 [int extraOffset = 0]) {
(...skipping 14 matching lines...) Expand all
80 91
81 SubStringScanner(this.baseOffset, String string, 92 SubStringScanner(this.baseOffset, String string,
82 {bool includeComments: false}) 93 {bool includeComments: false})
83 : super(string, includeComments: includeComments); 94 : super(string, includeComments: includeComments);
84 95
85 @override 96 @override
86 void beginToken() { 97 void beginToken() {
87 tokenStart = baseOffset + stringOffset; 98 tokenStart = baseOffset + stringOffset;
88 } 99 }
89 } 100 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698