eval

package
v0.1.5 Latest Latest
Warning

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

Go to latest
Published: Jul 11, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package eval evaluates cirql expressions against an environment: the current object (for field access), the variable bindings (for $var), and an injected clock (for now()). Field access propagates null and arithmetic follows jq's double model; division or modulo by zero yields null.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Eval

func Eval(e ast.Expr, env Env) (value.Value, error)

Eval evaluates e against env. A nil expression — possible only in a programmatically assembled pipeline, never from the parser — reports ErrNilExpr rather than panicking.

Types

type Env

type Env struct {
	Obj  value.Value
	Vars map[string]value.Value
	Now  func() int64 // epoch seconds; nil falls back to a zero clock
}

Env is the evaluation context for one expression.

type Error

type Error = errs.Const

Error is the sentinel-error type for the eval package — an alias of errs.Const from github.com/gomatic/go-error, which owns the mechanism (Error, With). The alias keeps every existing `eval.Error` reference and errors.Is match compiling and behaving identically.

const (
	// ErrUnknownFunc is returned when a called builtin does not exist.
	ErrUnknownFunc Error = "eval: unknown function"
	// ErrArity is returned when a builtin gets the wrong number of arguments.
	ErrArity Error = "eval: wrong argument count"
	// ErrType is returned when an operation gets an unsupported value type.
	ErrType Error = "eval: type error"
	// ErrNilExpr is returned when Eval is handed a nil expression — a pipeline
	// assembled programmatically with a missing Cond/Key/Expr, which the parser
	// never produces.
	ErrNilExpr Error = "eval: nil expression"
)

Jump to

Keyboard shortcuts

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