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

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

Issue 10153004: Add a basic YAML processor. Much of the language is still unimplemented. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Remove tests/lib from TEST_SUITE_DIRECTORIES. Created 8 years, 8 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
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 #source("yaml_map.dart");
8 #source("model.dart");
9 #source("parser.dart");
10 #source("visitor.dart");
11 #source("composer.dart");
12 #source("constructor.dart");
13
14 /**
15 * Loads a single document from a YAML string. If the string contains more than
16 * one document, this throws an error.
17 *
18 * The return value is mostly normal Dart objects. However, since YAML mappings
19 * support some key types that the default Dart map implementation doesn't
20 * (null, NaN, booleans, lists, and maps), all maps in the returned document are
21 * YamlMaps. These have a few small behavioral differences from the default Map
22 * implementation; for details, see the YamlMap class.
23 */
24 load(String yaml) {
25 var stream = loadStream(yaml);
26 if (stream.length != 1) {
27 throw new Error("Expected 1 document, were ${stream.length}");
28 }
29 return stream[0];
30 }
31
32 /**
33 * Loads a stream of documents from a YAML string.
34 *
35 * The return value is mostly normal Dart objects. However, since YAML mappings
36 * support some key types that the default Dart map implementation doesn't
37 * (null, NaN, booleans, lists, and maps), all maps in the returned document are
38 * YamlMaps. These have a few small behavioral differences from the default Map
39 * implementation; for details, see the YamlMap class.
40 */
41 List loadStream(String yaml) {
42 var tok = new _Parser(yaml);
43 return tok._l_yamlStream().map((doc) =>
44 new _Constructor(new _Composer(doc).compose()).construct());
45 }
46
47 /** An error thrown by the YAML processor. */
48 class Error implements Exception {
49 String _msg;
50
51 Error(String this._msg);
52
53 String toString() => _msg;
54 }
OLDNEW
« utils/yaml/parser.dart ('K') | « utils/yaml/visitor.dart ('k') | utils/yaml/yaml_map.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698