| 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 /// A parser for [YAML](http://www.yaml.org/). | 5 /// A parser for [YAML](http://www.yaml.org/). |
| 6 /// | 6 /// |
| 7 /// Use [loadYaml] to load a single document, or [loadYamlStream] to load a | 7 /// Use [loadYaml] to load a single document, or [loadYamlStream] to load a |
| 8 /// stream of documents. For example: | 8 /// stream of documents. For example: |
| 9 /// | 9 /// |
| 10 /// import 'package:yaml/yaml.dart'; | 10 /// import 'package:yaml/yaml.dart'; |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 53 } | 53 } |
| 54 | 54 |
| 55 /// Loads a stream of documents from a YAML string. | 55 /// Loads a stream of documents from a YAML string. |
| 56 /// | 56 /// |
| 57 /// The return value is mostly normal Dart objects. However, since YAML mappings | 57 /// The return value is mostly normal Dart objects. However, since YAML mappings |
| 58 /// support some key types that the default Dart map implementation doesn't | 58 /// support some key types that the default Dart map implementation doesn't |
| 59 /// (null, NaN, booleans, lists, and maps), all maps in the returned document | 59 /// (null, NaN, booleans, lists, and maps), all maps in the returned document |
| 60 /// are YamlMaps. These have a few small behavioral differences from the default | 60 /// are YamlMaps. These have a few small behavioral differences from the default |
| 61 /// Map implementation; for details, see the YamlMap class. | 61 /// Map implementation; for details, see the YamlMap class. |
| 62 List loadYamlStream(String yaml) { | 62 List loadYamlStream(String yaml) { |
| 63 return new _Parser(yaml).l_yamlStream().mappedBy((doc) => | 63 return new _Parser(yaml).l_yamlStream() |
| 64 new _Constructor(new _Composer(doc).compose()).construct()) | 64 .map((doc) => new _Constructor(new _Composer(doc).compose()).construct()) |
| 65 .toList(); | 65 .toList(); |
| 66 } | 66 } |
| 67 | 67 |
| 68 /// An error thrown by the YAML processor. | 68 /// An error thrown by the YAML processor. |
| 69 class YamlException implements Exception { | 69 class YamlException implements Exception { |
| 70 String msg; | 70 String msg; |
| 71 | 71 |
| 72 YamlException(this.msg); | 72 YamlException(this.msg); |
| 73 | 73 |
| 74 String toString() => msg; | 74 String toString() => msg; |
| 75 } | 75 } |
| OLD | NEW |