tlvm

package module
v0.0.0-...-b31852d Latest Latest
Warning

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

Go to latest
Published: May 26, 2026 License: MIT Imports: 18 Imported by: 0

README

tlvm

Tiny stack based VM and lisp like language compiler for it.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FormatErrorWithTextPosition

func FormatErrorWithTextPosition(err error, rawText string) string

func ShowErrorLine

func ShowErrorLine(rawText string, posInt int) string

Types

type CompileOption

type CompileOption func(bt *VMByteCode)

func EnableDebugSymbols

func EnableDebugSymbols() CompileOption

func EnvVariables

func EnvVariables(env ...Label) CompileOption

func ExtFunctions

func ExtFunctions(funcs map[string]any) (CompileOption, error)

func ExtFunctionsOrPanic

func ExtFunctionsOrPanic(funcs map[string]any) CompileOption

type Label

type Label string

func (Label) String

func (l Label) String() string

type LazyString

type LazyString func() string

func (LazyString) String

func (ls LazyString) String() string

type SExpressions

type SExpressions []any

func Read

func Read(sourceCode string) (SExpressions, error)

type StructLabel

type StructLabel string

func (StructLabel) String

func (l StructLabel) String() string

type VM

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

func Build

func Build(ctx context.Context, text string, options ...CompileOption) (*VM, error)

func NewVM

func NewVM(output *VMByteCode) *VM

func (*VM) CodeString

func (v *VM) CodeString() string

func (*VM) Copy

func (v *VM) Copy() VM

func (*VM) Env

func (vm *VM) Env(k Label, v any)

func (*VM) EnvFloat32

func (vm *VM) EnvFloat32(k string, v float32)

func (*VM) EnvFloat64

func (vm *VM) EnvFloat64(k string, v float64)

func (*VM) EnvInt

func (vm *VM) EnvInt(k string, v int)

func (*VM) EnvInt64

func (vm *VM) EnvInt64(k string, v int64)

func (*VM) EnvString

func (vm *VM) EnvString(k string, v string)

func (*VM) Execute

func (v *VM) Execute(ctx context.Context) (errRes error)

func (*VM) Reset

func (v *VM) Reset()

func (*VM) Result

func (v *VM) Result() any

func (*VM) Stop

func (v *VM) Stop()

func (*VM) WithMaxStackSize

func (vm *VM) WithMaxStackSize(sizeInBytes uint64) *VM

func (*VM) WithTimeout

func (vm *VM) WithTimeout(timeout time.Duration) *VM

type VMByteCode

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

func Compile

func Compile(ctx context.Context, text string, options ...CompileOption) (_ *VMByteCode, err error)

func (*VMByteCode) ImportedEnvVariables

func (v *VMByteCode) ImportedEnvVariables() []string

func (*VMByteCode) ImportedExternalFunctions

func (v *VMByteCode) ImportedExternalFunctions() []string

type ValuePath

type ValuePath []Label

func (ValuePath) VariableName

func (v ValuePath) VariableName() Label

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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