repl

package
v0.0.0-...-59d3038 Latest Latest
Warning

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

Go to latest
Published: Dec 31, 2018 License: BSD-3-Clause Imports: 60 Imported by: 0

Documentation

Overview

Package repl provides a read/eval/print loop for Starlark.

It supports readline-style command editing, and interrupts through Control-C.

If an input line can be parsed as an expression, the REPL parses and evaluates it and prints its result. Otherwise the REPL reads lines until a blank line, then tries again to parse the multi-line input as an expression. If the input still cannot be parsed as an expression, the REPL parses and executes it as a file (a list of statements), for side effects.

Index

Constants

This section is empty.

Variables

View Source
var Natives = make(map[string]func() interface{})

Functions

func AsTm

func AsTm(tms string) time.Time

string -> time.Time

func ExecFileNoFreeze

func ExecFileNoFreeze(thread *starlark.Thread, src interface{}, globals *starlark.StringDict) error

ExecFileNoFreeze is starlark.ExecFile without globals.Freeze().

func MakeLoad

func MakeLoad() func(thread *starlark.Thread, module string) (*starlark.StringDict, error)

MakeLoad returns a simple sequential implementation of module loading suitable for use in the REPL. Each function returned by MakeLoad accesses a distinct private cache.

func PackageMaker

func PackageMaker(_ *starlark.Thread, _ *starlark.Builtin, args starlark.Tuple, kwargs []starlark.Tuple) (starlark.Value, error)

func PrintError

func PrintError(err error)

PrintError prints the error to stderr, or its backtrace if it is a Starlark evaluation error.

func REPL

func REPL(thread *starlark.Thread, globals *starlark.StringDict)

REPL executes a read, eval, print loop.

Before evaluating each expression, it sets the Starlark thread local variable named "context" to a context.Context that is cancelled by a SIGINT (Control-C). Client-supplied global functions may use this context to make long-running operations interruptable.

Types

type MontyEnv

type MontyEnv struct {
	InitDone bool

	// GoGlobal -> translated into GlobalDict
	GoGlobal   map[string]interface{}
	GlobalDict *starlark.StringDict

	ScriptCache *starlight.Cache
	Thread      *starlark.Thread

	Stdlib map[string]bool
}

func NewMontyEnv

func NewMontyEnv() *MontyEnv

func (*MontyEnv) Eval

func (env *MontyEnv) Eval(code string) error

func (*MontyEnv) Init

func (env *MontyEnv) Init()

type TestBar

type TestBar struct {
	Height int
	Width  int
}

func MakeTestBar

func MakeTestBar() *TestBar

Jump to

Keyboard shortcuts

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