interp

package
v1.0.4 Latest Latest
Warning

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

Go to latest
Published: Jul 17, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package interp implements the bc interpreter / evaluator.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RegisterMathLib

func RegisterMathLib(ip *Interp)

RegisterMathLib installs the -l math functions and sets scale=20.

Types

type Interp

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

Interp is the bc interpreter.

func New

func New(stdin io.Reader, stdout, stderr io.Writer) *Interp

New creates an Interp.

func (*Interp) ExecStmts

func (ip *Interp) ExecStmts(stmts []parser.Stmt) (quit bool)

ExecStmts executes a list of statements and returns whether `quit` was signalled.

func (*Interp) RegisterFunc

func (ip *Interp) RegisterFunc(fd *parser.FuncDef)

RegisterFunc registers a function definition.

func (*Interp) Scale

func (ip *Interp) Scale() int

Expose scale for math library.

func (*Interp) SetLineLen added in v1.0.1

func (ip *Interp) SetLineLen(n int)

func (*Interp) SetScale

func (ip *Interp) SetScale(s int)

type RuntimeError

type RuntimeError struct{ Msg string }

RuntimeError is a non-fatal error (prints message, continues REPL).

func (*RuntimeError) Error

func (e *RuntimeError) Error() string

Jump to

Keyboard shortcuts

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