Chromium Code Reviews| 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 library dart.json; | 5 library dart.json; |
| 6 | 6 |
| 7 // JSON parsing and serialization. | 7 // JSON parsing and serialization. |
| 8 | 8 |
| 9 /** | 9 /** |
| 10 * Error thrown by JSON serialization if an object cannot be serialized. | 10 * Error thrown by JSON serialization if an object cannot be serialized. |
| (...skipping 484 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 495 // Format: '"'([^\x00-\x1f\\\"]|'\\'[bfnrt/\\"])*'"' | 495 // Format: '"'([^\x00-\x1f\\\"]|'\\'[bfnrt/\\"])*'"' |
| 496 // Initial position is right after first '"'. | 496 // Initial position is right after first '"'. |
| 497 int start = position; | 497 int start = position; |
| 498 int char; | 498 int char; |
| 499 do { | 499 do { |
| 500 if (position == source.length) { | 500 if (position == source.length) { |
| 501 fail(start - 1, "Unterminated string"); | 501 fail(start - 1, "Unterminated string"); |
| 502 } | 502 } |
| 503 char = source.codeUnitAt(position); | 503 char = source.codeUnitAt(position); |
| 504 if (char == QUOTE) { | 504 if (char == QUOTE) { |
| 505 listener.handleString(source.substring(start, position)); | 505 String result = source.substring(start, position); |
|
Søren Gjesse
2013/08/14 07:45:07
Why?
Lasse Reichstein Nielsen
2013/08/14 08:38:34
Needed it for debugging at some point.
I saw no r
| |
| 506 listener.handleString(result); | |
| 506 return position + 1; | 507 return position + 1; |
| 507 } | 508 } |
| 508 if (char < SPACE) { | 509 if (char < SPACE) { |
| 509 fail(position, "Control character in string"); | 510 fail(position, "Control character in string"); |
| 510 } | 511 } |
| 511 position++; | 512 position++; |
| 512 } while (char != BACKSLASH); | 513 } while (char != BACKSLASH); |
| 513 // Backslash escape detected. Collect character codes for rest of string. | 514 // Backslash escape detected. Collect character codes for rest of string. |
| 514 int firstEscape = position - 1; | 515 int firstEscape = position - 1; |
| 515 List<int> chars = <int>[]; | 516 List<int> chars = <int>[]; |
| (...skipping 301 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 817 first = false; | 818 first = false; |
| 818 }); | 819 }); |
| 819 sink.write('}'); | 820 sink.write('}'); |
| 820 seen.removeLast(); | 821 seen.removeLast(); |
| 821 return true; | 822 return true; |
| 822 } else { | 823 } else { |
| 823 return false; | 824 return false; |
| 824 } | 825 } |
| 825 } | 826 } |
| 826 } | 827 } |
| OLD | NEW |