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

Side by Side Diff: sdk/lib/_internal/compiler/implementation/scanner/scanner.dart

Issue 23583038: Fix dart2js decimal number tokenization. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Analyzer tests passing now. Created 7 years, 3 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | tests/language/language_dart2js.status » ('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 part of scanner; 5 part of scanner;
6 6
7 abstract class Scanner { 7 abstract class Scanner {
8 Token tokenize(); 8 Token tokenize();
9 } 9 }
10 10
(...skipping 446 matching lines...) Expand 10 before | Expand all | Expand 10 after
457 return next; 457 return next;
458 } 458 }
459 } 459 }
460 460
461 int tokenizeNumber(int next) { 461 int tokenizeNumber(int next) {
462 int start = byteOffset; 462 int start = byteOffset;
463 while (true) { 463 while (true) {
464 next = advance(); 464 next = advance();
465 if ($0 <= next && next <= $9) { 465 if ($0 <= next && next <= $9) {
466 continue; 466 continue;
467 } else if (identical(next, $PERIOD)) { 467 } else if (identical(next, $e) || identical(next, $E)) {
468 return tokenizeFractionPart(advance(), start);
469 } else if (identical(next, $e) || identical(next, $E)
470 || identical(next, $d) || identical(next, $D)) {
471 return tokenizeFractionPart(next, start); 468 return tokenizeFractionPart(next, start);
472 } else { 469 } else {
470 if (identical(next, $PERIOD)) {
471 int nextnext = peek();
472 if ($0 <= nextnext && nextnext <= $9) {
473 return tokenizeFractionPart(advance(), start);
474 }
475 }
473 appendByteStringToken(INT_INFO, asciiString(start, 0)); 476 appendByteStringToken(INT_INFO, asciiString(start, 0));
474 return next; 477 return next;
475 } 478 }
476 } 479 }
477 } 480 }
478 481
479 int tokenizeHexOrNumber(int next) { 482 int tokenizeHexOrNumber(int next) {
480 int x = peek(); 483 int x = peek();
481 if (identical(x, $x) || identical(x, $X)) { 484 if (identical(x, $x) || identical(x, $X)) {
482 advance(); 485 advance();
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
536 } 539 }
537 if (!hasDigit) { 540 if (!hasDigit) {
538 appendByteStringToken(INT_INFO, asciiString(start, -1)); 541 appendByteStringToken(INT_INFO, asciiString(start, -1));
539 if (identical($PERIOD, next)) { 542 if (identical($PERIOD, next)) {
540 return select($PERIOD, PERIOD_PERIOD_PERIOD_INFO, PERIOD_PERIOD_INFO); 543 return select($PERIOD, PERIOD_PERIOD_PERIOD_INFO, PERIOD_PERIOD_INFO);
541 } 544 }
542 // TODO(ahe): Wrong offset for the period. 545 // TODO(ahe): Wrong offset for the period.
543 appendPrecedenceToken(PERIOD_INFO); 546 appendPrecedenceToken(PERIOD_INFO);
544 return bigSwitch(next); 547 return bigSwitch(next);
545 } 548 }
546 if (identical(next, $d) || identical(next, $D)) {
547 next = advance();
548 }
549 appendByteStringToken(DOUBLE_INFO, asciiString(start, 0)); 549 appendByteStringToken(DOUBLE_INFO, asciiString(start, 0));
550 return next; 550 return next;
551 } 551 }
552 552
553 int tokenizeExponent(int next) { 553 int tokenizeExponent(int next) {
554 if (identical(next, $PLUS) || identical(next, $MINUS)) { 554 if (identical(next, $PLUS) || identical(next, $MINUS)) {
555 next = advance(); 555 next = advance();
556 } 556 }
557 bool hasDigits = false; 557 bool hasDigits = false;
558 while (true) { 558 while (true) {
(...skipping 277 matching lines...) Expand 10 before | Expand all | Expand 10 after
836 next = advance(); 836 next = advance();
837 } 837 }
838 return error(const SourceString("unterminated string literal")); 838 return error(const SourceString("unterminated string literal"));
839 } 839 }
840 840
841 int error(SourceString message) { 841 int error(SourceString message) {
842 appendByteStringToken(BAD_INPUT_INFO, message); 842 appendByteStringToken(BAD_INPUT_INFO, message);
843 return advance(); // Ensure progress. 843 return advance(); // Ensure progress.
844 } 844 }
845 } 845 }
OLDNEW
« no previous file with comments | « no previous file | tests/language/language_dart2js.status » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698