Documentation ¶
Index ¶
- Variables
- func Register(name string, library func(*Interpreter) error)
- type Interpreter
- func (i *Interpreter) Exec(query string, args ...interface{}) error
- func (i *Interpreter) ExecContext(ctx context.Context, query string, args ...interface{}) error
- func (i *Interpreter) Query(query string, args ...interface{}) (*Solutions, error)
- func (i *Interpreter) QueryContext(ctx context.Context, query string, args ...interface{}) (*Solutions, error)
- type Solutions
Constants ¶
This section is empty.
Variables ¶
var ErrClosed = errors.New("closed")
ErrClosed indicates the Solutions are already closed and unable to perform the operation.
Functions ¶
func Register ¶ added in v0.5.0
func Register(name string, library func(*Interpreter) error)
Register registers a library. if there's a library with the same name registered, it panics.
Types ¶
type Interpreter ¶ added in v0.2.0
Interpreter is a Prolog interpreter. The zero value is a valid interpreter without any predicates/operators defined.
func New ¶ added in v0.2.0
func New(in io.Reader, out io.Writer) *Interpreter
New creates a new Prolog interpreter with predefined predicates/operators.
func (*Interpreter) Exec ¶ added in v0.2.0
func (i *Interpreter) Exec(query string, args ...interface{}) error
Exec executes a prolog program.
func (*Interpreter) ExecContext ¶ added in v0.3.0
func (i *Interpreter) ExecContext(ctx context.Context, query string, args ...interface{}) error
ExecContext executes a prolog program with context.
func (*Interpreter) Query ¶ added in v0.2.0
func (i *Interpreter) Query(query string, args ...interface{}) (*Solutions, error)
Query executes a prolog query and returns *Solutions.
func (*Interpreter) QueryContext ¶ added in v0.3.0
func (i *Interpreter) QueryContext(ctx context.Context, query string, args ...interface{}) (*Solutions, error)
QueryContext executes a prolog query and returns *Solutions with context.
type Solutions ¶ added in v0.2.0
type Solutions struct {
// contains filtered or unexported fields
}
Solutions is the result of a query. Everytime the Next method is called, it searches for the next solution. By calling the Scan method, you can retrieve the content of the solution.
func (*Solutions) Close ¶ added in v0.2.0
Close closes the Solutions and terminates the search for other solutions.
func (*Solutions) Next ¶ added in v0.2.0
Next prepares the next solution for reading with the Scan method. It returns true if it finds another solution, or false if there's no further solutions or if there's an error.