OLD | NEW |
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 'dart:collection'; | 9 import 'dart:collection'; |
10 | 10 |
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
193 value = value * 16 + hexDigitValue(code); | 193 value = value * 16 + hexDigitValue(code); |
194 } | 194 } |
195 } | 195 } |
196 code = value; | 196 code = value; |
197 } | 197 } |
198 } | 198 } |
199 if (code >= 0x10000) { | 199 if (code >= 0x10000) { |
200 length++; | 200 length++; |
201 if (code > 0x10FFFF) { | 201 if (code > 0x10FFFF) { |
202 stringParseError("Invalid code point", token, index); | 202 stringParseError("Invalid code point", token, index); |
| 203 return null; |
203 } | 204 } |
204 } | 205 } |
205 } | 206 } |
206 // String literal successfully validated. | 207 // String literal successfully validated. |
207 if (quoting.raw || !containsEscape) { | 208 if (quoting.raw || !containsEscape) { |
208 // A string without escapes could just as well have been raw. | 209 // A string without escapes could just as well have been raw. |
209 return new DartString.rawString(string, length); | 210 return new DartString.rawString(string, length); |
210 } | 211 } |
211 return new DartString.escapedString(string, length); | 212 return new DartString.escapedString(string, length); |
212 } | 213 } |
213 } | 214 } |
OLD | NEW |