ast

package
v1.4.15 Latest Latest
Warning

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

Go to latest
Published: Jul 31, 2024 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewArrayNode

func NewArrayNode(parent Node) *arrayNode

func NewMapNode

func NewMapNode(parent Node) *mapNode

func NewMapValueNode

func NewMapValueNode(parent Node, key string) (*valueNode, error)

func NewValueNode

func NewValueNode(parent Node, value any) *valueNode

Types

type Context

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

func NewContext

func NewContext(fn EvalFunc) *Context

func (*Context) Label

func (ctx *Context) Label() types.Label

Get the label

func (*Context) Path

func (ctx *Context) Path() types.Label

Return the current path

func (*Context) SetLabel

func (ctx *Context) SetLabel(label types.Label)

Set the label

type EvalFunc

type EvalFunc func(ctx *Context, value any) (any, error)

Evaluate a value node and return the value

type Node

type Node interface {
	// Type of node
	Type() NodeType

	// Parent node
	Parent() Node

	// Node key (plugin name, map key)
	Key() string

	// Node evaluated value
	Value(ctx *Context) (any, error)

	// Child nodes
	Children() []Node

	// Add child node, and return it
	Append(Node) Node
}

type NodeType

type NodeType int
const (
	Map NodeType
	Array
	Value
)

func (NodeType) String

func (r NodeType) String() string

Jump to

Keyboard shortcuts

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