ast

package
v0.0.0-...-dfb39b5 Latest Latest
Warning

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

Go to latest
Published: Aug 2, 2026 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Eval

func Eval(node *ASTNode, scope map[string]*expr.Vars) (expr.TypedValue, error)

Eval evaluates the given AST tree with provided vars

func EvalBool

func EvalBool(node *ASTNode, scope map[string]*expr.Vars) (bool, error)

EvalBool evaluates node and casts the result to a bool.

func TypeRegistry

func TypeRegistry(ref string) expr.Type

TypeRegistry is a simplified type registry for the types that AST nodes need to understand.

Types

type ASTNode

type ASTNode struct {
	// Meta holds additional node data such as scope references
	Meta map[string]any `json:"meta,omitempty"`

	Ref  string     `json:"ref,omitempty"`
	Args ASTNodeSet `json:"args,omitempty"`

	Symbol string      `json:"symbol,omitempty"`
	Value  *TypedValue `json:"value,omitempty"`

	Raw string `json:"raw,omitempty"`
}

func MergeAnd

func MergeAnd(a, b *ASTNode) *ASTNode

func MergeOr

func MergeOr(a, b *ASTNode) *ASTNode

func (ASTNode) Clone

func (n ASTNode) Clone() *ASTNode

func (*ASTNode) CollectSymbols

func (n *ASTNode) CollectSymbols() (out []string)

func (*ASTNode) String

func (n *ASTNode) String() string

func (*ASTNode) Traverse

func (n *ASTNode) Traverse(f func(*ASTNode) (bool, *ASTNode, error)) (err error)

Traverse traverses the AST down to leaf nodes.

If fnc. returns false, the traversal of the current branch ends.

type ASTNodeSet

type ASTNodeSet []*ASTNode

type TypedValue

type TypedValue struct {
	V expr.TypedValue
}

func MakeValueOf

func MakeValueOf(t string, v interface{}) *TypedValue

func WrapValue

func WrapValue(v expr.TypedValue) *TypedValue

func (*TypedValue) MarshalJSON

func (t *TypedValue) MarshalJSON() ([]byte, error)

func (*TypedValue) UnmarshalJSON

func (t *TypedValue) UnmarshalJSON(in []byte) (err error)

Jump to

Keyboard shortcuts

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