Documentation
¶
Index ¶
- Variables
- func CompareAtomic[T Term](a T, t Term, cmp func(T, T) int, env *Env) int
- func CompareCompound(c Compound, t Term, env *Env) int
- func WriteCompound(w io.Writer, c Compound, opts *WriteOptions, env *Env) error
- type Atom
- type Compound
- type Cont
- type Dict
- type Env
- type Exception
- func DomainError(domain, culprit Term, env *Env) Exception
- func EvaluationError(error Term, env *Env) Exception
- func ExistenceError(objectType, culprit Term, env *Env) Exception
- func InstantiationError(env *Env) Exception
- func NewException(term Term, env *Env) Exception
- func PermissionError(operation, permissionType, culprit Term, env *Env) Exception
- func RepresentationError(limit Term, env *Env) Exception
- func ResourceError(resource Term, env *Env) Exception
- func SyntaxError(error Term, env *Env) Exception
- func TypeError(typ, culprit Term, env *Env) Exception
- type Float
- func (f Float) Compare(t Term, env *Env) int
- func (f Float) Eq(other Float) bool
- func (f Float) Gt(other Float) bool
- func (f Float) Gte(other Float) bool
- func (f Float) Lt(other Float) bool
- func (f Float) Lte(other Float) bool
- func (f Float) Negative() bool
- func (f Float) Positive() bool
- func (f Float) String() string
- func (f Float) WriteTerm(w io.Writer, opts *WriteOptions, _ *Env) error
- func (f Float) Zero() bool
- type HookFunc
- type Integer
- type Lexer
- type ListIterator
- type NextFunc
- type Number
- type Opcode
- type ParsedVariable
- type Parser
- type Predicate0
- type Predicate1
- type Predicate2
- type Predicate3
- type Predicate4
- type Predicate5
- type Predicate6
- type Predicate7
- type Predicate8
- type Promise
- func Abolish(vm *VM, pi Term, k Cont, env *Env) *Promise
- func AcyclicTerm(_ *VM, t Term, k Cont, env *Env) *Promise
- func Append(vm *VM, xs, ys, zs Term, k Cont, env *Env) *Promise
- func Arg(vm *VM, nth, t, arg Term, k Cont, env *Env) *Promise
- func Asserta(vm *VM, t Term, k Cont, env *Env) *Promise
- func Assertz(vm *VM, t Term, k Cont, env *Env) *Promise
- func AtomChars(vm *VM, atom, chars Term, k Cont, env *Env) *Promise
- func AtomCodes(vm *VM, atom, codes Term, k Cont, env *Env) *Promise
- func AtomConcat(vm *VM, atom1, atom2, atom3 Term, k Cont, env *Env) *Promise
- func AtomLength(vm *VM, atom, length Term, k Cont, env *Env) *Promise
- func BagOf(vm *VM, template, goal, instances Term, k Cont, env *Env) *Promise
- func Between(vm *VM, lower, upper, value Term, k Cont, env *Env) *Promise
- func Bool(ok bool) *Promise
- func Call(vm *VM, goal Term, k Cont, env *Env) (promise *Promise)
- func Call1(vm *VM, closure, arg1 Term, k Cont, env *Env) *Promise
- func Call2(vm *VM, closure, arg1, arg2 Term, k Cont, env *Env) *Promise
- func Call3(vm *VM, closure, arg1, arg2, arg3 Term, k Cont, env *Env) *Promise
- func Call4(vm *VM, closure, arg1, arg2, arg3, arg4 Term, k Cont, env *Env) *Promise
- func Call5(vm *VM, closure, arg1, arg2, arg3, arg4, arg5 Term, k Cont, env *Env) *Promise
- func Call6(vm *VM, closure, arg1, arg2, arg3, arg4, arg5, arg6 Term, k Cont, env *Env) *Promise
- func Call7(vm *VM, closure, arg1, arg2, arg3, arg4, arg5, arg6, arg7 Term, k Cont, ...) *Promise
- func CallNth(vm *VM, goal, nth Term, k Cont, env *Env) *Promise
- func Catch(vm *VM, goal, catcher, recover Term, k Cont, env *Env) *Promise
- func CharCode(vm *VM, char, code Term, k Cont, env *Env) *Promise
- func CharConversion(vm *VM, inChar, outChar Term, k Cont, env *Env) *Promise
- func Clause(vm *VM, head, body Term, k Cont, env *Env) *Promise
- func Close(vm *VM, streamOrAlias, options Term, k Cont, env *Env) *Promise
- func Compare(vm *VM, order, term1, term2 Term, k Cont, env *Env) *Promise
- func Consult(vm *VM, files Term, k Cont, env *Env) *Promise
- func CopyTerm(vm *VM, in, out Term, k Cont, env *Env) *Promise
- func CurrentCharConversion(vm *VM, inChar, outChar Term, k Cont, env *Env) *Promise
- func CurrentInput(vm *VM, stream Term, k Cont, env *Env) *Promise
- func CurrentOp(vm *VM, priority, specifier, op Term, k Cont, env *Env) *Promise
- func CurrentOutput(vm *VM, stream Term, k Cont, env *Env) *Promise
- func CurrentPredicate(vm *VM, pi Term, k Cont, env *Env) *Promise
- func CurrentPrologFlag(vm *VM, flag, value Term, k Cont, env *Env) *Promise
- func Delay(k ...PromiseFunc) *Promise
- func DelaySeq(next NextFunc) *Promise
- func Equal(_ *VM, e1, e2 Term, k Cont, env *Env) *Promise
- func Error(err error) *Promise
- func ExpandTerm(vm *VM, term1, term2 Term, k Cont, env *Env) *Promise
- func Failure(*Env) *Promise
- func FindAll(vm *VM, template, goal, instances Term, k Cont, env *Env) *Promise
- func FlushOutput(vm *VM, streamOrAlias Term, k Cont, env *Env) *Promise
- func Functor(vm *VM, t, name, arity Term, k Cont, env *Env) *Promise
- func GetByte(vm *VM, streamOrAlias, inByte Term, k Cont, env *Env) *Promise
- func GetChar(vm *VM, streamOrAlias, char Term, k Cont, env *Env) *Promise
- func GetDict3(vm *VM, keyPath Term, dict Term, result Term, cont Cont, env *Env) *Promise
- func GreaterThan(_ *VM, e1, e2 Term, k Cont, env *Env) *Promise
- func GreaterThanOrEqual(_ *VM, e1, e2 Term, k Cont, env *Env) *Promise
- func Halt(_ *VM, n Term, k Cont, env *Env) *Promise
- func Is(vm *VM, result, expression Term, k Cont, env *Env) *Promise
- func KeySort(vm *VM, pairs, sorted Term, k Cont, env *Env) *Promise
- func Length(vm *VM, list, length Term, k Cont, env *Env) *Promise
- func LessThan(_ *VM, e1, e2 Term, k Cont, env *Env) *Promise
- func LessThanOrEqual(_ *VM, e1, e2 Term, k Cont, env *Env) *Promise
- func Negate(vm *VM, goal Term, k Cont, env *Env) *Promise
- func NotEqual(_ *VM, e1, e2 Term, k Cont, env *Env) *Promise
- func Nth0(vm *VM, n, list, elem Term, k Cont, env *Env) *Promise
- func Nth1(vm *VM, n, list, elem Term, k Cont, env *Env) *Promise
- func NumberChars(vm *VM, num, chars Term, k Cont, env *Env) *Promise
- func NumberCodes(vm *VM, num, codes Term, k Cont, env *Env) *Promise
- func Op(vm *VM, priority, specifier, op Term, k Cont, env *Env) *Promise
- func Op3(vm *VM, dict, function, result Term, cont Cont, env *Env) *Promise
- func Open(vm *VM, sourceSink, mode, stream, options Term, k Cont, env *Env) *Promise
- func PeekByte(vm *VM, streamOrAlias, inByte Term, k Cont, env *Env) *Promise
- func PeekChar(vm *VM, streamOrAlias, char Term, k Cont, env *Env) *Promise
- func Phrase(vm *VM, grBody, s0, s Term, k Cont, env *Env) *Promise
- func PutByte(vm *VM, streamOrAlias, byt Term, k Cont, env *Env) *Promise
- func PutChar(vm *VM, streamOrAlias, char Term, k Cont, env *Env) *Promise
- func PutDict3(vm *VM, new Term, dictIn Term, dictOut Term, cont Cont, env *Env) *Promise
- func ReadTerm(vm *VM, streamOrAlias, out, options Term, k Cont, env *Env) *Promise
- func Repeat(_ *VM, k Cont, env *Env) *Promise
- func Retract(vm *VM, t Term, k Cont, env *Env) *Promise
- func SetInput(vm *VM, streamOrAlias Term, k Cont, env *Env) *Promise
- func SetOf(vm *VM, template, goal, instances Term, k Cont, env *Env) *Promise
- func SetOutput(vm *VM, streamOrAlias Term, k Cont, env *Env) *Promise
- func SetPrologFlag(vm *VM, flag, value Term, k Cont, env *Env) *Promise
- func SetStreamPosition(vm *VM, streamOrAlias, position Term, k Cont, env *Env) *Promise
- func SkipMaxList(vm *VM, skip, max, list, suffix Term, k Cont, env *Env) *Promise
- func Sort(vm *VM, list, sorted Term, k Cont, env *Env) *Promise
- func StreamProperty(vm *VM, stream, property Term, k Cont, env *Env) *Promise
- func SubAtom(vm *VM, atom, before, length, after, subAtom Term, k Cont, env *Env) *Promise
- func SubsumesTerm(_ *VM, general, specific Term, k Cont, env *Env) *Promise
- func Succ(vm *VM, x, s Term, k Cont, env *Env) *Promise
- func Success(*Env) *Promise
- func TermVariables(vm *VM, term, vars Term, k Cont, env *Env) *Promise
- func Throw(_ *VM, ball Term, _ Cont, env *Env) *Promise
- func TypeAtom(_ *VM, t Term, k Cont, env *Env) *Promise
- func TypeCompound(_ *VM, t Term, k Cont, env *Env) *Promise
- func TypeFloat(_ *VM, t Term, k Cont, env *Env) *Promise
- func TypeInteger(_ *VM, t Term, k Cont, env *Env) *Promise
- func TypeVar(_ *VM, t Term, k Cont, env *Env) *Promise
- func Unify(_ *VM, x, y Term, k Cont, env *Env) *Promise
- func UnifyWithOccursCheck(_ *VM, x, y Term, k Cont, env *Env) *Promise
- func Univ(vm *VM, t, list Term, k Cont, env *Env) *Promise
- func WriteTerm(vm *VM, streamOrAlias, t, options Term, k Cont, env *Env) *Promise
- type PromiseFunc
- type Stream
- func (s *Stream) Close() error
- func (s *Stream) Compare(t Term, env *Env) int
- func (s *Stream) Flush() error
- func (s *Stream) Name() string
- func (s *Stream) ReadByte() (byte, error)
- func (s *Stream) ReadRune() (r rune, size int, err error)
- func (s *Stream) Seek(offset int64, whence int) (int64, error)
- func (s *Stream) UnreadByte() error
- func (s *Stream) UnreadRune() error
- func (s *Stream) WriteByte(c byte) error
- func (s *Stream) WriteRune(r rune) (size int, err error)
- func (s *Stream) WriteTerm(w io.Writer, _ *WriteOptions, _ *Env) error
- type Term
- type Token
- type VM
- func (vm *VM) Arrive(name Atom, args []Term, k Cont, env *Env) (promise *Promise)
- func (vm *VM) ClearHook()
- func (vm *VM) Compile(ctx context.Context, s string, args ...interface{}) error
- func (vm *VM) InstallHook(f HookFunc)
- func (vm *VM) Register0(name Atom, p Predicate0)
- func (vm *VM) Register1(name Atom, p Predicate1)
- func (vm *VM) Register2(name Atom, p Predicate2)
- func (vm *VM) Register3(name Atom, p Predicate3)
- func (vm *VM) Register4(name Atom, p Predicate4)
- func (vm *VM) Register5(name Atom, p Predicate5)
- func (vm *VM) Register6(name Atom, p Predicate6)
- func (vm *VM) Register7(name Atom, p Predicate7)
- func (vm *VM) Register8(name Atom, p Predicate8)
- func (vm *VM) ResetEnv()
- func (vm *VM) SetMaxVariables(n uint64)
- func (vm *VM) SetUserInput(s *Stream)
- func (vm *VM) SetUserOutput(s *Stream)
- type Variable
- type WriteOptions
Constants ¶
This section is empty.
Variables ¶
var (
AtomPanicError = NewAtom("panic_error")
)
var ErrMaxVariables = errors.New("maximum number of variables reached")
Functions ¶
func CompareAtomic ¶
CompareAtomic compares a custom atomic term of type T with a Term and returns -1, 0, or 1. The order is Variable < Float < Integer < Atom < custom atomic terms < Compound where different types of custom atomic terms are ordered by the Go-syntax representation of the types. It compares values of the same custom atomic term type T by the provided comparison function.
func CompareCompound ¶
CompareCompound compares the Compound with a Term.
func WriteCompound ¶
WriteCompound outputs the Compound to an io.Writer.
Types ¶
type Atom ¶
type Atom string
Atom is a prolog atom.
func NewAtomRune ¶
func (Atom) Apply ¶
Apply returns a Compound which Functor is the Atom and args are the arguments. If the arguments are empty, then returns itself.
type Dict ¶
type Dict interface { Compound Tag() Term All() iter.Seq2[Atom, Term] Value(key Atom) (Term, bool) At(i int) (Atom, Term, bool) Len() int }
Dict is a term that represents a dictionary.
Dicts are currently represented as a compound term using the functor `dict`. The first argument is the tag. The remaining arguments create an array of sorted key-value pairs.
type Env ¶
type Env struct {
// contains filtered or unexported fields
}
Env is a mapping from variables to terms.
type Exception ¶
type Exception struct {
// contains filtered or unexported fields
}
Exception is an error represented by a prolog term.
func DomainError ¶
DomainError creates a new domain error exception.
func EvaluationError ¶
EvaluationError creates a new evaluation error exception.
func ExistenceError ¶
ExistenceError creates a new existence error exception.
func InstantiationError ¶
InstantiationError returns an instantiation error exception.
func NewException ¶
NewException creates an Exception from a copy of the given Term.
func PermissionError ¶
PermissionError creates a new permission error exception.
func RepresentationError ¶
RepresentationError creates a new representation error exception.
func ResourceError ¶
ResourceError creates a new resource error exception.
func SyntaxError ¶
SyntaxError creates a new syntax error exception.
type Float ¶
type Float struct {
// contains filtered or unexported fields
}
Float is a prolog "falsy" floating-point number.
The underlying implementation is not based on floating-point, it's a [GDA](https://speleotrove.com/decimal/) compatible implementation to avoid approximation and determinism issues. It uses under the hood a decimal128 with 34 precision digits and must be manipulated using the `decimal128Ctx` only.
It serves as an immutable wrapper over `apd.Decimal`.
func NewFloatFromInt64 ¶
func NewFloatFromString ¶
type HookFunc ¶
HookFunc is a type for a hook function that is triggered before the VM executes a specific instruction. If the hook function returns an error, the VM halts execution and returns the error.
func CompositeHook ¶
CompositeHook returns a hook function that chains multiple hooks together. The hooks are executed sequentially, and if any hook returns an error, the execution stops.
func DebugHookFn ¶
DebugHookFn is a function that returns a hook function that prints the executed instruction.
type Integer ¶
type Integer int64
Integer is a prolog integer.
type Lexer ¶
type Lexer struct {
// contains filtered or unexported fields
}
Lexer turns runes into tokens.
type ListIterator ¶
type ListIterator struct { List Term Env *Env AllowPartial bool AllowCycle bool // contains filtered or unexported fields }
ListIterator is an iterator for a list.
func (*ListIterator) Current ¶
func (i *ListIterator) Current() Term
Current returns the current element.
func (*ListIterator) Next ¶
func (i *ListIterator) Next() bool
Next proceeds to the next element of the list and returns true if there's such an element.
func (*ListIterator) Suffix ¶
func (i *ListIterator) Suffix() Term
Suffix returns the rest of the list.
type NextFunc ¶
type NextFunc = func() (PromiseFunc, bool)
NextFunc defines the type of a function that returns the next PromiseFunc in a sequence, along with a boolean indicating whether the returned value is valid.
type Number ¶
type Number interface { Term // contains filtered or unexported methods }
Number is a prolog number, either Integer or Float.
type ParsedVariable ¶
ParsedVariable is a set of information regarding a variable in a parsed term.
type Parser ¶
type Parser struct { Vars []ParsedVariable // contains filtered or unexported fields }
Parser turns bytes into Term.
func NewParser ¶
func NewParser(vm *VM, r io.RuneReader) *Parser
NewParser creates a new parser from the current VM and io.RuneReader.
func (*Parser) SetPlaceholder ¶
SetPlaceholder registers placeholder and its arguments. Every occurrence of placeholder will be replaced by arguments. Mismatch of the number of occurrences of placeholder and the number of arguments raises an error.
type Predicate0 ¶
Predicate0 is a predicate of arity 0.
type Predicate1 ¶
Predicate1 is a predicate of arity 1.
type Predicate2 ¶
Predicate2 is a predicate of arity 2.
type Predicate3 ¶
Predicate3 is a predicate of arity 3.
type Predicate4 ¶
Predicate4 is a predicate of arity 4.
type Predicate5 ¶
Predicate5 is a predicate of arity 5.
type Predicate6 ¶
Predicate6 is a predicate of arity 6.
type Predicate7 ¶
Predicate7 is a predicate of arity 7.
type Predicate8 ¶
Predicate8 is a predicate of arity 8.
type Promise ¶
type Promise struct {
// contains filtered or unexported fields
}
Promise is a delayed execution that results in (bool, error). The zero value for Promise is equivalent to Bool(false).
func AcyclicTerm ¶
AcyclicTerm checks if t is acyclic.
func Arg ¶
Arg extracts nth argument of term as arg, or finds the argument position of arg in term as nth.
func AtomChars ¶
AtomChars breaks down atom into list of characters and unifies with chars, or constructs an atom from a list of characters chars and unifies it with atom.
func AtomCodes ¶
AtomCodes breaks up atom into a list of runes and unifies it with codes, or constructs an atom from the list of runes and unifies it with atom.
func AtomConcat ¶
AtomConcat concatenates atom1 and atom2 and unifies it with atom3.
func AtomLength ¶
AtomLength counts the runes in atom and unifies the result with length.
func BagOf ¶
BagOf collects all the solutions of goal as instances, which unify with template. instances may contain duplications.
func Between ¶
Between succeeds when lower, upper, and value are all integers, and lower <= value <= upper. If value is a variable, it is unified with successive integers from lower to upper.
func Call ¶
Call executes goal. it succeeds if goal followed by k succeeds. A cut inside goal doesn't affect outside of Call.
func Call7 ¶
func Call7(vm *VM, closure, arg1, arg2, arg3, arg4, arg5, arg6, arg7 Term, k Cont, env *Env) *Promise
Call7 succeeds if closure with 7 additional arguments succeeds.
func CallNth ¶
CallNth succeeds iff goal succeeds and nth unifies with the number of re-execution. See http://www.complang.tuwien.ac.at/ulrich/iso-prolog/call_nth
func Catch ¶
Catch calls goal. If an exception is thrown and unifies with catcher, it calls recover.
func CharConversion ¶
CharConversion registers a character conversion from inChar to outChar, or remove the conversion if inChar = outChar.
func Clause ¶
Clause unifies head and body with H and B respectively where H :- B is in the database.
func CurrentCharConversion ¶
CurrentCharConversion succeeds iff a conversion from inChar to outChar is defined.
func CurrentInput ¶
CurrentInput unifies stream with the current input stream.
func CurrentOutput ¶
CurrentOutput unifies stream with the current output stream.
func CurrentPredicate ¶
CurrentPredicate matches pi with a predicate indicator of the user-defined procedures in the database.
func CurrentPrologFlag ¶
CurrentPrologFlag succeeds iff flag is set to value.
func Delay ¶
func Delay(k ...PromiseFunc) *Promise
Delay delays an execution of k. Should be used with reasonable quantity of k, otherwise prefer DelaySeq.
func ExpandTerm ¶
ExpandTerm transforms term1 according to term_expansion/2 and DCG rules then unifies with term2.
func FindAll ¶
FindAll collects all the solutions of goal as instances, which unify with template. instances may contain duplications.
func FlushOutput ¶
FlushOutput sends any buffered output to the stream.
func Functor ¶
Functor extracts the name and arity of term, or unifies term with an atomic/compound term of name and arity with fresh variables as arguments.
func GetByte ¶
GetByte reads a byte from the stream represented by streamOrAlias and unifies it with inByte.
func GetChar ¶
GetChar reads a character from the stream represented by streamOrAlias and unifies it with char.
func GetDict3 ¶
GetDict3 return the value associated with keyPath. keyPath is either a single key or a term Key1/Key2/.... Each key is either an atom, small integer or a variable. While Dict.Key (see Op3) throws an existence error, this function fails silently if a key does not exist in the target dict.
func GreaterThan ¶
GreaterThan succeeds iff e1 is greater than e2.
func GreaterThanOrEqual ¶
GreaterThanOrEqual succeeds iff e1 is greater than or equal to e2.
func LessThanOrEqual ¶
LessThanOrEqual succeeds iff e1 is less than or equal to e2.
func Negate ¶
Negate calls goal and returns false if it succeeds. Otherwise, invokes the continuation.
func NumberChars ¶
NumberChars breaks up an atom representation of a number num into a list of characters and unifies it with chars, or constructs a number from a list of characters chars and unifies it with num.
func NumberCodes ¶
NumberCodes breaks up an atom representation of a number num into a list of runes and unifies it with codes, or constructs a number from a list of runes codes and unifies it with num.
func Op3 ¶
Op3 primarily evaluates "./2" terms within Dict expressions. If the provided Function is an atom, the function checks for the corresponding key in the Dict, raising an exception if the key is missing. For compound terms, it interprets Function as a call to a predefined set of functions, processing it accordingly.
func PeekByte ¶
PeekByte peeks a byte from the stream represented by streamOrAlias and unifies it with inByte.
func PeekChar ¶
PeekChar peeks a rune from the stream represented by streamOrAlias and unifies it with char.
func PutDict3 ¶
PutDict3 evaluates to a new dict where the key-values in dictIn replace or extend the key-values in the original dict.
new is either a dict or list of attribute-value pairs using the syntax Key:Value, Key=Value, Key-Value or Key(Value)
func ReadTerm ¶
ReadTerm reads from the stream represented by streamOrAlias and unifies with stream.
func SetOf ¶
SetOf collects all the solutions of goal as instances, which unify with template. instances don't contain duplications.
func SetPrologFlag ¶
SetPrologFlag sets flag to value.
func SetStreamPosition ¶
SetStreamPosition sets the position property of the stream represented by streamOrAlias.
func SkipMaxList ¶
SkipMaxList iterates over list up to max elements and unifies the number of skipped elements with skip and the rest with suffix.
func StreamProperty ¶
StreamProperty succeeds iff the stream represented by stream has the stream property.
func SubAtom ¶
SubAtom unifies subAtom with a sub atom of length which appears with before runes preceding it and after runes following it.
func SubsumesTerm ¶
SubsumesTerm succeeds if general and specific are unifiable without binding variables in specific.
func TermVariables ¶
TermVariables succeeds if vars unifies with a list of variables in term.
func TypeCompound ¶
TypeCompound checks if t is a compound term.
func TypeInteger ¶
TypeInteger checks if t is an integer.
func UnifyWithOccursCheck ¶
UnifyWithOccursCheck unifies x and y with occurs check (i.e., X = f(X) is not allowed).
func Univ ¶
Univ constructs list as a list which first element is the functor of term and the rest is the arguments of term, or construct a compound from list as term.
type PromiseFunc ¶
PromiseFunc defines the type of a function that returns a promise.
type Stream ¶
type Stream struct {
// contains filtered or unexported fields
}
Stream is a prolog stream.
func NewInputBinaryStream ¶
NewInputBinaryStream creates a new input binary stream backed by the given io.Reader.
func NewInputTextStream ¶
NewInputTextStream creates a new input text stream backed by the given io.Reader.
func NewOutputBinaryStream ¶
NewOutputBinaryStream creates a new output binary stream backed by the given io.Writer.
func NewOutputTextStream ¶
NewOutputTextStream creates a new output text stream backed by the given io.Writer.
func (*Stream) Name ¶
Name returns the stream's name. If the underlying source/sink doesn't have a name, returns "".
func (*Stream) ReadByte ¶
ReadByte reads a byte from the underlying source. It throws an error if the stream is not an input binary stream.
func (*Stream) ReadRune ¶
ReadRune reads the next rune from the underlying source. It throws an error if the stream is not an input text stream.
func (*Stream) UnreadByte ¶
func (*Stream) UnreadRune ¶
func (*Stream) WriteByte ¶
WriteByte writes the byte c to the underlying sink. It throws an error if the stream is not an output binary stream,.
type Term ¶
type Term interface { WriteTerm(w io.Writer, opts *WriteOptions, env *Env) error Compare(t Term, env *Env) int }
Term is a prolog term.
func PartialList ¶
PartialList returns a list of ts followed by tail.
type Token ¶
type Token struct {
// contains filtered or unexported fields
}
Token is a smallest meaningful unit of prolog program.
type VM ¶
type VM struct { // Unknown is a callback that is triggered when the VM reaches to an unknown predicate while current_prolog_flag(unknown, warning). Unknown func(name Atom, args []Term, env *Env) // FS is a file system that is referenced when the VM loads Prolog texts e.g. ensure_loaded/1. // It has no effect on open/4 nor open/3 which always access the actual file system. FS fs.FS // contains filtered or unexported fields }
VM is the core of a Prolog interpreter. The zero value for VM is a valid VM without any builtin predicates.
func (*VM) ClearHook ¶
func (vm *VM) ClearHook()
ClearHook removes the installed hook function from the VM.
func (*VM) InstallHook ¶
InstallHook sets the given hook function in the VM.
func (*VM) Register0 ¶
func (vm *VM) Register0(name Atom, p Predicate0)
Register0 registers a predicate of arity 0.
func (*VM) Register1 ¶
func (vm *VM) Register1(name Atom, p Predicate1)
Register1 registers a predicate of arity 1.
func (*VM) Register2 ¶
func (vm *VM) Register2(name Atom, p Predicate2)
Register2 registers a predicate of arity 2.
func (*VM) Register3 ¶
func (vm *VM) Register3(name Atom, p Predicate3)
Register3 registers a predicate of arity 3.
func (*VM) Register4 ¶
func (vm *VM) Register4(name Atom, p Predicate4)
Register4 registers a predicate of arity 4.
func (*VM) Register5 ¶
func (vm *VM) Register5(name Atom, p Predicate5)
Register5 registers a predicate of arity 5.
func (*VM) Register6 ¶
func (vm *VM) Register6(name Atom, p Predicate6)
Register6 registers a predicate of arity 6.
func (*VM) Register7 ¶
func (vm *VM) Register7(name Atom, p Predicate7)
Register7 registers a predicate of arity 7.
func (*VM) Register8 ¶
func (vm *VM) Register8(name Atom, p Predicate8)
Register8 registers a predicate of arity 8.
func (*VM) SetMaxVariables ¶
SetMaxVariables sets the maximum number of variables that the VM can create. Zero value mean no limits
func (*VM) SetUserInput ¶
SetUserInput sets the given stream as user_input.
func (*VM) SetUserOutput ¶
SetUserOutput sets the given stream as user_output.
type WriteOptions ¶
type WriteOptions struct {
// contains filtered or unexported fields
}
WriteOptions specify how the Term writes itself.