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

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

Issue 11368138: Add some support for the code-point code-unit distinction. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Implemented feedback from patch set 3 Created 8 years, 1 month 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 "dart2jslib.dart"; 9 import "dart2jslib.dart";
10 import "tree/tree.dart"; 10 import "tree/tree.dart";
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after
161 stringParseError("Invalid character in escape sequence", 161 stringParseError("Invalid character in escape sequence",
162 token, index); 162 token, index);
163 return null; 163 return null;
164 } 164 }
165 value = value * 16 + hexDigitValue(code); 165 value = value * 16 + hexDigitValue(code);
166 } 166 }
167 } 167 }
168 code = value; 168 code = value;
169 } 169 }
170 } 170 }
171 // TODO(erikcorry): Use the string code point iterator when available.
172 if (code >= String.SMP_CODE_POINT_BASE) ++length;;
171 // This handles both unescaped characters and the value of unicode 173 // This handles both unescaped characters and the value of unicode
172 // escapes. 174 // escapes.
173 if (!isUnicodeScalarValue(code)) { 175 if (!isUnicodeScalarValue(code)) {
174 stringParseError( 176 stringParseError(
175 "Invalid Unicode scalar value U+${code.toRadixString(16)}", 177 "Invalid Unicode scalar value U+${code.toRadixString(16)}",
176 token, index); 178 token, index);
177 return null; 179 return null;
178 } 180 }
179 } 181 }
180 // String literal successfully validated. 182 // String literal successfully validated.
181 if (quoting.raw || !containsEscape) { 183 if (quoting.raw || !containsEscape) {
182 // A string without escapes could just as well have been raw. 184 // A string without escapes could just as well have been raw.
183 return new DartString.rawString(string, length); 185 return new DartString.rawString(string, length);
184 } 186 }
185 return new DartString.escapedString(string, length); 187 return new DartString.escapedString(string, length);
186 } 188 }
187 } 189 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698