adapters

package
v0.1.9 Latest Latest
Warning

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

Go to latest
Published: Nov 21, 2025 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AutoRegisterer added in v0.1.7

type AutoRegisterer interface {
	Register(codex Codex) error
}

type Callable

type Callable interface {
	Node
	Call(ctx context.Context, funcName string, argValues ...Value) Value
}

Callable defines a node that can be called. It represents a function as a node.

type Codex

type Codex interface {
	Register(name string, constructor func([]KeyNode) (Node, error)) error
}

type DefinitionError

type DefinitionError interface {
	Key() string
}

type DefinitionNotCallableError

type DefinitionNotCallableError struct {
	DefinitionKey string
}

func (DefinitionNotCallableError) Error

func (DefinitionNotCallableError) Key

type DefinitionNotFoundError

type DefinitionNotFoundError struct {
	DefinitionKey string
}

func (DefinitionNotFoundError) Error

func (e DefinitionNotFoundError) Error() string

func (DefinitionNotFoundError) Key

type DefinitionReadWriter

type DefinitionReadWriter interface {
	DefinitionReader
	DefinitionWriter
}

type DefinitionReader

type DefinitionReader interface {
	Definition(key string) (Value, bool)
}

type DefinitionWriter

type DefinitionWriter interface {
	Define(key string, value Value) error
}

type IncompatiblePairError

type IncompatiblePairError struct {
	First  any
	Second any
}

func (IncompatiblePairError) Error

func (e IncompatiblePairError) Error() string

type InvalidDefinitionKey

type InvalidDefinitionKey struct {
	DefinitionKey string
}

func (InvalidDefinitionKey) Error

func (e InvalidDefinitionKey) Error() string

func (InvalidDefinitionKey) Key

func (e InvalidDefinitionKey) Key() string

type KeyNode

type KeyNode struct {
	Key  string
	Node Node
}

KeyNode defines a key-node pair, used for named parameters.

type Named

type Named interface {
	Scalar() string
}

Named abstracts a node scalar getter.

type Node

type Node interface {
	Named
	Eval(scope Scope) Value
}

Node is the building block of any expression. It can be used to represent values, evaluations or operations. Nodes can be evaluated under a scope.

type NodeError

type NodeError struct {
	NodeScalar string
	Cause      error
}

func NewNodeError

func NewNodeError(namedNode Named, err error) NodeError

func (NodeError) Error

func (e NodeError) Error() string

func (NodeError) Eval

func (e NodeError) Eval(scope Scope) Value

func (NodeError) Scalar

func (e NodeError) Scalar() string

func (NodeError) Unwrap

func (e NodeError) Unwrap() error

func (NodeError) Value

func (e NodeError) Value() any

type NodeType

type NodeType uint8
const (
	NodeTypeInvalid NodeType = iota
	// NodeTypeExpression represents an expression() node type. Example: if()
	NodeTypeExpression
	// NodeTypeReference represents a variable reference. Example: friend.name.
	NodeTypeReference
	// NodeTypeLiteral represents a direct value. Example: "string", 5.
	NodeTypeLiteral
)

func (NodeType) IsValid

func (t NodeType) IsValid() bool

type Scope

type Scope interface {
	context.Context
	DefinitionReader
	Compute(Node) (any, error)
}

Scope defines a block capable of evaluating expressions. It should be able to act as a context, as well as resolve definitions.

type SerializableNode added in v0.1.7

type SerializableNode interface {
	Node
	Named
	Typed
	Shaped
	AutoRegisterer
}

type Shaped

type Shaped interface {
	Shape() []KeyNode
}

Shaped defines a node capable of returning it's shape. The shape is a slice of named or unamed parameters required for constructing the node. This abstraction is used for constructing nodes from named parameters.

type StringError

type StringError string
const (
	ErrAllNodesMustMatch StringError = "all nodes must be of the same type"
	ErrAllNodesMustBeSet StringError = "all nodes must be set"
	ErrMustHaveArguments StringError = "must have at least one argument"
)

func (StringError) Error

func (e StringError) Error() string

type Typed

type Typed interface {
	Type() NodeType
}

Typed defines a node capable of returning it's NodeType. This interface is used for encoding and syntax purposes.

type Value

type Value interface {
	Node
	Valued
}

Value represents a value node, it can be used inside expressions or as definitions.

type Valued

type Valued interface {
	Value() any
}

Valued defines a value wrapper, any struct capable of returning it's internal value.

Jump to

Keyboard shortcuts

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