Search Results for

    Show / Hide Table of Contents

    Class CstNode

    One node or token of the concrete syntax tree of a Links Notation document.

    Inheritance
    object
    CstNode
    Inherited Members
    object.Equals(object)
    object.Equals(object, object)
    object.GetHashCode()
    object.GetType()
    object.ReferenceEquals(object, object)
    Namespace: Link.Foundation.Links.Notation
    Assembly: Link.Foundation.Links.Notation.dll
    Syntax
    public sealed class CstNode
    Remarks

    Every character of a document belongs to exactly one token, so the text of the tree is the document itself, comments, blank lines, indentation, quotes and line endings included. A Document holds Line nodes; a line holds the tokens up to and including its line ending, and a parenthesized Group holds its own parentheses and the lines written between them. A group is part of the line it opens on, however many lines it spans. Read a tree with ParseCst(string).

    Constructors

    | Edit this page View Source

    CstNode(CstKind, IEnumerable<CstNode>?)

    Creates a node.

    Declaration
    public CstNode(CstKind kind, IEnumerable<CstNode>? children = null)
    Parameters
    Type Name Description
    CstKind kind

    A node kind.

    IEnumerable<CstNode> children

    The node's children, in document order.

    Exceptions
    Type Condition
    ArgumentException

    kind is a token kind.

    | Edit this page View Source

    CstNode(CstKind, string, string?, char?)

    Creates a token.

    Declaration
    public CstNode(CstKind kind, string text, string? value = null, char? quote = null)
    Parameters
    Type Name Description
    CstKind kind

    A token kind.

    string text

    The token's text exactly as written.

    string value

    What a reference token means; null otherwise.

    char? quote

    The delimiter of a quoted reference token; null otherwise.

    Exceptions
    Type Condition
    ArgumentException

    kind is a node kind.

    Properties

    | Edit this page View Source

    Children

    The children of a node, in document order; empty for a token.

    Declaration
    public IReadOnlyList<CstNode> Children { get; }
    Property Value
    Type Description
    IReadOnlyList<CstNode>
    | Edit this page View Source

    IsToken

    Whether this is a token rather than a node with children.

    Declaration
    public bool IsToken { get; }
    Property Value
    Type Description
    bool
    | Edit this page View Source

    Kind

    The kind of this node or token.

    Declaration
    public CstKind Kind { get; }
    Property Value
    Type Description
    CstKind
    | Edit this page View Source

    Quote

    The delimiter a quoted reference token was written between (', " or `); null for a bare or literal reference and every other kind.

    Declaration
    public char? Quote { get; }
    Property Value
    Type Description
    char?
    | Edit this page View Source

    Text

    The exact text this node or token was read from: a token's own text, and the text of its children one after another for a node.

    Declaration
    public string Text { get; }
    Property Value
    Type Description
    string
    | Edit this page View Source

    Value

    What a reference token means, its delimiters and escapes resolved: the ID a parsed link has. null for every other node and token.

    Declaration
    public string? Value { get; }
    Property Value
    Type Description
    string

    Methods

    | Edit this page View Source

    ToSExpression()

    The tree as an S-expression: (kind child ...) for a node and kind:"text" for a token, the text with </code>, ", line feeds, carriage returns and tabs escaped. Every Links Notation implementation writes the same S-expression for the same document, and two trees are the same exactly when their S-expressions are.

    Declaration
    public string ToSExpression()
    Returns
    Type Description
    string

    The S-expression of this subtree.

    Examples

    new Parser().ParseCst("a '1'").ToSExpression() is (document (line reference:"a" whitespace:" " reference:"'1'")).

    | Edit this page View Source

    ToString()

    The exact text this node or token was read from; see Text.

    Declaration
    public override string ToString()
    Returns
    Type Description
    string

    The text of this node or token.

    Overrides
    object.ToString()
    | Edit this page View Source

    Tokens()

    Every token of this subtree, in document order; a token yields just itself.

    Declaration
    public IReadOnlyList<CstNode> Tokens()
    Returns
    Type Description
    IReadOnlyList<CstNode>

    The tokens of this subtree.

    • Edit this page
    • View Source
    In this article
    Back to top Generated by DocFX