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

Side by Side Diff: runtime/vm/scanner.cc

Issue 9346005: Fix string escape, recognize escaped newline (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: '' Created 8 years, 10 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.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 #include "vm/scanner.h" 5 #include "vm/scanner.h"
6 6
7 #include "platform/assert.h" 7 #include "platform/assert.h"
8 #include "vm/flags.h" 8 #include "vm/flags.h"
9 #include "vm/object.h" 9 #include "vm/object.h"
10 #include "vm/thread.h" 10 #include "vm/thread.h"
(...skipping 499 matching lines...) Expand 10 before | Expand all | Expand 10 after
510 case 'v': 510 case 'v':
511 escape_char = '\v'; 511 escape_char = '\v';
512 break; 512 break;
513 case 'u': 513 case 'u':
514 case 'x': 514 case 'x':
515 if (!ScanEscapedCodePoint(&escape_char)) { 515 if (!ScanEscapedCodePoint(&escape_char)) {
516 EndStringLiteral(); 516 EndStringLiteral();
517 return; 517 return;
518 } 518 }
519 break; 519 break;
520 case '\0':
521 ErrorMsg("illegal escape sequence in string");
522 EndStringLiteral();
523 return;
524 default: 520 default:
521 if ((c0_ == '\0') || (c0_ == '\n') && !string_is_multiline_) {
522 ErrorMsg("unterminated string literal");
523 EndStringLiteral();
524 return;
525 }
525 escape_char = c0_; 526 escape_char = c0_;
526 break; 527 break;
527 } 528 }
528 string_chars.Add(escape_char); 529 string_chars.Add(escape_char);
529 } else if (c0_ == '$' && !is_raw) { 530 } else if (c0_ == '$' && !is_raw) {
530 // Scanned a string piece. 531 // Scanned a string piece.
531 ASSERT(string_chars.data() != NULL); 532 ASSERT(string_chars.data() != NULL);
532 // Strings are canonicalized: Allocate a symbol. 533 // Strings are canonicalized: Allocate a symbol.
533 current_token_.literal = &String::ZoneHandle( 534 current_token_.literal = &String::ZoneHandle(
534 String::NewSymbol(string_chars.data(), string_chars.length())); 535 String::NewSymbol(string_chars.data(), string_chars.length()));
(...skipping 355 matching lines...) Expand 10 before | Expand all | Expand 10 after
890 "%c%"PRIxPTR, kPrivateKeySeparator, key_value); 891 "%c%"PRIxPTR, kPrivateKeySeparator, key_value);
891 const String& result = String::Handle(String::New(private_key)); 892 const String& result = String::Handle(String::New(private_key));
892 return result.raw(); 893 return result.raw();
893 } 894 }
894 895
895 896
896 void Scanner::InitOnce() { 897 void Scanner::InitOnce() {
897 } 898 }
898 899
899 } // namespace dart 900 } // namespace dart
OLDNEW
« no previous file with comments | « no previous file | tests/language/language.status » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698