Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Branch ¶
type Branch struct { NodeBase // Children is the slice of child nodes for this Branch. Children []Node }
Branch is a CST node that can have children.
func (*Branch) First ¶
First returns the first child of the branch, or nil if the branch has no children.
type Fragment ¶
type Fragment interface { // Tok returns the underlying token of this fragment. Tok() Token // Write is used to write the underlying token out to the writer. Write(io.Writer) error }
Fragment is a component of a cst that is backed by a token. This includes Nodes and all forms of space and comment.
type Leaf ¶
Leaf nodes are part of the cst that cannot have child nodes, they represent a single token from the input.
type Node ¶
type Node interface { Fragment // Parent returns the Branch that this node is under. Parent() *Branch // SetParent replaces the Branch that this node is under. SetParent(*Branch) // Prefix returns the set of skippable fragments associated with this Node // that precede it in the stream. Association is defined by the Skip function // in use. Prefix() Separator // AddPrefix adds more fragments to the Prefix list. AddPrefix(Separator) // Suffix returns the set of skippable fragments associated with this Node // that follow it in the stream. Association is defined by the Skip function // in use, the default is until the end of the line. Suffix() Separator // AddSuffix adds more fragments to the Suffix list. AddSuffix(Separator) }
Node is a Fragment in a cst that represents unskipped tokens.
type NodeBase ¶
NodeBase implements the non-fragment parts of the Node interface. NodeBase is intended to be used as an anonymous field of types that implement the Node interface.
func (*NodeBase) Prefix ¶
Prefix returns the set of skippable fragments associated with this Node that precede it in the stream. Association is defined by the Skip function in use.
type Separator ¶
type Separator []Fragment
Separator is a list type to manage fragments that were skipped.
type Source ¶
type Source struct { Filename string // The path which was used to load the source (if any). Runes []rune // The full content of the source file. }
Source represents a source file.
func (Source) RelativeFilename ¶
RelativeFilename returns the filename relative to the current working directory.
type Token ¶
type Token struct { Source *Source // The source object this token is from (including the full rune array). Start int // The start of the token in the full rune array. End int // One past the end of the token. }
A Token represents the smallest consumed unit input.
func (Token) Cursor ¶
Cursor is used to calculate the line and column of the start of the token. It may be very expensive to call, and is intended to be used sparingly in producing human readable error messages only.
func (Token) Less ¶
Less returns true if t comes before rhs when considering source files and offsets within the same file.