match

package
v0.20.0 Latest Latest
Warning

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

Go to latest
Published: Oct 8, 2026 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const ID = "match"

Variables

This section is empty.

Functions

func Bundle

func Bundle(_ map[string]string) core.Bundle

func CompileCondition added in v0.16.0

func CompileCondition(source string) (*vm.Program, error)

CompileCondition compiles an expression using Flow's input-dot syntax.

func EvaluateProgram added in v0.16.0

func EvaluateProgram(program *vm.Program, env map[string]any) (any, error)

EvaluateProgram runs a compiled condition or subject expression.

func FirstMatchingCase added in v0.16.0

func FirstMatchingCase(cases []ConditionCase, env map[string]any) int

FirstMatchingCase returns the first condition that evaluates to true, or the first default case reached in order. Evaluation failures are skipped, matching the existing match and @on_error behavior.

func KindEnvironment added in v0.16.0

func KindEnvironment() map[string]any

KindEnvironment returns fresh bindings for symbolic Kernel kinds.

func KindEnvironmentFor added in v0.16.0

func KindEnvironmentFor(kindValue any) map[string]any

KindEnvironmentFor returns symbolic bindings with the same runtime representation as kindValue. Legacy @on_error exposes error.kind as a string; expression guards expose it as xerr.Kind.

func KindSymbol added in v0.16.0

func KindSymbol(kind xerr.Kind) string

KindSymbol returns the source spelling of a built-in Kernel kind.

func ResolveKindSymbol added in v0.16.0

func ResolveKindSymbol(symbol string) (xerr.Kind, bool)

ResolveKindSymbol maps a symbolic Flow name to one of the built-in Kernel kinds. It intentionally does not treat xerr.Kind as a closed runtime set: custom values remain possible and are handled by explicit else cases.

func WithKindEnvironment added in v0.16.0

func WithKindEnvironment(env map[string]any) map[string]any

WithKindEnvironment returns a fresh expression environment with built-in Kernel kind symbols added under xerr. The caller's map is never mutated.

Types

type Case

type Case struct {
	Condition string
	IsDefault bool
	Body      core.Expr
}

type ConditionCase added in v0.16.0

type ConditionCase struct {
	Program   *vm.Program
	IsDefault bool
}

ConditionCase is one ordered expression condition, or a default branch. A nil Program is skipped unless IsDefault is true.

type Expr

type Expr struct {
	Subject string
	Cases   []Case
}

func (*Expr) Analyze

func (m *Expr) Analyze(resolver core.CapabilityResolver) error

func (*Expr) Build

func (m *Expr) Build(ctx context.Context, bCtx *core.BuildContext) (action.AnyAction, error)

func (*Expr) Children

func (m *Expr) Children() []core.Expr

func (*Expr) Node

func (*Expr) Node()

Jump to

Keyboard shortcuts

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