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

Side by Side Diff: src/scanner-base.cc

Issue 6928059: Fix newly introduced bug in detecing octal numbers. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Added test to preparser test. Removed duplicates Created 9 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | test/preparser/preparser.expectation » ('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 2011 the V8 project authors. All rights reserved. 1 // Copyright 2011 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 546 matching lines...) Expand 10 before | Expand all | Expand 10 after
557 557
558 LiteralScope literal(this); 558 LiteralScope literal(this);
559 if (seen_period) { 559 if (seen_period) {
560 // we have already seen a decimal point of the float 560 // we have already seen a decimal point of the float
561 AddLiteralChar('.'); 561 AddLiteralChar('.');
562 ScanDecimalDigits(); // we know we have at least one digit 562 ScanDecimalDigits(); // we know we have at least one digit
563 563
564 } else { 564 } else {
565 // if the first character is '0' we must check for octals and hex 565 // if the first character is '0' we must check for octals and hex
566 if (c0_ == '0') { 566 if (c0_ == '0') {
567 int start_pos = source_pos(); // For reporting octal positions.
567 AddLiteralCharAdvance(); 568 AddLiteralCharAdvance();
568 569
569 // either 0, 0exxx, 0Exxx, 0.xxx, an octal number, or a hex number 570 // either 0, 0exxx, 0Exxx, 0.xxx, an octal number, or a hex number
570 if (c0_ == 'x' || c0_ == 'X') { 571 if (c0_ == 'x' || c0_ == 'X') {
571 // hex number 572 // hex number
572 kind = HEX; 573 kind = HEX;
573 AddLiteralCharAdvance(); 574 AddLiteralCharAdvance();
574 if (!IsHexDigit(c0_)) { 575 if (!IsHexDigit(c0_)) {
575 // we must have at least one hex digit after 'x'/'X' 576 // we must have at least one hex digit after 'x'/'X'
576 return Token::ILLEGAL; 577 return Token::ILLEGAL;
577 } 578 }
578 while (IsHexDigit(c0_)) { 579 while (IsHexDigit(c0_)) {
579 AddLiteralCharAdvance(); 580 AddLiteralCharAdvance();
580 } 581 }
581 } else if ('0' <= c0_ && c0_ <= '7') { 582 } else if ('0' <= c0_ && c0_ <= '7') {
582 // (possible) octal number 583 // (possible) octal number
583 kind = OCTAL; 584 kind = OCTAL;
584 while (true) { 585 while (true) {
585 if (c0_ == '8' || c0_ == '9') { 586 if (c0_ == '8' || c0_ == '9') {
586 kind = DECIMAL; 587 kind = DECIMAL;
587 break; 588 break;
588 } 589 }
589 if (c0_ < '0' || '7' < c0_) { 590 if (c0_ < '0' || '7' < c0_) {
590 // Octal literal finished. 591 // Octal literal finished.
591 octal_pos_ = next_.location; 592 octal_pos_ = Location(start_pos, source_pos());
592 break; 593 break;
593 } 594 }
594 AddLiteralCharAdvance(); 595 AddLiteralCharAdvance();
595 } 596 }
596 } 597 }
597 } 598 }
598 599
599 // Parse decimal digits and allow trailing fractional part. 600 // Parse decimal digits and allow trailing fractional part.
600 if (kind == DECIMAL) { 601 if (kind == DECIMAL) {
601 ScanDecimalDigits(); // optional 602 ScanDecimalDigits(); // optional
(...skipping 340 matching lines...) Expand 10 before | Expand all | Expand 10 after
942 if (MatchKeywordStart(input, "with", 1, Token::WITH)) return; 943 if (MatchKeywordStart(input, "with", 1, Token::WITH)) return;
943 break; 944 break;
944 case UNMATCHABLE: 945 case UNMATCHABLE:
945 break; 946 break;
946 } 947 }
947 // On fallthrough, it's a failure. 948 // On fallthrough, it's a failure.
948 state_ = UNMATCHABLE; 949 state_ = UNMATCHABLE;
949 } 950 }
950 951
951 } } // namespace v8::internal 952 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « no previous file | test/preparser/preparser.expectation » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698