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

Side by Side Diff: src/scanner.cc

Issue 3330001: Fix parsing of /**/--> on first line of input. (Closed)
Patch Set: Added test-case. Created 10 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
« no previous file with comments | « no previous file | test/cctest/test-parsing.cc » ('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 2006-2008 the V8 project authors. All rights reserved. 1 // Copyright 2006-2008 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 412 matching lines...) Expand 10 before | Expand all | Expand 10 after
423 // BUG 1215673: Find a thread safe way to set a stack limit in 423 // BUG 1215673: Find a thread safe way to set a stack limit in
424 // pre-parse mode. Otherwise, we cannot safely pre-parse from other 424 // pre-parse mode. Otherwise, we cannot safely pre-parse from other
425 // threads. 425 // threads.
426 current_ = next_; 426 current_ = next_;
427 // Check for stack-overflow before returning any tokens. 427 // Check for stack-overflow before returning any tokens.
428 StackLimitCheck check; 428 StackLimitCheck check;
429 if (check.HasOverflowed()) { 429 if (check.HasOverflowed()) {
430 stack_overflow_ = true; 430 stack_overflow_ = true;
431 next_.token = Token::ILLEGAL; 431 next_.token = Token::ILLEGAL;
432 } else { 432 } else {
433 has_line_terminator_before_next_ = false;
433 Scan(); 434 Scan();
434 } 435 }
435 return current_.token; 436 return current_.token;
436 } 437 }
437 438
438 439
439 void Scanner::StartLiteral() { 440 void Scanner::StartLiteral() {
440 literal_buffer_.StartLiteral(); 441 literal_buffer_.StartLiteral();
441 } 442 }
442 443
(...skipping 322 matching lines...) Expand 10 before | Expand all | Expand 10 after
765 } 766 }
766 if (kIsIdentifierPart.get(c0_)) return Token::ILLEGAL; 767 if (kIsIdentifierPart.get(c0_)) return Token::ILLEGAL;
767 literal.Complete(); 768 literal.Complete();
768 return token; 769 return token;
769 } 770 }
770 771
771 772
772 void Scanner::ScanJavaScript() { 773 void Scanner::ScanJavaScript() {
773 next_.literal_chars = Vector<const char>(); 774 next_.literal_chars = Vector<const char>();
774 Token::Value token; 775 Token::Value token;
775 has_line_terminator_before_next_ = false;
776 do { 776 do {
777 // Remember the position of the next token 777 // Remember the position of the next token
778 next_.location.beg_pos = source_pos(); 778 next_.location.beg_pos = source_pos();
779 779
780 switch (c0_) { 780 switch (c0_) {
781 case ' ': 781 case ' ':
782 case '\t': 782 case '\t':
783 Advance(); 783 Advance();
784 token = Token::WHITESPACE; 784 token = Token::WHITESPACE;
785 break; 785 break;
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after
1006 } while (token == Token::WHITESPACE); 1006 } while (token == Token::WHITESPACE);
1007 1007
1008 next_.location.end_pos = source_pos(); 1008 next_.location.end_pos = source_pos();
1009 next_.token = token; 1009 next_.token = token;
1010 } 1010 }
1011 1011
1012 1012
1013 void Scanner::SeekForward(int pos) { 1013 void Scanner::SeekForward(int pos) {
1014 source_->SeekForward(pos - 1); 1014 source_->SeekForward(pos - 1);
1015 Advance(); 1015 Advance();
1016 // This function is only called to seek to the location
1017 // of the end of a function (at the "}" token). It doesn't matter
1018 // whether there was a line terminator in the part we skip.
1019 has_line_terminator_before_next_ = false;
1016 Scan(); 1020 Scan();
1017 } 1021 }
1018 1022
1019 1023
1020 uc32 Scanner::ScanHexEscape(uc32 c, int length) { 1024 uc32 Scanner::ScanHexEscape(uc32 c, int length) {
1021 ASSERT(length <= 4); // prevent overflow 1025 ASSERT(length <= 4); // prevent overflow
1022 1026
1023 uc32 digits[4]; 1027 uc32 digits[4];
1024 uc32 x = 0; 1028 uc32 x = 0;
1025 for (int i = 0; i < length; i++) { 1029 for (int i = 0; i < length; i++) {
(...skipping 317 matching lines...) Expand 10 before | Expand all | Expand 10 after
1343 } 1347 }
1344 AddCharAdvance(); 1348 AddCharAdvance();
1345 } 1349 }
1346 literal.Complete(); 1350 literal.Complete();
1347 1351
1348 next_.location.end_pos = source_pos() - 1; 1352 next_.location.end_pos = source_pos() - 1;
1349 return true; 1353 return true;
1350 } 1354 }
1351 1355
1352 } } // namespace v8::internal 1356 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « no previous file | test/cctest/test-parsing.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698