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

Unified Diff: pkg/yaml/lib/src/yaml_document.dart

Issue 689513002: Rewrite the pkg/yaml parser. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Code review changes Created 6 years, 1 month 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
« no previous file with comments | « pkg/yaml/lib/src/visitor.dart ('k') | pkg/yaml/lib/src/yaml_node.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/yaml/lib/src/yaml_document.dart
diff --git a/pkg/yaml/lib/src/yaml_document.dart b/pkg/yaml/lib/src/yaml_document.dart
new file mode 100644
index 0000000000000000000000000000000000000000..4c249a0c1fa8827eae57e3cb81fc978b98204550
--- /dev/null
+++ b/pkg/yaml/lib/src/yaml_document.dart
@@ -0,0 +1,67 @@
+// Copyright (c) 2014, 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.
+
+library yaml.yaml_document;
+
+import 'dart:collection';
+
+import 'package:source_span/source_span.dart';
+
+import 'yaml_node.dart';
+
+/// A YAML document, complete with metadata.
+class YamlDocument {
+ /// The contents of the document.
+ final YamlNode contents;
+
+ /// The span covering the entire document.
+ final SourceSpan span;
+
+ /// The version directive for the document, if any.
+ final VersionDirective versionDirective;
+
+ /// The tag directives for the document.
+ final List<TagDirective> tagDirectives;
+
+ /// Whether the beginning of the document was implicit (versus explicit via
+ /// `===`).
+ final bool startImplicit;
+
+ /// Whether the end of the document was implicit (versus explicit via `...`).
+ final bool endImplicit;
+
+ /// Users of the library should not use this constructor.
+ YamlDocument.internal(this.contents, this.span, this.versionDirective,
+ List<TagDirective> tagDirectives, {this.startImplicit: false,
+ this.endImplicit: false})
+ : tagDirectives = new UnmodifiableListView(tagDirectives);
+
+ String toString() => contents.toString();
+}
+
+/// A directive indicating which version of YAML a document was written to.
+class VersionDirective {
+ /// The major version number.
+ final int major;
+
+ /// The minor version number.
+ final int minor;
+
+ VersionDirective(this.major, this.minor);
+
+ String toString() => "%YAML $major.$minor";
+}
+
+/// A directive describing a custom tag handle.
+class TagDirective {
+ /// The handle for use in the document.
+ final String handle;
+
+ /// The prefix that the handle maps to.
+ final String prefix;
+
+ TagDirective(this.handle, this.prefix);
+
+ String toString() => "%TAG $handle $prefix";
+}
« no previous file with comments | « pkg/yaml/lib/src/visitor.dart ('k') | pkg/yaml/lib/src/yaml_node.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698