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

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

Issue 3002493002: generate synthetic and error tokens when missing digit (Closed)
Patch Set: rebase Created 3 years, 4 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
« no previous file with comments | « no previous file | pkg/front_end/lib/src/fasta/scanner/array_based_scanner.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 146 matching lines...) Expand 10 before | Expand all | Expand 10 after
157 * substring string [5,9). 157 * substring string [5,9).
158 * 158 *
159 * Note that [extraOffset] can only be used if the covered character(s) are 159 * Note that [extraOffset] can only be used if the covered character(s) are
160 * known to be ASCII. 160 * known to be ASCII.
161 */ 161 */
162 void appendSubstringToken(TokenType type, int start, bool asciiOnly, 162 void appendSubstringToken(TokenType type, int start, bool asciiOnly,
163 [int extraOffset]); 163 [int extraOffset]);
164 164
165 /** 165 /**
166 * Appends a substring from the scan offset [start] to the current 166 * Appends a substring from the scan offset [start] to the current
167 * [scanOffset] plus [closingQuotes]. The closing quote(s) will be added 167 * [scanOffset] plus [syntheticChars]. The additional char(s) will be added
168 * to the unterminated string literal's lexeme but the returned 168 * to the unterminated string literal's lexeme but the returned
169 * token's length will *not* include those closing quotes 169 * token's length will *not* include those additional char(s)
170 * so as to be true to the original source. 170 * so as to be true to the original source.
171 */ 171 */
172 void appendSyntheticSubstringToken( 172 void appendSyntheticSubstringToken(
173 TokenType type, int start, bool asciiOnly, String closingQuotes); 173 TokenType type, int start, bool asciiOnly, String syntheticChars);
174 174
175 /** Documentation in subclass [ArrayBasedScanner]. */ 175 /** Documentation in subclass [ArrayBasedScanner]. */
176 void appendPrecedenceToken(TokenType type); 176 void appendPrecedenceToken(TokenType type);
177 177
178 /** Documentation in subclass [ArrayBasedScanner]. */ 178 /** Documentation in subclass [ArrayBasedScanner]. */
179 int select(int choice, TokenType yes, TokenType no); 179 int select(int choice, TokenType yes, TokenType no);
180 180
181 /** Documentation in subclass [ArrayBasedScanner]. */ 181 /** Documentation in subclass [ArrayBasedScanner]. */
182 void appendKeywordToken(Keyword keyword); 182 void appendKeywordToken(Keyword keyword);
183 183
(...skipping 535 matching lines...) Expand 10 before | Expand all | Expand 10 after
719 next = advance(); 719 next = advance();
720 if (identical(next, $PLUS) || identical(next, $MINUS)) { 720 if (identical(next, $PLUS) || identical(next, $MINUS)) {
721 next = advance(); 721 next = advance();
722 } 722 }
723 bool hasExponentDigits = false; 723 bool hasExponentDigits = false;
724 while (true) { 724 while (true) {
725 if ($0 <= next && next <= $9) { 725 if ($0 <= next && next <= $9) {
726 hasExponentDigits = true; 726 hasExponentDigits = true;
727 } else { 727 } else {
728 if (!hasExponentDigits) { 728 if (!hasExponentDigits) {
729 unterminated('1e', shouldAdvance: false); 729 appendSyntheticSubstringToken(TokenType.DOUBLE, start, true, '0');
730 appendErrorToken(
731 new UnterminatedToken('1e', tokenStart, stringOffset));
730 return next; 732 return next;
731 } 733 }
732 break; 734 break;
733 } 735 }
734 next = advance(); 736 next = advance();
735 } 737 }
736 738
737 done = true; 739 done = true;
738 continue LOOP; 740 continue LOOP;
739 } else { 741 } else {
(...skipping 579 matching lines...) Expand 10 before | Expand all | Expand 10 after
1319 switchToUint32(newLength); 1321 switchToUint32(newLength);
1320 } 1322 }
1321 } 1323 }
1322 1324
1323 void switchToUint32(int newLength) { 1325 void switchToUint32(int newLength) {
1324 final newArray = new Uint32List(newLength); 1326 final newArray = new Uint32List(newLength);
1325 newArray.setRange(0, arrayLength, array); 1327 newArray.setRange(0, arrayLength, array);
1326 array = newArray; 1328 array = newArray;
1327 } 1329 }
1328 } 1330 }
OLDNEW
« no previous file with comments | « no previous file | pkg/front_end/lib/src/fasta/scanner/array_based_scanner.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698