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 | |
| 6 part of intl; | |
| 7 | |
| 5 /** | 8 /** |
| 6 * A class for holding onto the data for a date so that it can be built | 9 * A class for holding onto the data for a date so that it can be built |
| 7 * up incrementally. | 10 * up incrementally. |
| 8 */ | 11 */ |
| 9 class _DateBuilder { | 12 class _DateBuilder { |
| 10 // Default the date values to the EPOCH so that there's a valid date | 13 // Default the date values to the EPOCH so that there's a valid date |
| 11 // in case the format doesn't set them. | 14 // in case the format doesn't set them. |
| 12 int year = 1970, | 15 int year = 1970, |
| 13 month = 1, | 16 month = 1, |
| 14 day = 1, | 17 day = 1, |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 64 * lists or strings. | 67 * lists or strings. |
| 65 */ | 68 */ |
| 66 class _Stream { | 69 class _Stream { |
| 67 var contents; | 70 var contents; |
| 68 int index = 0; | 71 int index = 0; |
| 69 | 72 |
| 70 _Stream(this.contents); | 73 _Stream(this.contents); |
| 71 | 74 |
| 72 bool atEnd() => index >= contents.length; | 75 bool atEnd() => index >= contents.length; |
| 73 | 76 |
| 74 Dynamic next() => contents[index++]; | 77 Object next() => contents[index++]; |
|
Emily Fortuna
2012/10/31 20:17:32
will this no longer work now?
Alan Knight
2012/10/31 21:31:59
It would have to be small d dynamic. This is anoth
| |
| 75 | 78 |
| 76 /** | 79 /** |
| 77 * Return the next [howMany] items, or as many as there are remaining. | 80 * Return the next [howMany] items, or as many as there are remaining. |
| 78 * Advance the stream by that many positions. | 81 * Advance the stream by that many positions. |
| 79 */ | 82 */ |
| 80 read([howMany = 1]) { | 83 read([howMany = 1]) { |
| 81 var result = peek(howMany); | 84 var result = peek(howMany); |
| 82 index += howMany; | 85 index += howMany; |
| 83 return result; | 86 return result; |
| 84 } | 87 } |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 131 * can see and then return the corresponding integer. Advance the stream. | 134 * can see and then return the corresponding integer. Advance the stream. |
| 132 */ | 135 */ |
| 133 var digitMatcher = const RegExp(r'\d+'); | 136 var digitMatcher = const RegExp(r'\d+'); |
| 134 int nextInteger() { | 137 int nextInteger() { |
| 135 var string = digitMatcher.stringMatch(rest()); | 138 var string = digitMatcher.stringMatch(rest()); |
| 136 if (string == null || string.isEmpty) return null; | 139 if (string == null || string.isEmpty) return null; |
| 137 read(string.length); | 140 read(string.length); |
| 138 return int.parse(string); | 141 return int.parse(string); |
| 139 } | 142 } |
| 140 } | 143 } |
| OLD | NEW |