compiler

package
v1.11.1 Latest Latest
Warning

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

Go to latest
Published: Jun 29, 2026 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CoreConsts added in v1.3.0

func CoreConsts() *vm.Consts

CoreConsts returns the global const pool populated during core boot. Used as parent for layered child pools during user code compilation.

func Eval

func Eval(src string) (vm.Value, error)

func IsErrorEOF added in v1.9.0

func IsErrorEOF(err error) bool

IsErrorEOF reports whether err represents end-of-input: a plain io.EOF, or a ReaderError whose (possibly nested) cause is io.EOF. Use this instead of errors.Is(err, io.EOF) for reader output — ReaderError wraps io.EOF in a `cause` field and does not implement Unwrap, so errors.Is never matches it.

func PrecompiledNSChunk added in v1.3.0

func PrecompiledNSChunk(name string) *vm.CodeChunk

PrecompiledNSChunk returns the precompiled main chunk for a namespace, or nil.

func ReadString

func ReadString(s string) (vm.Value, error)

ReadString parses a string into a let-go Value. As a single-form entry point it skips leading no-value forms (comments, #_ discard) so a string that opens with a ';;' comment yields the following form rather than the VOID sentinel.

func SetMatchBbConditional added in v1.10.0

func SetMatchBbConditional(v bool)

SetMatchBbConditional toggles whether reader conditionals match :bb.

func SetMatchCljConditional added in v1.7.3

func SetMatchCljConditional(v bool)

SetMatchCljConditional toggles whether reader conditionals match :clj.

Types

type CompileError

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

func NewCompileError

func NewCompileError(message string) *CompileError

func NewCompileErrorWithSource

func NewCompileErrorWithSource(message string, info *vm.SourceInfo) *CompileError

func (*CompileError) Error

func (r *CompileError) Error() string

func (*CompileError) GetCause

func (r *CompileError) GetCause() error

func (*CompileError) InnermostMessage

func (r *CompileError) InnermostMessage() string

InnermostMessage walks the error chain and returns the deepest error message.

func (*CompileError) InnermostSource

func (r *CompileError) InnermostSource() *vm.SourceInfo

InnermostSource walks the error chain and returns the deepest source info found.

func (*CompileError) Source

func (r *CompileError) Source() *vm.SourceInfo

func (*CompileError) Wrap

func (r *CompileError) Wrap(err error) errors.Error

type Context

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

func NewCompiler

func NewCompiler(consts *vm.Consts, ns *vm.Namespace) *Context

func NewDebugCompiler

func NewDebugCompiler(consts *vm.Consts, ns *vm.Namespace) *Context

func (*Context) Compile

func (c *Context) Compile(s string) (*vm.CodeChunk, error)

func (*Context) CompileMultiple

func (c *Context) CompileMultiple(reader io.Reader) (*vm.CodeChunk, vm.Value, error)

func (*Context) Consts

func (c *Context) Consts() *vm.Consts

func (*Context) CurrentNS

func (c *Context) CurrentNS() *vm.Namespace

func (*Context) SetCurrentNS

func (c *Context) SetCurrentNS(ns *vm.Namespace)

func (*Context) SetSource

func (c *Context) SetSource(source string) *Context

type LispReader

type LispReader struct {
	Tokens []Token
	// contains filtered or unexported fields
}

func NewLispReader

func NewLispReader(r io.Reader, inputName string) *LispReader

func NewLispReaderTokenizing

func NewLispReaderTokenizing(r io.Reader, inputName string) *LispReader

func (*LispReader) Read

func (r *LispReader) Read() (vm.Value, error)

Read reads a single form. No-value reader macros (line comments, #_ discard, reader conditionals with no matching branch) return the VOID sentinel — this is load-bearing: collection readers (readList/readVector/readMap/readSet) call Read in element/value position and rely on seeing VOID to drop an orphaned map key or splice nothing (e.g. {:a #_ 1 :b 2} => {:b 2}). Callers that want a real form with leading no-value forms skipped use ReadSkipNoValue.

func (*LispReader) ReadSkipNoValue added in v1.11.0

func (r *LispReader) ReadSkipNoValue() (vm.Value, error)

ReadSkipNoValue reads a single form, skipping leading no-value forms (line comments, #_ discard, non-matching reader conditionals) so the result is a real form. It surfaces EOF when the input holds no form at all. This is the single-form entry point used by read-string; unlike Read it never returns VOID. Each no-value macro consumes input, so the loop always makes progress.

type ReaderError

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

func NewReaderError

func NewReaderError(r *LispReader, message string) *ReaderError

func (*ReaderError) Error

func (r *ReaderError) Error() string

func (*ReaderError) GetCause

func (r *ReaderError) GetCause() error

func (*ReaderError) IsEOF

func (r *ReaderError) IsEOF() bool

func (*ReaderError) Wrap

func (r *ReaderError) Wrap(err error) errors.Error

type Token

type Token struct {
	Start int
	End   int
	Kind  TokenKind
}

type TokenKind

type TokenKind int
const (
	TokenString TokenKind = iota
	TokenNumber
	TokenKeyword
	TokenSymbol
	TokenChar
	TokenSpecial
	TokenComment
	TokenPunctuation
)

Jump to

Keyboard shortcuts

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