Documentation ¶
Overview ¶
Package interpreter provides functions for an interactive interpreter.
Index ¶
- type Interpreter
- func (i *Interpreter) AddPostProcessor(postProcessor func(store factstore.FactStore) error)
- func (i *Interpreter) Define(clauseText string) error
- func (i *Interpreter) Load(pathset string) error
- func (i *Interpreter) Loop() error
- func (i *Interpreter) ParseQuery(query string) (ast.Atom, error)
- func (i *Interpreter) Pop()
- func (i *Interpreter) Preload(units []parse.SourceUnit, store factstore.FactStore, ...) error
- func (i *Interpreter) Query(query ast.Atom) ([]ast.Atom, error)
- func (i *Interpreter) QueryInteractive(queryString string) error
- func (i *Interpreter) Show(arg string) error
- func (i *Interpreter) ShowHelp()
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) 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.