repl

package
v1.4.0 Latest Latest
Warning

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

Go to latest
Published: Feb 21, 2026 License: Apache-2.0 Imports: 14 Imported by: 0

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

Standalone Functions

Compile and Run are exported for use outside the REPL loop, providing the canonical compilation pipeline entry points.

Package repl provides an interactive Read-Eval-Print Loop for Scheme.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Compile deprecated

Compile expands and compiles a syntax expression into a native template.

Deprecated: Use github.com/aalpar/wile/runtime.Compile instead. This function delegates to the runtime package.

func Load deprecated

func Load(ctx context.Context, env *environment.EnvironmentFrame, r io.Reader, filename string) error

Load reads and evaluates Scheme expressions from a reader into the environment.

Deprecated: Use github.com/aalpar/wile/runtime.Load instead. This function delegates to the runtime package.

func Run deprecated

Run executes a compiled template and returns the result values.

Deprecated: Use github.com/aalpar/wile/runtime.Run instead. This function delegates to the runtime package.

Types

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) 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 Option

type Option func(*REPL)

Option configures a REPL.

func WithContinuationPrompt

func WithContinuationPrompt(prompt string) Option

WithContinuationPrompt sets the continuation prompt for multi-line input.

func WithErrorOutput

func WithErrorOutput(w io.Writer) Option

WithErrorOutput sets the error output writer.

func WithHistoryFile

func WithHistoryFile(path string) Option

WithHistoryFile sets the history file path.

func WithOutput

func WithOutput(w io.Writer) Option

WithOutput sets the output writer.

func WithPrompt

func WithPrompt(prompt string) Option

WithPrompt sets the primary prompt.

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.

func (*REPL) Debugger

func (p *REPL) Debugger() *machine.Debugger

Debugger returns the REPL's debugger for external configuration.

func (*REPL) Run

func (p *REPL) Run(ctx context.Context) error

Run starts the REPL with readline support, falling back to simple mode if needed.

func (*REPL) RunSimple

func (p *REPL) RunSimple(ctx context.Context) error

RunSimple runs a basic REPL without readline support.

Jump to

Keyboard shortcuts

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