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

Side by Side Diff: src/scanner.cc

Issue 6009009: Simplify ScanJsonString. (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: Created 9 years, 11 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 | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2010 the V8 project authors. All rights reserved. 1 // Copyright 2010 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 439 matching lines...) Expand 10 before | Expand all | Expand 10 after
450 450
451 next_.location.end_pos = source_pos(); 451 next_.location.end_pos = source_pos();
452 next_.token = token; 452 next_.token = token;
453 } 453 }
454 454
455 455
456 Token::Value JsonScanner::ScanJsonString() { 456 Token::Value JsonScanner::ScanJsonString() {
457 ASSERT_EQ('"', c0_); 457 ASSERT_EQ('"', c0_);
458 Advance(); 458 Advance();
459 LiteralScope literal(this); 459 LiteralScope literal(this);
460 while (c0_ != '"' && c0_ > 0) { 460 while (c0_ != '"') {
461 // Check for control character (0x00-0x1f) or unterminated string (<0). 461 // Check for control character (0x00-0x1f) or unterminated string (<0).
462 if (c0_ < 0x20) return Token::ILLEGAL; 462 if (c0_ < 0x20) return Token::ILLEGAL;
463 if (c0_ != '\\') { 463 if (c0_ != '\\') {
464 AddLiteralCharAdvance(); 464 AddLiteralCharAdvance();
465 } else { 465 } else {
466 Advance(); 466 Advance();
467 switch (c0_) { 467 switch (c0_) {
468 case '"': 468 case '"':
469 case '\\': 469 case '\\':
470 case '/': 470 case '/':
(...skipping 26 matching lines...) Expand all
497 } 497 }
498 AddLiteralChar(value); 498 AddLiteralChar(value);
499 break; 499 break;
500 } 500 }
501 default: 501 default:
502 return Token::ILLEGAL; 502 return Token::ILLEGAL;
503 } 503 }
504 Advance(); 504 Advance();
505 } 505 }
506 } 506 }
507 if (c0_ != '"') {
508 return Token::ILLEGAL;
509 }
510 literal.Complete(); 507 literal.Complete();
511 Advance(); 508 Advance();
512 return Token::STRING; 509 return Token::STRING;
513 } 510 }
514 511
515 512
516 Token::Value JsonScanner::ScanJsonNumber() { 513 Token::Value JsonScanner::ScanJsonNumber() {
517 LiteralScope literal(this); 514 LiteralScope literal(this);
518 if (c0_ == '-') AddLiteralCharAdvance(); 515 if (c0_ == '-') AddLiteralCharAdvance();
519 if (c0_ == '0') { 516 if (c0_ == '0') {
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
556 text++; 553 text++;
557 } 554 }
558 if (ScannerConstants::kIsIdentifierPart.get(c0_)) return Token::ILLEGAL; 555 if (ScannerConstants::kIsIdentifierPart.get(c0_)) return Token::ILLEGAL;
559 literal.Complete(); 556 literal.Complete();
560 return token; 557 return token;
561 } 558 }
562 559
563 560
564 561
565 } } // namespace v8::internal 562 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698