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 /** | 5 /** |
6 * Takes a parsed YAML document (what the spec calls the "serialization tree") | 6 * Takes a parsed YAML document (what the spec calls the "serialization tree") |
7 * and resolves aliases, resolves tags, and parses scalars to produce the | 7 * and resolves aliases, resolves tags, and parses scalars to produce the |
8 * "representation graph". | 8 * "representation graph". |
9 */ | 9 */ |
10 class _Composer extends _Visitor { | 10 class _Composer extends _Visitor { |
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
123 var match = const RegExp("^[-+]?[0-9]+\$").firstMatch(content); | 123 var match = const RegExp("^[-+]?[0-9]+\$").firstMatch(content); |
124 if (match != null) { | 124 if (match != null) { |
125 return new _ScalarNode(_Tag.yaml("int"), | 125 return new _ScalarNode(_Tag.yaml("int"), |
126 value: Math.parseInt(match.group(0))); | 126 value: Math.parseInt(match.group(0))); |
127 } | 127 } |
128 | 128 |
129 match = const RegExp("^0o([0-7]+)\$").firstMatch(content); | 129 match = const RegExp("^0o([0-7]+)\$").firstMatch(content); |
130 if (match != null) { | 130 if (match != null) { |
131 // TODO(nweiz): clean this up when Dart can parse an octal string | 131 // TODO(nweiz): clean this up when Dart can parse an octal string |
132 var n = 0; | 132 var n = 0; |
133 for (var c in match.group(1).charCodes()) { | 133 for (var c in match.group(1).charCodes) { |
134 n *= 8; | 134 n *= 8; |
135 n += c - 48; | 135 n += c - 48; |
136 } | 136 } |
137 return new _ScalarNode(_Tag.yaml("int"), value: n); | 137 return new _ScalarNode(_Tag.yaml("int"), value: n); |
138 } | 138 } |
139 | 139 |
140 match = const RegExp("^0x[0-9a-fA-F]+\$").firstMatch(content); | 140 match = const RegExp("^0x[0-9a-fA-F]+\$").firstMatch(content); |
141 if (match != null) { | 141 if (match != null) { |
142 return new _ScalarNode(_Tag.yaml("int"), | 142 return new _ScalarNode(_Tag.yaml("int"), |
143 value: Math.parseInt(match.group(0))); | 143 value: Math.parseInt(match.group(0))); |
(...skipping 28 matching lines...) Expand all Loading... |
172 value: Math.parseDouble("NaN")); | 172 value: Math.parseDouble("NaN")); |
173 } | 173 } |
174 | 174 |
175 return null; | 175 return null; |
176 } | 176 } |
177 | 177 |
178 /** Parses a string scalar. */ | 178 /** Parses a string scalar. */ |
179 _ScalarNode parseString(String content) => | 179 _ScalarNode parseString(String content) => |
180 new _ScalarNode(_Tag.yaml("str"), value: content); | 180 new _ScalarNode(_Tag.yaml("str"), value: content); |
181 } | 181 } |
OLD | NEW |