script

package
v0.0.0-...-5db1884 Latest Latest
Warning

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

Go to latest
Published: Apr 7, 2026 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Overview

Package script implements script environments for engine steps and predicates

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrAleCompile = errors.New("script compile error")
	ErrAleCall    = errors.New("error calling procedure")
)
View Source
var (
	ErrJPathCompile = errors.New("jpath compile error")
	ErrJPathNoMatch = errors.New("jpath produced no matches")
)
View Source
var (
	ErrLuaLoad      = errors.New("lua load error")
	ErrLuaExecution = errors.New("lua execution error")
)

Functions

This section is empty.

Types

type AleEnv

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

AleEnv provides an Ale script execution environment

func NewAleEnv

func NewAleEnv() *AleEnv

NewAleEnv creates a new Ale script execution environment with the standard library bootstrapped

func (AleEnv) Compile

func (c AleEnv) Compile(
	step *api.Step, cfg *api.ScriptConfig,
) (Compiled, error)

func (*AleEnv) EvaluatePredicate

func (e *AleEnv) EvaluatePredicate(
	c Compiled, step *api.Step, inputs api.Args,
) (bool, error)

EvaluatePredicate executes a compiled Ale predicate with the provided inputs and returns the boolean result

func (*AleEnv) ExecuteScript

func (e *AleEnv) ExecuteScript(
	c Compiled, step *api.Step, inputs api.Args,
) (api.Args, error)

ExecuteScript runs a compiled Ale procedure with the provided inputs and returns the output arguments

func (AleEnv) Validate

func (c AleEnv) Validate(step *api.Step, script string) error

type Compiled

type Compiled any

Compiled represents a compiled script for any supported language

type CompiledLua

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

CompiledLua represents a compiled Lua script

type Environment

type Environment interface {
	// Validate checks if a script is syntactically valid
	Validate(step *api.Step, script string) error

	// Compile compiles a script and returns the compiled form
	Compile(step *api.Step, cfg *api.ScriptConfig) (Compiled, error)

	// ExecuteScript executes a compiled script with the given inputs
	ExecuteScript(
		c Compiled, step *api.Step, inputs api.Args,
	) (api.Args, error)

	// EvaluatePredicate evaluates a compiled predicate with given inputs
	EvaluatePredicate(
		c Compiled, step *api.Step, inputs api.Args,
	) (bool, error)
}

Environment defines the interface for script environments

type JPathEnv

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

JPathEnv provides JPath predicate evaluation

func NewJPathEnv

func NewJPathEnv() *JPathEnv

NewJPathEnv creates a JPath predicate evaluation environment

func (JPathEnv) Compile

func (c JPathEnv) Compile(
	step *api.Step, cfg *api.ScriptConfig,
) (Compiled, error)

func (*JPathEnv) EvaluatePredicate

func (e *JPathEnv) EvaluatePredicate(
	c Compiled, _ *api.Step, inputs api.Args,
) (bool, error)

EvaluatePredicate applies the compiled JPath expression and treats any match as predicate success, including explicit null matches

func (*JPathEnv) ExecuteScript

func (e *JPathEnv) ExecuteScript(
	c Compiled, _ *api.Step, inputs api.Args,
) (api.Args, error)

ExecuteScript evaluates a compiled JPath expression against mapping inputs

func (JPathEnv) Validate

func (c JPathEnv) Validate(step *api.Step, script string) error

type LuaEnv

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

LuaEnv provides a Lua script execution environment with state pooling

func NewLuaEnv

func NewLuaEnv() *LuaEnv

NewLuaEnv creates a new Lua script execution environment with a state pool for efficient script reuse

func (LuaEnv) Compile

func (c LuaEnv) Compile(
	step *api.Step, cfg *api.ScriptConfig,
) (Compiled, error)

func (*LuaEnv) EvaluatePredicate

func (e *LuaEnv) EvaluatePredicate(
	c Compiled, _ *api.Step, inputs api.Args,
) (bool, error)

EvaluatePredicate executes a compiled Lua predicate with the provided inputs and returns the boolean result

func (*LuaEnv) ExecuteScript

func (e *LuaEnv) ExecuteScript(
	c Compiled, _ *api.Step, inputs api.Args,
) (api.Args, error)

ExecuteScript runs a compiled Lua script with the provided inputs and returns the output arguments

func (LuaEnv) Validate

func (c LuaEnv) Validate(step *api.Step, script string) error

type Registry

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

Registry manages script environments for different languages

func NewRegistry

func NewRegistry() *Registry

NewRegistry creates a new registry with Ale, JPath and Lua environments

func (*Registry) Compile

func (r *Registry) Compile(
	step *api.Step, cfg *api.ScriptConfig,
) (Compiled, error)

Compile compiles a script config

func (*Registry) Get

func (r *Registry) Get(language string) (Environment, error)

Get returns the script environment for the given language

func (*Registry) Register

func (r *Registry) Register(language string, env Environment)

Jump to

Keyboard shortcuts

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