ast

package
v0.3.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 16, 2024 License: MIT Imports: 4 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Document

type Document struct {
	// contains filtered or unexported fields
}

Document represents an abstract syntax tree document.

func (*Document) Append

func (d *Document) Append(node Node)

Append appends a node to the list of children nodes in the document.

func (*Document) Children

func (d *Document) Children() []Node

Children returns the children nodes of the document.

func (*Document) MarshalJSON

func (d *Document) MarshalJSON() ([]byte, error)

MarshalJSON returns the JSON encoding of the document.

func (*Document) String

func (d *Document) String() string

String returns a string representation of the document.

type Node

type Node interface {
	// String returns a string representation of the node.
	String() string
	// Children returns the children nodes of the node.
	Children() []Node
	// Append appends a child node to the node.
	Append(node Node)
}

Node represents a node in an abstract syntax tree.

type TemplateNode

type TemplateNode struct {
	// Token is the token associated with the template node.
	Token *token.Token
	// Closed indicates whether the template tag is closed.
	Closed bool
	// Ident is the identifier of the template tag.
	Ident string
	// contains filtered or unexported fields
}

TemplateNode represents a node in the abstract syntax tree corresponding to a template tag.

func NewTemplateNode

func NewTemplateNode(tok *token.Token) *TemplateNode

NewTemplateNode creates a new TemplateNode instance from the given token.

func (*TemplateNode) Append

func (tn *TemplateNode) Append(node Node)

Append appends a child node to the template node.

func (*TemplateNode) Children

func (tn *TemplateNode) Children() []Node

Children returns the children nodes of the template node.

func (*TemplateNode) MarshalJSON

func (tn *TemplateNode) MarshalJSON() ([]byte, error)

MarshalJSON returns the JSON encoding of the template node.

func (*TemplateNode) String

func (tn *TemplateNode) String() string

String returns the string representation of the template node.

type TextNode

type TextNode struct {
	// Token is the token associated with the text node.
	Token *token.Token
}

TextNode represents a node in the abstract syntax tree corresponding to text.

func (*TextNode) Append

func (tn *TextNode) Append(node Node)

Append panics when attempting to append a child node to a text node, as text nodes cannot have children.

func (*TextNode) Children

func (tn *TextNode) Children() []Node

Children returns nil for text nodes as they do not have children.

func (*TextNode) MarshalJSON

func (tn *TextNode) MarshalJSON() ([]byte, error)

MarshalJSON returns the JSON encoding of the text node.

func (*TextNode) String

func (tn *TextNode) String() string

String returns the string representation of the text node.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL