Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(121)

Side by Side Diff: utils/pub/yaml/yaml.dart

Issue 11622011: Restructure YAML package suitable for pub lish (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: add yaml exclude Created 7 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « utils/pub/yaml/visitor.dart ('k') | utils/pub/yaml/yaml_map.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // BSD-style license that can be found in the LICENSE file.
4
5 library yaml;
6
7 import 'dart:math' as Math;
8 import 'dart:collection' show Queue;
9
10 import 'deep_equals.dart';
11
12 part 'yaml_map.dart';
13 part 'model.dart';
14 part 'parser.dart';
15 part 'visitor.dart';
16 part 'composer.dart';
17 part 'constructor.dart';
18
19 /// Loads a single document from a YAML string. If the string contains more than
20 /// one document, this throws an error.
21 ///
22 /// The return value is mostly normal Dart objects. However, since YAML mappings
23 /// support some key types that the default Dart map implementation doesn't
24 /// (null, NaN, booleans, lists, and maps), all maps in the returned document
25 /// are YamlMaps. These have a few small behavioral differences from the default
26 /// Map implementation; for details, see the YamlMap class.
27 loadYaml(String yaml) {
28 var stream = loadYamlStream(yaml);
29 if (stream.length != 1) {
30 throw new YamlException("Expected 1 document, were ${stream.length}");
31 }
32 return stream[0];
33 }
34
35 /// Loads a stream of documents from a YAML string.
36 ///
37 /// The return value is mostly normal Dart objects. However, since YAML mappings
38 /// support some key types that the default Dart map implementation doesn't
39 /// (null, NaN, booleans, lists, and maps), all maps in the returned document
40 /// are YamlMaps. These have a few small behavioral differences from the default
41 /// Map implementation; for details, see the YamlMap class.
42 List loadYamlStream(String yaml) {
43 return new _Parser(yaml).l_yamlStream().mappedBy((doc) =>
44 new _Constructor(new _Composer(doc).compose()).construct())
45 .toList();
46 }
47
48 /// An error thrown by the YAML processor.
49 class YamlException implements Exception {
50 String msg;
51
52 YamlException(this.msg);
53
54 String toString() => msg;
55 }
OLDNEW
« no previous file with comments | « utils/pub/yaml/visitor.dart ('k') | utils/pub/yaml/yaml_map.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698