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

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

Issue 2910583002: improve fasta interpolation recovery (Closed)
Patch Set: remove unnecessary label 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, 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 fasta.scanner.abstract_scanner; 5 library fasta.scanner.abstract_scanner;
6 6
7 import 'dart:collection' show ListMixin; 7 import 'dart:collection' show ListMixin;
8 8
9 import 'dart:typed_data' show Uint16List, Uint32List; 9 import 'dart:typed_data' show Uint16List, Uint32List;
10 10
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after
215 * 215 *
216 * Note that [extraOffset] can only be used if the covered character(s) are 216 * Note that [extraOffset] can only be used if the covered character(s) are
217 * known to be ASCII. 217 * known to be ASCII.
218 */ 218 */
219 DartDocToken createDartDocToken(TokenType type, int start, bool asciiOnly, 219 DartDocToken createDartDocToken(TokenType type, int start, bool asciiOnly,
220 [int extraOffset = 0]); 220 [int extraOffset = 0]);
221 221
222 /** Documentation in subclass [ArrayBasedScanner]. */ 222 /** Documentation in subclass [ArrayBasedScanner]. */
223 void discardOpenLt(); 223 void discardOpenLt();
224 224
225 /** Documentation in subclass [ArrayBasedScanner]. */
226 void discardInterpolation();
227
225 /// Return true when at EOF. 228 /// Return true when at EOF.
226 bool atEndOfFile(); 229 bool atEndOfFile();
227 230
228 Token tokenize() { 231 Token tokenize() {
229 while (!atEndOfFile()) { 232 while (!atEndOfFile()) {
230 int next = advance(); 233 int next = advance();
231 while (!identical(next, $EOF)) { 234 while (!identical(next, $EOF)) {
232 next = bigSwitch(next); 235 next = bigSwitch(next);
233 } 236 }
234 if (atEndOfFile()) { 237 if (atEndOfFile()) {
(...skipping 809 matching lines...) Expand 10 before | Expand all | Expand 10 after
1044 } 1047 }
1045 } 1048 }
1046 1049
1047 int tokenizeInterpolatedExpression(int next) { 1050 int tokenizeInterpolatedExpression(int next) {
1048 appendBeginGroup(TokenType.STRING_INTERPOLATION_EXPRESSION); 1051 appendBeginGroup(TokenType.STRING_INTERPOLATION_EXPRESSION);
1049 beginToken(); // The expression starts here. 1052 beginToken(); // The expression starts here.
1050 next = advance(); // Move past the curly bracket. 1053 next = advance(); // Move past the curly bracket.
1051 while (!identical(next, $EOF) && !identical(next, $STX)) { 1054 while (!identical(next, $EOF) && !identical(next, $STX)) {
1052 next = bigSwitch(next); 1055 next = bigSwitch(next);
1053 } 1056 }
1054 if (identical(next, $EOF)) return next; 1057 if (identical(next, $EOF)) {
1058 beginToken();
1059 discardInterpolation();
1060 return next;
1061 }
1055 next = advance(); // Move past the $STX. 1062 next = advance(); // Move past the $STX.
1056 beginToken(); // The string interpolation suffix starts here. 1063 beginToken(); // The string interpolation suffix starts here.
1057 return next; 1064 return next;
1058 } 1065 }
1059 1066
1060 int tokenizeInterpolatedIdentifier(int next) { 1067 int tokenizeInterpolatedIdentifier(int next) {
1061 appendPrecedenceToken(TokenType.STRING_INTERPOLATION_IDENTIFIER); 1068 appendPrecedenceToken(TokenType.STRING_INTERPOLATION_IDENTIFIER);
1062 1069
1063 if ($a <= next && next <= $z || 1070 if ($a <= next && next <= $z ||
1064 $A <= next && next <= $Z || 1071 $A <= next && next <= $Z ||
(...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after
1298 switchToUint32(newLength); 1305 switchToUint32(newLength);
1299 } 1306 }
1300 } 1307 }
1301 1308
1302 void switchToUint32(int newLength) { 1309 void switchToUint32(int newLength) {
1303 final newArray = new Uint32List(newLength); 1310 final newArray = new Uint32List(newLength);
1304 newArray.setRange(0, arrayLength, array); 1311 newArray.setRange(0, arrayLength, array);
1305 array = newArray; 1312 array = newArray;
1306 } 1313 }
1307 } 1314 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698