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

Side by Side Diff: lib/compiler/implementation/string_validator.dart

Issue 10920066: issue 4817 fixed. Implemented raw strings with 'r' instead of '@' for dart2js (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Rebased. Marked raw_string_test as pass for dart2js-ff and dart2dart Created 8 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
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 // Check the validity of string literals. 5 // Check the validity of string literals.
6 6
7 #library("stringvalidator"); 7 #library("stringvalidator");
8 8
9 #import("leg.dart"); 9 #import("leg.dart");
10 #import("scanner/scannerlib.dart"); 10 #import("scanner/scannerlib.dart");
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
42 token.charOffset + leftQuote, 42 token.charOffset + leftQuote,
43 content, 43 content,
44 quoting); 44 quoting);
45 } 45 }
46 46
47 static StringQuoting quotingFromString(SourceString sourceString) { 47 static StringQuoting quotingFromString(SourceString sourceString) {
48 Iterator<int> source = sourceString.iterator(); 48 Iterator<int> source = sourceString.iterator();
49 bool raw = false; 49 bool raw = false;
50 int quoteLength = 1; 50 int quoteLength = 1;
51 int quoteChar = source.next(); 51 int quoteChar = source.next();
52 if (quoteChar == $AT) { 52 // TODO(aprelev@gmail.com): Remove deprecated "quoteChar === $AT ||" below.
53 if (quoteChar === $AT || quoteChar === $r) {
53 raw = true; 54 raw = true;
54 quoteChar = source.next(); 55 quoteChar = source.next();
55 } 56 }
56 assert(quoteChar === $SQ || quoteChar === $DQ); 57 assert(quoteChar === $SQ || quoteChar === $DQ);
57 // String has at least one quote. Check it if has three. 58 // String has at least one quote. Check it if has three.
58 // If it only have two, the string must be an empty string literal, 59 // If it only have two, the string must be an empty string literal,
59 // and end after the second quote. 60 // and end after the second quote.
60 bool multiline = false; 61 bool multiline = false;
61 if (source.hasNext() && source.next() === quoteChar && source.hasNext()) { 62 if (source.hasNext() && source.next() === quoteChar && source.hasNext()) {
62 int code = source.next(); 63 int code = source.next();
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
178 } 179 }
179 } 180 }
180 // String literal successfully validated. 181 // String literal successfully validated.
181 if (quoting.raw || !containsEscape) { 182 if (quoting.raw || !containsEscape) {
182 // A string without escapes could just as well have been raw. 183 // A string without escapes could just as well have been raw.
183 return new DartString.rawString(string, length); 184 return new DartString.rawString(string, length);
184 } 185 }
185 return new DartString.escapedString(string, length); 186 return new DartString.escapedString(string, length);
186 } 187 }
187 } 188 }
OLDNEW
« no previous file with comments | « lib/compiler/implementation/scanner/scanner.dart ('k') | tests/compiler/dart2js/array_static_intercept_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698