YamlSyntaxTree Class

Represents a parsed YAML syntax tree.

public sealed class YamlSyntaxTree

Properties

NameDescription
RootGets the root syntax node.
TextGets the original source text.
TokensGets parsed syntax tokens.

Gets the root syntax node.

public YamlSyntaxNode Root { get; }

Property value

YamlSyntaxNode

Gets the original source text.

public string Text { get; }

Property value

string

Gets parsed syntax tokens.

public IReadOnlyList<YamlSyntaxToken> Tokens { get; }

Methods

NameDescription
Parse(string, YamlSyntaxOptions?)Parses YAML text into a syntax tree.
ToFullString()Converts this syntax tree back to full text.
WriteTo(TextWriter)Writes the full original text to a writer.

Parse(string, YamlSyntaxOptions?)

YamlSyntaxTree.cs

Parses YAML text into a syntax tree.

public static YamlSyntaxTree Parse(string yaml, YamlSyntaxOptions? options = null)

Parameters

yaml string
The YAML text.
options YamlSyntaxOptions?
The syntax options.

Returns

YamlSyntaxTree A parsed syntax tree.

Exceptions

ArgumentNullException
yaml is null.
YamlException
The YAML content is invalid.

ToFullString()

YamlSyntaxTree.cs

Converts this syntax tree back to full text.

public string ToFullString()

Returns

string The full original text.

WriteTo(TextWriter)

YamlSyntaxTree.cs

Writes the full original text to a writer.

public void WriteTo(TextWriter writer)

Parameters

writer TextWriter
The destination writer.

Exceptions

ArgumentNullException
writer is null.