Documentation
¶
Index ¶
- func CoreConsts() *vm.Consts
- func Eval(src string) (vm.Value, error)
- func IsErrorEOF(err error) bool
- func IsTokenBoundary(r rune) bool
- func PrecompiledNSChunk(name string) *vm.CodeChunk
- func ReadAllDataString(s string) ([]vm.Value, error)
- func ReadDataString(s string) (vm.Value, error)
- func ReadString(s string) (vm.Value, error)
- func SetMatchBbConditional(v bool)
- func SetMatchCljConditional(v bool)
- type CompileError
- func (r *CompileError) Error() string
- func (r *CompileError) GetCause() error
- func (r *CompileError) InnermostMessage() string
- func (r *CompileError) InnermostSource() *vm.SourceInfo
- func (r *CompileError) Message() string
- func (r *CompileError) Source() *vm.SourceInfo
- func (r *CompileError) Wrap(err error) errors.Error
- type Context
- func (c *Context) ChildForEval() *Context
- func (c *Context) ChildForLoad(ns *vm.Namespace) *Context
- func (c *Context) Compile(s string) (chunk *vm.CodeChunk, err error)
- func (c *Context) CompileMultiple(reader io.Reader) (compiled *vm.CodeChunk, result vm.Value, err error)
- func (c *Context) CompileMultipleForEntryFrame(reader io.Reader, namespace, name string) (compiled *vm.CodeChunk, result vm.Value, err error)
- func (c *Context) Consts() *vm.Consts
- func (c *Context) CurrentNS() *vm.Namespace
- func (c *Context) EvaluationExecContext() *vm.ExecContext
- func (c *Context) SetCurrentNS(ns *vm.Namespace)
- func (c *Context) SetSource(source string) *Context
- func (c *Context) SetTaggedReaders(registry *TaggedReaderRegistry) *Context
- type LispReader
- func NewLispDataReader(r io.Reader, inputName string) *LispReader
- func NewLispReader(r io.Reader, inputName string) *LispReader
- func NewLispReaderTokenizing(r io.Reader, inputName string) *LispReader
- func NewLispReaderWithTaggedReaders(r io.Reader, inputName string, registry *TaggedReaderRegistry) *LispReader
- type ReaderError
- type TaggedDataReader
- type TaggedReaderRegistry
- type Token
- type TokenKind
- type TopLevelForm
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CoreConsts ¶ added in v1.3.0
CoreConsts returns the global const pool populated during core boot. Used as parent for layered child pools during user code compilation.
func IsErrorEOF ¶ added in v1.9.0
IsErrorEOF reports whether err represents end-of-input: a plain or standard-wrapped io.EOF, or a compiler error whose nested cause is io.EOF. Use this instead of errors.Is(err, io.EOF) for reader output — ReaderError keeps its cause in GetCause rather than implementing Unwrap.
func IsTokenBoundary ¶ added in v1.13.0
IsTokenBoundary reports whether r ends a symbol token the way the reader's tokenizer does everywhere it scans one (readSymbol, readString escapes, readRegex, etc.): whitespace (isWhitespace treats ',' as whitespace too) or a terminating macro character. Exported so pkg/complete's REPL completer can backscan a line for a completion prefix using the exact same boundary rule as the reader, instead of a hand-rolled approximation that can drift from it.
func PrecompiledNSChunk ¶ added in v1.3.0
PrecompiledNSChunk returns the precompiled main chunk for a namespace, or nil.
func ReadDataString ¶ added in v1.13.0
ReadDataString reads the first form of s with data semantics (see NewLispDataReader). ReadAllDataString reads every top-level form the same way; EOF at a form boundary stops cleanly, EOF mid-form is an error.
func ReadString ¶
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) Message ¶ added in v1.12.0
func (r *CompileError) Message() string
func (*CompileError) Source ¶
func (r *CompileError) Source() *vm.SourceInfo
type Context ¶
type Context struct {
// contains filtered or unexported fields
}
func NewTransientCompiler ¶ added in v1.12.0
NewTransientCompiler returns a compiler for ONE transient evaluation (a REPL/nREPL input, load-string, eval, a pod or host request): constants the evaluation introduces intern into a CHILD pool layered on parent, so they stay reachable only through the chunks and functions that use them and are collected with them — instead of rooting the parent pool forever, one entry per eval, unbounded in a long-lived session.
Every transient-eval site must build its compiler here; a bare NewCompiler call is reserved for pools that SHOULD live as long as the process (boot, require/ns loading, build tools). Grep for NewCompiler( to audit.
func (*Context) ChildForEval ¶ added in v1.12.0
ChildForEval returns a fresh compilation context for one transient top-level evaluation layered on this context's pool: same namespace and debug mode, child constant pool (see NewTransientCompiler).
Field semantics: debug and source are COPIED (user setting + error-report label); the namespace is inherited through the process-global CurrentNS (continuity across evals); everything else (chunk, locals, stack state) is freshly initialized — each eval is independent. Repeated calls produce SIBLING children of this context's pool, not a nested chain: each transient eval's constants live exactly as long as its own chunks, and siblings cannot alias each other's index space (Intern only reuses parent indices below the child's base).
func (*Context) ChildForLoad ¶ added in v1.13.0
ChildForLoad returns a fresh top-level context for compiling a required namespace. Required namespaces share the parent's long-lived constant pool and reader/execution configuration, but start with independent compiler state and the supplied scratch namespace.
func (*Context) CompileMultiple ¶
func (*Context) CompileMultipleForEntryFrame ¶ added in v1.13.0
func (c *Context) CompileMultipleForEntryFrame(reader io.Reader, namespace, name string) (compiled *vm.CodeChunk, result vm.Value, err error)
CompileMultipleForEntryFrame compiles a program bundle whose native entry frame will invoke namespace/name after replay. Only top-level calls to that selected entry are omitted from the emitted chunk; every other top-level form, including runtime initialization in required namespaces, remains. Ordinary CompileMultiple and its bytecode bundles retain their usual entry invocation semantics.
func (*Context) EvaluationExecContext ¶ added in v1.13.0
func (c *Context) EvaluationExecContext() *vm.ExecContext
EvaluationExecContext returns the execution context configured for compiled code, including the context-local tagged-reader registry binding.
func (*Context) SetCurrentNS ¶
func (*Context) SetTaggedReaders ¶ added in v1.13.0
func (c *Context) SetTaggedReaders(registry *TaggedReaderRegistry) *Context
SetTaggedReaders installs explicit Go tagged readers for subsequent Compile and CompileMultiple calls. The registry is shared with child eval contexts.
type LispReader ¶
type LispReader struct {
Tokens []Token
// contains filtered or unexported fields
}
func NewLispDataReader ¶ added in v1.13.0
func NewLispDataReader(r io.Reader, inputName string) *LispReader
NewLispDataReader reads data with Clojure reader semantics; see the data field. Nothing read this way is evaluated.
func NewLispReader ¶
func NewLispReader(r io.Reader, inputName string) *LispReader
func NewLispReaderTokenizing ¶
func NewLispReaderTokenizing(r io.Reader, inputName string) *LispReader
func NewLispReaderWithTaggedReaders ¶ added in v1.13.0
func NewLispReaderWithTaggedReaders(r io.Reader, inputName string, registry *TaggedReaderRegistry) *LispReader
NewLispReaderWithTaggedReaders returns a reader that dispatches custom tagged literals through registry. Built-in #uuid and #inst literals remain available when they are not overridden.
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
type TaggedDataReader ¶ added in v1.13.0
TaggedDataReader transforms the next ordinary Lisp form after a registered tag, such as #probe [1 2].
type TaggedReaderRegistry ¶ added in v1.13.0
type TaggedReaderRegistry struct {
// contains filtered or unexported fields
}
TaggedReaderRegistry is a concurrency-safe, per-reader registry of custom tagged literal handlers. The zero value is ready to use.
func NewTaggedReaderRegistry ¶ added in v1.13.0
func NewTaggedReaderRegistry() *TaggedReaderRegistry
NewTaggedReaderRegistry returns an empty tagged-reader registry.
func (*TaggedReaderRegistry) RegisterData ¶ added in v1.13.0
func (r *TaggedReaderRegistry) RegisterData(tag string, reader TaggedDataReader) error
RegisterData registers a handler that receives the next normally-read Lisp form. Registering the same tag more than once is an error.
type TopLevelForm ¶ added in v1.12.0
type TopLevelForm struct {
Form vm.Value
Source string
Start int
End int
Line int
Column int
EndLine int
EndColumn int
}
TopLevelForm holds one top-level form plus the exact source slice that produced it.
func SplitTopLevelForms ¶ added in v1.12.0
func SplitTopLevelForms(src, inputName string) ([]TopLevelForm, error)
SplitTopLevelForms reads src as a sequence of top-level forms and returns their exact source slices in order. Leading whitespace and no-value reader forms are skipped; each returned Source starts at the first byte of the corresponding real form.