Documentation
¶
Overview ¶
Package repl provides an interactive Read-Eval-Print Loop for Wile Scheme.
The package offers both a full-featured REPL with readline support and a simple fallback mode:
repl := repl.New(env,
repl.WithHistoryFile("~/.wile_history"),
repl.WithPrompt("> "),
)
repl.Run(ctx)
Features ¶
- Readline with history, line editing, and continuation prompts
- Integrated source-level debugger with breakpoints and stepping
- Multi-line input accumulation for incomplete expressions
- Ctrl-C clears input, Ctrl-D exits cleanly
Debug Commands ¶
Commands start with comma (,) when the input buffer is empty:
,break FILE:LINE Set breakpoint ,step Step into next expression ,next Step over (same frame) ,continue Continue execution ,backtrace Show stack trace
Package repl provides an interactive Read-Eval-Print Loop for Scheme.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func StripExamples ¶ added in v1.10.3
StripExamples removes the Examples: section from a docstring. Returns the description portion only. If no Examples: section exists, returns the original string unchanged.
Types ¶
type DebugCommandInfo ¶ added in v1.6.0
type DebugCommandInfo struct {
Name string
Aliases []string
Summary string
Detail string
Handler func(args []string, out io.Writer)
}
DebugCommandInfo describes a single debug command: its canonical name, aliases, summary text, detail text, and handler function.
type DebugContext ¶
type DebugContext struct {
// contains filtered or unexported fields
}
DebugContext holds the state for debug commands.
func NewDebugContext ¶
func NewDebugContext() *DebugContext
NewDebugContext creates a new debug context.
func (*DebugContext) DebugCommands ¶ added in v1.6.0
func (p *DebugContext) DebugCommands() []DebugCommandInfo
DebugCommands returns the canonical list of debug commands with bound handlers.
func (*DebugContext) Debugger ¶
func (p *DebugContext) Debugger() *machine.Debugger
Debugger returns the debugger instance.
func (*DebugContext) HandleDebugCommand ¶
func (p *DebugContext) HandleDebugCommand(line string, out io.Writer) bool
HandleDebugCommand processes a debug command starting with ','. Returns true if a command was handled, false otherwise.
func (*DebugContext) SetCurrentMC ¶
func (p *DebugContext) SetCurrentMC(mc *machine.MachineContext)
SetCurrentMC sets the current machine context (for inspection commands).
type DocInfo ¶ added in v1.5.0
type DocInfo struct {
Doc string
Syntax string // e.g. "(if <test> <consequent> <alternate>)"
TypeLabel string // e.g. "special form", "syntax"
ParamNames []string
Category string
ParamCount int
IsVariadic bool
ParamTypes []values.ValueType
ReturnType values.ValueType
}
DocInfo holds documentation for a primitive binding.
type DocProvider ¶ added in v1.5.0
type DocProvider interface {
// LookupDoc returns documentation for the named primitive.
// Returns found=false if no documentation exists.
LookupDoc(name string) (info DocInfo, found bool)
}
DocProvider looks up documentation for named bindings.
type DocSearchProvider ¶ added in v1.10.3
type DocSearchProvider interface {
DocProvider
// Search returns entries whose name, doc, or category contains pattern
// (case-insensitive substring match). Results are sorted by name.
Search(pattern string) []DocSearchResult
// Categories returns sorted category names.
Categories() []string
// ByCategory returns entries in the named category, sorted by name.
ByCategory(category string) []DocSearchResult
}
DocSearchProvider extends DocProvider with search and category browsing.
type DocSearchResult ¶ added in v1.10.3
DocSearchResult holds one search hit.
type MetaCommandHandler ¶ added in v1.5.0
type MetaCommandHandler struct {
// contains filtered or unexported fields
}
MetaCommandHandler dispatches comma-prefixed meta-commands. Session commands (help, doc, edit) are handled directly; debug commands are delegated to DebugContext.
func NewMetaCommandHandler ¶ added in v1.5.0
func NewMetaCommandHandler( env *environment.EnvironmentFrame, debugCtx *DebugContext, docProv DocProvider, ) *MetaCommandHandler
NewMetaCommandHandler creates a new meta-command handler.
func (*MetaCommandHandler) Commands ¶ added in v1.5.0
func (p *MetaCommandHandler) Commands() []string
Commands returns all meta-command names and aliases (session + debug) for autocomplete.
func (*MetaCommandHandler) DisassembleBinding ¶ added in v1.10.5
func (p *MetaCommandHandler) DisassembleBinding(name string) (string, error)
DisassembleBinding looks up a named binding and returns its formatted disassembly. Returns an error if the name is unbound, nil, or not a procedure. Exported for use by the MCP handler.
func (*MetaCommandHandler) Handle ¶ added in v1.5.0
func (p *MetaCommandHandler) Handle(line string, out io.Writer) bool
Handle processes a line starting with ",". Returns true if the line was a meta-command (even if unrecognized), false if it's not a meta-command.
func (*MetaCommandHandler) SetPager ¶ added in v1.10.3
func (p *MetaCommandHandler) SetPager(pager string)
SetPager overrides the pager command used for long output. Pass "" to disable paging (e.g., for non-TTY contexts like MCP).
type Option ¶
type Option func(*REPL)
Option configures a REPL.
func WithContinuationPrompt ¶
WithContinuationPrompt sets the continuation prompt for multi-line input.
func WithDocProvider ¶ added in v1.5.0
func WithDocProvider(dp DocProvider) Option
WithDocProvider sets the documentation provider for the ,doc command.
func WithErrorOutput ¶
WithErrorOutput sets the error output writer.
func WithHistoryFile ¶
WithHistoryFile sets the history file path.
type REPL ¶
type REPL struct {
// contains filtered or unexported fields
}
REPL is an interactive Read-Eval-Print Loop.
func New ¶
func New(env *environment.EnvironmentFrame, opts ...Option) *REPL
New creates a new REPL with the given environment and options.
type RegistryDocProvider ¶ added in v1.5.0
type RegistryDocProvider struct {
// contains filtered or unexported fields
}
RegistryDocProvider adapts a registry.Registry to the DocProvider interface.
func NewRegistryDocProvider ¶ added in v1.5.0
func NewRegistryDocProvider(reg *registry.Registry) *RegistryDocProvider
NewRegistryDocProvider creates a DocProvider backed by the given registry.
func (*RegistryDocProvider) ByCategory ¶ added in v1.10.3
func (p *RegistryDocProvider) ByCategory(category string) []DocSearchResult
ByCategory returns entries in the named category, sorted by name.
func (*RegistryDocProvider) Categories ¶ added in v1.10.3
func (p *RegistryDocProvider) Categories() []string
Categories returns sorted category names, excluding the empty-string category.
func (*RegistryDocProvider) LookupDoc ¶ added in v1.5.0
func (p *RegistryDocProvider) LookupDoc(name string) (DocInfo, bool)
LookupDoc returns documentation for the named primitive from the registry.
func (*RegistryDocProvider) Search ¶ added in v1.10.3
func (p *RegistryDocProvider) Search(pattern string) []DocSearchResult
Search returns entries whose name, doc, or category contains pattern (case-insensitive substring match). Results are sorted by name.
type SchemeCompleter ¶ added in v1.5.0
type SchemeCompleter struct {
// contains filtered or unexported fields
}
SchemeCompleter implements readline.AutoCompleter for the Wile REPL.
func NewSchemeCompleter ¶ added in v1.5.0
func NewSchemeCompleter( env *environment.EnvironmentFrame, metaCommands []string, ) *SchemeCompleter
NewSchemeCompleter creates a completer that completes Scheme bindings from all phase environments and meta-command names.
func (*SchemeCompleter) BindingNames ¶ added in v1.5.0
func (p *SchemeCompleter) BindingNames() []string
BindingNames returns all binding names visible in the environment. Exposed for use by the REPL to provide hints.