ngcore

package
v0.0.0-...-d472ff9 Latest Latest
Warning

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

Go to latest
Published: Mar 9, 2018 License: BSD-2-Clause Imports: 22 Imported by: 3

Documentation

Overview

Package ngcore presents a Neugram interpreter interface and the associated machinery that depends on the state of the interpreter, such as code completion.

This package is designed for embedding Neugram into a program.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Error

type Error struct {
	Phase string
	List  []error
}

func (Error) Error

func (e Error) Error() string

type History

type History struct {
	Name string // path to the shell's history file
	// contains filtered or unexported fields
}

History represents a shell (POSIX, Neugram) history.

func (*History) Run

func (h *History) Run(ctx context.Context)

type Neugram

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

func New

func New() *Neugram

func (*Neugram) Close

func (ng *Neugram) Close() error

func (*Neugram) GetOrNewSession

func (n *Neugram) GetOrNewSession(ctx context.Context, name string, env []string) *Session

func (*Neugram) GetSession

func (n *Neugram) GetSession(name string) *Session

func (*Neugram) NewSession

func (n *Neugram) NewSession(ctx context.Context, name string, env []string) (*Session, error)

type Session

type Session struct {
	Parser      *parser.Parser
	Program     *eval.Program
	ShellState  *shell.State
	ParserState parser.ParserState

	// Stdin, Stdout, and Stderr are the stdio to hook up to evaluator.
	// Nominally Stdout and Stderr are io.Writers.
	// If these interfaces have the concrete type *os.File the underlying
	// file descriptor is passed directly to shell jobs.
	Stdin  *os.File
	Stdout *os.File
	Stderr *os.File

	ExecCount int // number of statements executed

	Liner   *liner.State
	History struct {
		Ng History
		Sh History
	}
	// contains filtered or unexported fields
}

func (*Session) Close

func (s *Session) Close()

func (*Session) Completer

func (s *Session) Completer(mode, line string, pos int) (prefix string, completions []string, suffix string)

func (*Session) Display

func (s *Session) Display(w io.Writer, vals []reflect.Value)

Display displays the results of an execution to w.

func (*Session) Exec

func (s *Session) Exec(src []byte) ([]reflect.Value, error)

Exec returns the evaluation of the content of src and an error, if any. If src contains multiple statements, Exec returns the value of the last one.

func (*Session) Run

func (s *Session) Run(ctx context.Context, startInShell bool, sigint chan os.Signal) error

func (*Session) RunScript

func (s *Session) RunScript(r io.Reader) (parser.ParserState, error)

RunScript evaluates a complete Neugram script.

Jump to

Keyboard shortcuts

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