Back to godoc.org
github.com/google/skylark / repl

package repl

v0.0.0 (a5f7082)
Latest Go to latest
Published: Nov 1, 2018 | License: BSD-3-Clause | Module: github.com/google/skylark

Overview

The repl package provides a read/eval/print loop for Skylark.

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 MakeLoad() func(thread *skylark.Thread, module string) (skylark.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 PrintError

func PrintError(err error)

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

func REPL

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

REPL executes a read, eval, print loop.

Before evaluating each expression, it sets the Skylark 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.

Documentation was rendered with GOOS=linux and GOARCH=amd64.

Jump to identifier

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to identifier