interpreter

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Dec 15, 2023 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Overview

Package interpreter provides functions for an interactive interpreter.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Interpreter

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

Interpreter is an interactive interpreter.

func New

func New(out io.Writer, root string, stats []string) *Interpreter

New returns a new interpreter.

func (*Interpreter) AddPostProcessor

func (i *Interpreter) AddPostProcessor(postProcessor func(store factstore.FactStore) error)

AddPostProcessor adds a post processing function that is called after evaluation.

func (*Interpreter) Define

func (i *Interpreter) Define(clauseText string) error

Define adds rule definitions the interpreter's state.

func (*Interpreter) Load

func (i *Interpreter) Load(pathset string) error

Load loads source files in a pathset and analyzes them together.

func (*Interpreter) Loop

func (i *Interpreter) Loop() error

Loop reads lines from stdin and performs the commands.

func (*Interpreter) ParseQuery

func (i *Interpreter) ParseQuery(query string) (ast.Atom, error)

ParseQuery parses a query string. It can either be a predicate name, or an actual atom with constants, variables and wildcards.

func (*Interpreter) Pop

func (i *Interpreter) Pop()

Pop resets the interpreter's state to what it was before the last change. Definitions entered interactively are always considered the last change.

func (*Interpreter) Preload

func (i *Interpreter) Preload(units []parse.SourceUnit, store factstore.FactStore, knownPredicates map[ast.PredicateSym]ast.Decl) error

Preload evaluates decls and clauses before any interactive evaluation takes place. This is used for customizing the interpreter. TODO: Add optional path parameter so the user can ::pop individual preloaded sources.

func (*Interpreter) Query

func (i *Interpreter) Query(query ast.Atom) ([]ast.Atom, error)

Query queries the interpreter's state.

func (*Interpreter) QueryInteractive

func (i *Interpreter) QueryInteractive(queryString string) error

QueryInteractive parses query string, queries the interpreter's state, returns results formatted as strings.

func (*Interpreter) Show

func (i *Interpreter) Show(arg string) error

Show shows information about predicates. If arg = "all", it lists all predicate. Otherwise, it shows information about the predicate named arg.

func (*Interpreter) ShowHelp

func (i *Interpreter) ShowHelp()

ShowHelp displays help text.

Directories

Path Synopsis
Binary shell is a shell for interactive interpreter.
Binary shell is a shell for interactive interpreter.

Jump to

Keyboard shortcuts

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