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

Unified Diff: utils/yaml/visitor.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: Code review changes 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 side-by-side diff with in-line comments
Download patch
Index: utils/yaml/visitor.dart
diff --git a/utils/yaml/visitor.dart b/utils/yaml/visitor.dart
new file mode 100644
index 0000000000000000000000000000000000000000..744bcd7388e7be1f74170f06ce1b62f043db56a3
--- /dev/null
+++ b/utils/yaml/visitor.dart
@@ -0,0 +1,24 @@
+// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+/** The visitor pattern for YAML documents. */
+class _Visitor {
+ /** Returns [alias]. */
+ visitAlias(_AliasNode alias) => alias;
+
+ /** Returns [scalar]. */
+ visitScalar(_ScalarNode scalar) => scalar;
+
+ /** Visits each node in [seq] and returns a list of the results. */
+ visitSequence(_SequenceNode seq) => seq.content.map((e) => e.visit(this));
+
+ /** Visits each key and value in [map] and returns a map of the results. */
+ visitMapping(_MappingNode map) {
+ var out = new YamlMap();
+ for (var key in map.content.getKeys()) {
+ out[key.visit(this)] = map.content[key].visit(this);
+ }
+ return out;
+ }
+}
« utils/yaml/parser.dart ('K') | « utils/yaml/parser.dart ('k') | utils/yaml/yaml.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698