Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( ErrBytecodeNil = errors.New("risor bytecode is nil") ErrContentNil = errors.New("risor content is nil") ErrExecCreationFailed = errors.New("unable to create risor executable") ErrNoInstructions = errors.New("risor bytecode has zero instructions") ErrValidationFailed = errors.New("risor 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 Risor-specific Compiler instance with the provided options. Global variables are used for initial script parsing while building the executable bytecode.
func (*Compiler) Compile ¶
func (c *Compiler) Compile(scriptLoader io.ReadCloser) (script.ExecutableContent, error)
Compile turns the provided script content into runnable bytecode.
type FunctionalOption ¶
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 Risor scripts
func WithLogHandler ¶
func WithLogHandler(handler slog.Handler) FunctionalOption
WithLogHandler creates an option to set the log handler for Risor 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 Risor compiler. This is less flexible than WithLogHandler but allows users to customize their logging group configuration.