repl

package
v0.9.0 Latest Latest
Warning

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

Go to latest
Published: Sep 17, 2025 License: MIT Imports: 12 Imported by: 0

Documentation

Overview

Package repl implements the Read-Eval-Print Loop for the Monke programming language.

The REPL provides an interactive interface for users to enter Monke code, have it evaluated, and see the results immediately. It uses the Charm libraries (Bubbletea, Bubbles, and Lipgloss) to create a modern, user-friendly terminal interface with features like syntax highlighting and command history.

Key features:

  • Interactive command input and execution
  • Command history tracking
  • Styled output with different colors for results and errors
  • Persistent environment across commands

The main entry point is the Start function, which initializes and runs the REPL with the given username.

Index

Constants

View Source
const (
	// Prompt is the default prompt for the REPL
	Prompt = ">> "

	// ContPrompt is the continuation prompt used in multiline input mode within the REPL.
	ContPrompt = ".. "
)

Variables

This section is empty.

Functions

func Start

func Start(username string, options Options)

Start initializes and runs the REPL with the given username and options. It creates a new bubbletea program with an initial model and runs it. The username is displayed in the welcome message of the REPL. If an error occurs while running the program, it is printed to the console.

Types

type ErrorType

type ErrorType int

ErrorType represents the type of error that occurred

const (

	// NoError indicates that no error occurred, typically used as a default or initial value for error handling.
	NoError ErrorType = iota

	// ParseError indicates an error that occurred during the parsing phase of code evaluation or execution.
	ParseError

	// RuntimeError signifies an error that occurs during the execution of a program, typically at runtime.
	RuntimeError
)

type Options

type Options struct {
	NoColor bool // Disable syntax highlighting and colored output
	Debug   bool // Enable debug mode with more verbose output
}

Options contains configuration options for the REPL

Jump to

Keyboard shortcuts

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