compiler

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Sep 19, 2025 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrBytecodeNil        = errors.New("starlark bytecode is nil")
	ErrContentNil         = errors.New("starlark content is nil")
	ErrExecCreationFailed = errors.New("unable to create starlark executable")
	ErrValidationFailed   = errors.New("starlark script validation error")
)

Functions

This section is empty.

Types

type Compiler

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

func New

func New(opts ...FunctionalOption) (*Compiler, error)

New creates a new Starlark-specific Compiler instance with the provided options. Global variables are used during script parsing to validate global name usage.

func (*Compiler) Compile

func (c *Compiler) Compile(scriptReader io.ReadCloser) (script.ExecutableContent, error)

Compile turns the provided script content into runnable bytecode.

func (*Compiler) String

func (c *Compiler) String() string

type FunctionalOption

type FunctionalOption func(*Compiler) error

FunctionalOption is a function that configures a Compiler instance

func WithCtxGlobal

func WithCtxGlobal() FunctionalOption

WithCtxGlobal is a convenience option to set the user-specified global to 'ctx'

func WithGlobals

func WithGlobals(globals []string) FunctionalOption

WithGlobals creates an option to set the globals for Starlark scripts

func WithLogHandler

func WithLogHandler(handler slog.Handler) FunctionalOption

WithLogHandler creates an option to set the log handler for Starlark compiler. This is the preferred option for logging configuration as it provides more flexibility through the slog.Handler interface.

func WithLogger

func WithLogger(logger *slog.Logger) FunctionalOption

WithLogger creates an option to set a specific logger for Starlark compiler. This is less flexible than WithLogHandler but allows users to customize their logging group configuration.

Directories

Path Synopsis
internal

Jump to

Keyboard shortcuts

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