ucl

package
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: Mar 14, 2026 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrHalt = errors.New("halt")
View Source
var (
	ErrNotConvertable = errors.New("result not convertable to go")
)

Functions

func LineHandler

func LineHandler(line func(string)) io.Writer

func ObjectToString

func ObjectToString(obj Object) string

func ObjectsEqual

func ObjectsEqual(l, r Object) bool

Types

type BoolObject

type BoolObject bool

func (BoolObject) String

func (b BoolObject) String() string

func (BoolObject) Truthy

func (b BoolObject) Truthy() bool

type BuiltinHandler

type BuiltinHandler func(ctx context.Context, args CallArgs) (any, error)

type CallArgs

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

func (*CallArgs) Bind

func (ca *CallArgs) Bind(vars ...interface{}) error

func (CallArgs) BindSwitch

func (ca CallArgs) BindSwitch(name string, val interface{}) error

func (*CallArgs) CanBind

func (ca *CallArgs) CanBind(vars ...interface{}) bool

func (CallArgs) HasSwitch

func (ca CallArgs) HasSwitch(name string) bool

func (CallArgs) IsTopLevel

func (ca CallArgs) IsTopLevel() bool

func (*CallArgs) NArgs

func (ca *CallArgs) NArgs() int

func (*CallArgs) RestAsObjects

func (ca *CallArgs) RestAsObjects() []Object

func (*CallArgs) Shift

func (ca *CallArgs) Shift(n int)

type EchoPrinter

type EchoPrinter func(ctx context.Context, w io.Writer, args []any) error

type ErrRuntime

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

func (ErrRuntime) Error

func (e ErrRuntime) Error() string

type EvalOption

type EvalOption func(*evalOptions)

func WithSubEnv

func WithSubEnv() EvalOption

type GoFunction

type GoFunction func(ctx context.Context, args CallArgs) (any, error)

func (GoFunction) String

func (gf GoFunction) String() string

func (GoFunction) Truthy

func (gf GoFunction) Truthy() bool

type HashObject

type HashObject map[string]Object

func (HashObject) Each

func (s HashObject) Each(fn func(k string, v Object) error) error

func (HashObject) Len

func (s HashObject) Len() int

func (HashObject) SetValue

func (s HashObject) SetValue(k string, val Object) error

func (HashObject) String

func (s HashObject) String() string

func (HashObject) Truthy

func (s HashObject) Truthy() bool

func (HashObject) Value

func (s HashObject) Value(k string) Object

type Hashable

type Hashable interface {
	Len() int
	Value(k string) Object
	Each(func(k string, v Object) error) error
}

type Inst

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

func New

func New(opts ...InstOption) *Inst

func (*Inst) Eval

func (inst *Inst) Eval(ctx context.Context, r io.Reader, options ...EvalOption) (any, error)

func (*Inst) EvalString

func (inst *Inst) EvalString(ctx context.Context, expr string) (any, error)

func (*Inst) Out

func (inst *Inst) Out() io.Writer

func (*Inst) SetBuiltin

func (inst *Inst) SetBuiltin(name string, fn BuiltinHandler)

func (*Inst) SetBuiltinInvokable

func (inst *Inst) SetBuiltinInvokable(name string, fn Invokable)

func (*Inst) SetMissingPseudoVarHandler

func (inst *Inst) SetMissingPseudoVarHandler(h MissingPseudoVarHandler)

func (*Inst) SetPseudoVar

func (inst *Inst) SetPseudoVar(name string, h PseudoVarHandler)

func (*Inst) SetVar

func (inst *Inst) SetVar(name string, value any)

type InstOption

type InstOption func(*Inst)

func WithCustomEchoPrinter

func WithCustomEchoPrinter(echoPrinter EchoPrinter) InstOption

func WithMissingBuiltinHandler

func WithMissingBuiltinHandler(handler MissingBuiltinHandler) InstOption

func WithModule

func WithModule(module Module) InstOption

