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 ¶
- func MakeLoad() func(thread *starlark.Thread, module string) (starlark.StringDict, error)deprecated
- func MakeLoadOptions(opts *syntax.FileOptions) func(thread *starlark.Thread, module string) (starlark.StringDict, error)
- func PrintError(err error)
- func REPL(thread *starlark.Thread, globals starlark.StringDict)deprecated
- func REPLOptions(opts *syntax.FileOptions, thread *starlark.Thread, globals starlark.StringDict)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func MakeLoad
deprecated
MakeLoad calls MakeLoadOptions using syntax.LegacyFileOptions.
Deprecated: use MakeLoadOptions with syntax.FileOptions instead, because this function relies on legacy global variables.
func MakeLoadOptions ¶
func MakeLoadOptions(opts *syntax.FileOptions) func(thread *starlark.Thread, module string) (starlark.StringDict, error)
MakeLoadOptions returns a simple sequential implementation of module loading suitable for use in the REPL. Each function returned by MakeLoadOptions accesses a distinct private cache.
func PrintError ¶
func PrintError(err error)
PrintError prints the error to stderr, or its backtrace if it is a Starlark evaluation error.
func REPL
deprecated
func REPL(thread *starlark.Thread, globals starlark.StringDict)
REPL calls REPLOptions using syntax.LegacyFileOptions.
Deprecated: use REPLOptions with syntax.FileOptions instead, because this function relies on legacy global variables.
func REPLOptions ¶
func REPLOptions(opts *syntax.FileOptions, thread *starlark.Thread, globals starlark.StringDict)
REPLOptions 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 ¶
This section is empty.