func WithOut

func WithOut(out io.Writer) InstOption

type IntObject

type IntObject int

func (IntObject) String

func (i IntObject) String() string

func (IntObject) Truthy

func (i IntObject) Truthy() bool

type Invokable

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

func (Invokable) Invoke

func (i Invokable) Invoke(ctx context.Context, args ...any) (any, error)

func (Invokable) IsNil

func (i Invokable) IsNil() bool

type Iterable

type Iterable interface {
	HasNext() bool

	// Next returns the next object from the iterable if one exists, otherwise
	// returns nil, false.
	Next(ctx context.Context) (Object, error)
}

type ListObject

type ListObject []Object

func NewListObject

func NewListObject() *ListObject

func NewListObjectOfLength added in v0.1.2

func NewListObjectOfLength(l int) *ListObject

func (*ListObject) Append

func (lo *ListObject) Append(o Object)

func (*ListObject) Index

func (s *ListObject) Index(i int) Object

func (*ListObject) Insert

func (lo *ListObject) Insert(idx int, obj Object) error

func (*ListObject) Len

func (s *ListObject) Len() int

func (*ListObject) SetIndex

func (s *ListObject) SetIndex(i int, toVal Object) error

func (*ListObject) String

func (s *ListObject) String() string

func (*ListObject) Truthy

func (s *ListObject) Truthy() bool

type Listable

type Listable interface {
	Len() int
	Index(i int) Object
}

type MissingBuiltinHandler

type MissingBuiltinHandler func(ctx context.Context, name string, args CallArgs) (any, error)

type MissingModifiablePseudoVarHandler

type MissingModifiablePseudoVarHandler interface {
	MissingPseudoVarHandler
	Set(ctx context.Context, string, v any) error
}

type MissingPseudoVarHandler

type MissingPseudoVarHandler interface {
	Get(ctx context.Context, name string) (any, error)
}

type ModHashable

type ModHashable interface {
	Hashable
	SetValue(k string, val Object) error
}

type ModListable

type ModListable interface {
	Listable

	// Insert adds a new item to the list. idx can be a positive
	// number from 0 to len(), in which case the object will be inserted
	// at that position, shifting all other elements to the right.
	// If idx is negative, then the item will be inserted
	// at that position from the right.
	Insert(idx int, obj Object) error

	// SetIndex replaces the item at index position idx with obj.
	SetIndex(idx int, obj Object) error
}

type ModifiablePseudoVarHandler

type ModifiablePseudoVarHandler interface {
	PseudoVarHandler
	Set(ctx context.Context, v any) error
}

type Module

type Module struct {
	Name     string
	Builtins map[string]BuiltinHandler
}

type Object

type Object interface {
	String() string
	Truthy() bool
}

type OpaqueObject

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

func Opaque

func Opaque(v any) OpaqueObject

func (OpaqueObject) String

func (p OpaqueObject) String() string

func (OpaqueObject) Truthy

func (p OpaqueObject) Truthy() bool

type PseudoVarHandler

type PseudoVarHandler interface {
	Get(ctx context.Context) (any, error)
}

type StringListObject

type StringListObject []string

func (StringListObject) Index

func (ss StringListObject) Index(i int) Object

func (StringListObject) Len

func (ss StringListObject) Len() int

func (StringListObject) String

func (ss StringListObject) String() string

func (StringListObject) Truthy

func (ss StringListObject) Truthy() bool

type StringObject

type StringObject string

func (StringObject) String

func (s StringObject) String() string

func (StringObject) Truthy

func (s StringObject) Truthy() bool

type TimeObject

type TimeObject time.Time

func (TimeObject) String

func (t TimeObject) String() string

func (TimeObject) Truthy

func (t TimeObject) Truthy() bool

Source Files

  • ast.go
  • builtins.go
  • env.go
  • errors.go
  • eval.go
  • inst.go
  • io.go
  • objs.go
  • userbuiltin.go

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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