engine

package
v0.11.1 Latest Latest
Warning

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

Go to latest
Published: Sep 19, 2022 License: MIT Imports: 19 Imported by: 15

Documentation

Index

Constants

View Source
const (
	// StreamModeRead means you can read from the stream.
	StreamModeRead = StreamMode(os.O_RDONLY)
	// StreamModeWrite means you can write to the stream.
	StreamModeWrite = StreamMode(os.O_CREATE | os.O_WRONLY)
	// StreamModeAppend means you can append to the stream.
	StreamModeAppend = StreamMode(os.O_APPEND) | StreamModeWrite
)

Variables

View Source
var (
	// Success is a continuation that leads to true.
	Success = func(*Env) *Promise {
		return Bool(true)
	}

	// Failure is a continuation that leads to false.
	Failure = func(*Env) *Promise {
		return Bool(false)
	}
)
View Source
var DefaultEvaluableFunctors = EvaluableFunctors{
	Constant: map[Atom]Number{
		`pi`: Float(math.Pi),
	},
	Unary: map[Atom]func(Number) (Number, error){
		`-`:                     Neg,
		`abs`:                   Abs,
		`sign`:                  Sign,
		`float_integer_part`:    FloatIntegerPart,
		`float_fractional_part`: FloatFractionalPart,
		`float`:                 AsFloat,
		`floor`:                 Floor,
		`truncate`:              Truncate,
		`round`:                 Round,
		`ceiling`:               Ceiling,

		`sin`:  Sin,
		`cos`:  Cos,
		`atan`: Atan,
		`exp`:  Exp,
		`log`:  Log,
		`sqrt`: Sqrt,

		`\`: BitwiseComplement,

		`+`:    Pos,
		`asin`: Asin,
		`acos`: Acos,
		`tan`:  Tan,
	},
	Binary: map[Atom]func(Number, Number) (Number, error){
		`+`:   Add,
		`-`:   Sub,
		`*`:   Mul,
		`//`:  IntDiv,
		`/`:   Div,
		`rem`: Rem,
		`mod`: Mod,

		`**`: Power,

		`>>`: BitwiseRightShift,
		`<<`: BitwiseLeftShift,
		`/\`: BitwiseAnd,
		`\/`: BitwiseOr,

		`div`:   IntFloorDiv,
		`max`:   Max,
		`min`:   Min,
		`^`:     IntegerPower,
		`atan2`: Atan2,
		`xor`:   Xor,
	},
}

DefaultEvaluableFunctors is a EvaluableFunctors with builtin functions.

View Source
var (
	// ErrInsufficient is a parsing error which can be resolved by adding more characters to the input.
	ErrInsufficient = errors.New("insufficient")
)

Functions

func Contains added in v0.4.1

func Contains(t, s Term, env *Env) bool

Contains checks if t contains s.

func WriteTerm added in v0.11.0

func WriteTerm(w io.Writer, t Term, opts *WriteOptions, env *Env) error

Types

type AltIterator added in v0.9.0

type AltIterator struct {
	Alt Term
	Env *Env
	// contains filtered or unexported fields
}

AltIterator is an iterator for alternatives.

func (*AltIterator) Current added in v0.9.0

func (i *AltIterator) Current() Term

Current returns the current element.

func (*AltIterator) Next added in v0.9.0

func (i *AltIterator) Next() bool

Next proceeds to the next element of the alternatives and returns true if there's such an element.

type AnyIterator added in v0.9.0

type AnyIterator struct {
	Any Term
	Env *Env
	// contains filtered or unexported fields
}

AnyIterator is an iterator for a list or a sequence.

func (*AnyIterator) Current added in v0.9.0

func (i *AnyIterator) Current() Term

Current returns the current element.

func (*AnyIterator) Err added in v0.9.0

func (i *AnyIterator) Err() error

Err returns an error.

func (*AnyIterator) Next added in v0.9.0

func (i *AnyIterator) Next() bool

Next proceeds to the next element and returns true if there's such an element.

type Atom added in v0.4.1

type Atom string

Atom is a prolog atom.

func (Atom) Apply added in v0.4.1

func (a Atom) Apply(args ...Term) Term

Apply returns a Compound which Functor is the Atom and args are the arguments. If the arguments are empty, then returns itself.

type Compound added in v0.4.1

type Compound interface {
	Functor() Atom
	Arity() int
	Arg(n int) Term
}

Compound is a Prolog compound.

type EOFAction added in v0.4.1

type EOFAction int

EOFAction describes what happens when you reached to the end of the stream.

const (
	// EOFActionEOFCode means either an atom `end_of_file`, or an integer `-1` will be returned.
	EOFActionEOFCode EOFAction = iota
	// EOFActionError means an error will be raised.
	EOFActionError
	// EOFActionReset means another attempt will be made.
	EOFActionReset
)

func (EOFAction) String added in v0.6.0

func (a EOFAction) String() string

type Env added in v0.4.1

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

Env is a mapping from variables to terms.

var GoStringEnv *Env

GoStringEnv is an Env which resolves a Variable when GoString() is called.

func NewEnv added in v0.4.1

func NewEnv() *Env

NewEnv creates an empty environment.

func (*Env) Bind added in v0.4.1

func (e *Env) Bind(k Variable, v Term) *Env

Bind adds a new entry to the environment.

func (*Env) Compare added in v0.11.0

func (e *Env) Compare(x, y Term) Order

Compare compares two terms.

func (*Env) FreeVariables added in v0.4.1

func (e *Env) FreeVariables(ts ...Term) []Variable

FreeVariables extracts variables in the given terms.

func (*Env) Lookup added in v0.4.1

func (e *Env) Lookup(k Variable) (Term, bool)

Lookup returns a term that the given variable is bound to.

func (*Env) Resolve added in v0.4.1

func (e *Env) Resolve(t Term) Term

Resolve follows the variable chain and returns the first non-variable term or the last free variable.

func (*Env) Set added in v0.9.0

func (e *Env) Set(ts ...Term) Term

Set returns a list of ts which elements are unique.

func (*Env) Simplify added in v0.4.1

func (e *Env) Simplify(t Term) Term

Simplify trys to remove as many variables as possible from term t.

func (*Env) Unify added in v0.11.0

func (e *Env) Unify(x, y Term, occursCheck bool) (*Env, bool)

type EvaluableFunctors added in v0.9.0

type EvaluableFunctors struct {
	// Constant is a set of constants.
	Constant map[Atom]Number

	// Unary is a set of functions of arity 1.
	Unary map[Atom]func(x Number) (Number, error)

	// Binary is a set of functions of arity 2.
	Binary map[Atom]func(x, y Number) (Number, error)
}

EvaluableFunctors is a set of unary/binary functions.

func (EvaluableFunctors) Equal added in v0.9.0

func (e EvaluableFunctors) Equal(e1, e2 Term, k func(*Env) *Promise, env *Env) *Promise

Equal succeeds iff e1 equals to e2.

func (EvaluableFunctors) GreaterThan added in v0.9.0

func (e EvaluableFunctors) GreaterThan(e1, e2 Term, k func(*Env) *Promise, env *Env) *Promise

GreaterThan succeeds iff e1 is greater than e2.

func (EvaluableFunctors) GreaterThanOrEqual added in v0.9.0

func (e EvaluableFunctors) GreaterThanOrEqual(e1, e2 Term, k func(*Env) *Promise, env *Env) *Promise

GreaterThanOrEqual succeeds iff e1 is greater than or equal to e2.

func (EvaluableFunctors) Is added in v0.9.0

func (e EvaluableFunctors) Is(result, expression Term, k func(*Env) *Promise, env *Env) *Promise

Is evaluates expression and unifies the result with result.

func (EvaluableFunctors) LessThan added in v0.9.0

func (e EvaluableFunctors) LessThan(e1, e2 Term, k func(*Env) *Promise, env *Env) *Promise

LessThan succeeds iff e1 is less than e2.

func (EvaluableFunctors) LessThanOrEqual added in v0.9.0

func (e EvaluableFunctors) LessThanOrEqual(e1, e2 Term, k func(*Env) *Promise, env *Env) *Promise

LessThanOrEqual succeeds iff e1 is less than or equal to e2.

func (EvaluableFunctors) NotEqual added in v0.9.0

func (e EvaluableFunctors) NotEqual(e1, e2 Term, k func(*Env) *Promise, env *Env) *Promise

NotEqual succeeds iff e1 doesn't equal to e2.

type Exception

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

Exception is an error represented by a prolog term.

func DomainError added in v0.4.0

func DomainError(validDomain ValidDomain, culprit Term, env *Env) Exception

DomainError creates a new domain error exception.

func EvaluationError added in v0.10.0

func EvaluationError(ev ExceptionalValue, env *Env) Exception

EvaluationError creates a new evaluation error exception.

func ExistenceError added in v0.4.0

func ExistenceError(objectType ObjectType, culprit Term, env *Env) Exception

ExistenceError creates a new existence error exception.

func InstantiationError added in v0.4.0

func InstantiationError(env *Env) Exception

InstantiationError returns an instantiation error exception.

func NewException added in v0.10.0

func NewException(term Term, env *Env) Exception

NewException creates an exception from a copy of the given term.

func PermissionError added in v0.4.0

func PermissionError(operation Operation, permissionType PermissionType, culprit Term, env *Env) Exception

PermissionError creates a new permission error exception.

func RepresentationError added in v0.10.0

func RepresentationError(limit Flag, env *Env) Exception

RepresentationError creates a new representation error exception.

func ResourceError added in v0.10.0

func ResourceError(resource Resource, env *Env) Exception

ResourceError creates a new resource error exception.

func SyntaxError added in v0.10.0

func SyntaxError(err error, env *Env) Exception

SyntaxError creates a new syntax error exception.

func SystemError added in v0.4.0

func SystemError(err error) Exception

SystemError creates a new system error exception.

func TypeError added in v0.4.0

func TypeError(validType ValidType, culprit Term, env *Env) Exception

TypeError creates a new type error exception.

func (Exception) Error

func (e Exception) Error() string

func (Exception) Term

func (e Exception) Term() Term

Term returns the underlying term of the exception.

type ExceptionalValue added in v0.10.0

type ExceptionalValue uint8

ExceptionalValue is an evaluable functor's result which is not a number.

const (
	ExceptionalValueFloatOverflow ExceptionalValue = iota
	ExceptionalValueIntOverflow
	ExceptionalValueUnderflow
	ExceptionalValueZeroDivisor
	ExceptionalValueUndefined
)

ExceptionalValue is one of these values.

func (ExceptionalValue) Error added in v0.10.0

func (ev ExceptionalValue) Error() string

func (ExceptionalValue) Term added in v0.10.0

func (ev ExceptionalValue) Term() Term

Term returns an Atom for the ExceptionalValue.

type Flag added in v0.10.0

type Flag uint8

Flag is an implementation defined limit.

const (
	FlagCharacter Flag = iota
	FlagCharacterCode
	FlagInCharacterCode
	FlagMaxArity
	FlagMaxInteger
	FlagMinInteger
)

Flag is one of these values.

func (Flag) Term added in v0.10.0

func (f Flag) Term() Term

Term returns an Atom for the Flag.

type Float added in v0.4.1

type Float float64

Float is a prolog floating-point number.

type Integer added in v0.4.1

type Integer int64

Integer is a prolog integer.

type Lexer added in v0.4.1

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

Lexer turns bytes into tokens.

func (*Lexer) Token added in v0.9.0

func (l *Lexer) Token() Token

Token returns the next token.

type ListIterator added in v0.9.0

type ListIterator struct {
	List         Term
	Env          *Env
	AllowPartial bool
	// contains filtered or unexported fields
}

ListIterator is an iterator for a list.

func (*ListIterator) Current added in v0.9.0

func (i *ListIterator) Current() Term

Current returns the current element.

func (*ListIterator) Err added in v0.9.0

func (i *ListIterator) Err() error

Err returns an error.

func (*ListIterator) Next added in v0.9.0

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 added in v0.10.0

func (i *ListIterator) Suffix() Term

Suffix returns the rest of the list.

type Number added in v0.9.0

type Number interface {
	Term
	// contains filtered or unexported methods
}

Number is a prolog number, either Integer or Float.

func Abs added in v0.9.0

func Abs(x Number) (Number, error)

Abs returns the absolute value of x.

func Acos added in v0.9.0

func Acos(x Number) (Number, error)

Acos returns the arc cosine of x.

func Add added in v0.9.0

func Add(x, y Number) (Number, error)

Add returns sum of 2 numbers.

func AsFloat added in v0.9.0

func AsFloat(x Number) (Number, error)

AsFloat returns x as engine.Float.

func Asin added in v0.9.0

func Asin(x Number) (Number, error)

Asin returns the arc sine of x.

func Atan added in v0.9.0

func Atan(x Number) (Number, error)

Atan returns the arctangent of x.

func Atan2 added in v0.9.0

func Atan2(y, x Number) (Number, error)

Atan2 returns the arc tangent of y/x.

func BitwiseAnd added in v0.9.0

func BitwiseAnd(b1, b2 Number) (Number, error)

BitwiseAnd returns the logical AND on each bit.

func BitwiseComplement added in v0.9.0

func BitwiseComplement(b1 Number) (Number, error)

BitwiseComplement returns the logical negation on each bit.

func BitwiseLeftShift added in v0.9.0

func BitwiseLeftShift(n, s Number) (Number, error)

BitwiseLeftShift returns n bit-shifted by s to the left.

func BitwiseOr added in v0.9.0

func BitwiseOr(b1, b2 Number) (Number, error)

BitwiseOr returns the logical OR on each bit.

func BitwiseRightShift added in v0.9.0

func BitwiseRightShift(n, s Number) (Number, error)

BitwiseRightShift returns n bit-shifted by s to the right.

func Ceiling added in v0.9.0

func Ceiling(x Number) (Number, error)

Ceiling returns the least integer value greater than or equal to x.

func Cos added in v0.9.0

func Cos(x Number) (Number, error)

Cos returns the cosine of x.

func Div added in v0.9.0

func Div(x, y Number) (Number, error)

Div returns division of 2 numbers

func Exp added in v0.9.0

func Exp(x Number) (Number, error)

Exp returns the base-e exponential of x.

func FloatFractionalPart added in v0.9.0

func FloatFractionalPart(x Number) (Number, error)

FloatFractionalPart returns the fractional part of x.

func FloatIntegerPart added in v0.9.0

func FloatIntegerPart(x Number) (Number, error)

FloatIntegerPart returns the integer part of x.

func Floor added in v0.9.0

func Floor(x Number) (Number, error)

Floor returns the greatest integer value less than or equal to x.

func IntDiv added in v0.9.0

func IntDiv(x, y Number) (Number, error)

IntDiv returns integer division of 2 numbers.

func IntFloorDiv added in v0.9.0

func IntFloorDiv(x, y Number) (Number, error)

IntFloorDiv returns the integer floor division.

func IntegerPower added in v0.9.0

func IntegerPower(x, y Number) (Number, error)

IntegerPower returns x raised to the power of y.

func Log added in v0.9.0

func Log(x Number) (Number, error)

Log returns the natural logarithm of x.

func Max added in v0.9.0

func Max(x, y Number) (Number, error)

Max returns the maximum of x or y.

func Min added in v0.9.0

func Min(x, y Number) (Number, error)

Min returns the minimum of x or y.

func Mod added in v0.9.0

func Mod(x, y Number) (Number, error)

Mod returns modulo of 2 numbers.

func Mul added in v0.9.0

func Mul(x, y Number) (Number, error)

Mul returns multiplication of 2 numbers.

func Neg added in v0.9.0

func Neg(x Number) (Number, error)

Neg returns the negation of a number.

func Pos added in v0.9.0

func Pos(x Number) (Number, error)

Pos returns x as is.

func Power added in v0.9.0

func Power(x, y Number) (Number, error)

Power returns the base-x exponential of y.

func Rem added in v0.9.0

func Rem(x, y Number) (Number, error)

Rem returns remainder of 2 numbers.

func Round added in v0.9.0

func Round(x Number) (Number, error)

Round returns the nearest integer of x.

func Sign added in v0.9.0

func Sign(x Number) (Number, error)

Sign returns +1, 0, or -1 depending on the sign of x.

func Sin added in v0.9.0

func Sin(x Number) (Number, error)

Sin returns the sine of x.

func Sqrt added in v0.9.0

func Sqrt(x Number) (Number, error)

Sqrt returns the square root of x.

func Sub added in v0.9.0

func Sub(x, y Number) (Number, error)

Sub returns subtraction of 2 numbers.

func Tan added in v0.9.0

func Tan(x Number) (Number, error)

Tan returns the tangent of x.

func Truncate added in v0.9.0

func Truncate(x Number) (Number, error)

Truncate returns the integer value of x.

func Xor added in v0.9.0

func Xor(x, y Number) (Number, error)

Xor returns the bitwise exclusive or of x and y.

type ObjectType added in v0.10.0

type ObjectType uint8

ObjectType is the object on which an operation is to be performed.

const (
	ObjectTypeProcedure ObjectType = iota
	ObjectTypeSourceSink
	ObjectTypeStream
)

ObjectType is one of these values.

func (ObjectType) Term added in v0.10.0

func (ot ObjectType) Term() Term

Term returns an Atom for the ObjectType.

type Operation added in v0.10.0

type Operation uint8

Operation is the operation to be performed.

const (
	OperationAccess Operation = iota
	OperationCreate
	OperationInput
	OperationModify
	OperationOpen
	OperationOutput
	OperationReposition
)

Operation is one of these values.

func (Operation) Term added in v0.10.0

func (o Operation) Term() Term

Term returns an Atom for the Operation.

type Order added in v0.11.0

type Order int8

Order indicates ordering of two terms.

const (
	OrderEqual Order = iota
	OrderLess
	OrderGreater
)

Order is either =, <, or >.

func (Order) GoString added in v0.11.0

func (o Order) GoString() string

func (Order) Term added in v0.11.0

func (o Order) Term() Term

Term returns the Atom representation of Order.

type ParsedVariable added in v0.4.1

type ParsedVariable struct {
	Name     Atom
	Variable Variable
	Count    int
}

ParsedVariable is a set of information regarding a variable in a parsed term.

type Parser added in v0.4.1

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

Parser turns bytes into Term.

func (*Parser) More added in v0.4.1

func (p *Parser) More() bool

More checks if the parser has more tokens to read.

func (*Parser) Number added in v0.4.1

func (p *Parser) Number() (Number, error)

Number parses a number term.

func (*Parser) Replace added in v0.4.1

func (p *Parser) Replace(placeholder Atom, args ...interface{}) error

Replace 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.

func (*Parser) Term added in v0.4.1

func (p *Parser) Term() (Term, error)

Term parses a term followed by a full stop.

type PermissionType added in v0.10.0

type PermissionType uint8

PermissionType is the type to which the operation is not permitted to perform.

const (
	PermissionTypeBinaryStream PermissionType = iota
	PermissionTypeFlag
	PermissionTypeOperator
	PermissionTypePastEndOfStream
	PermissionTypePrivateProcedure
	PermissionTypeStaticProcedure
	PermissionTypeSourceSink
	PermissionTypeStream
	PermissionTypeTextStream
)

PermissionType is one of these values.

func (PermissionType) Term added in v0.10.0

func (pt PermissionType) Term() Term

Term returns an Atom for the PermissionType.

type ProcedureIndicator added in v0.3.0

type ProcedureIndicator struct {
	Name  Atom
	Arity Integer
}

ProcedureIndicator identifies procedure e.g. (=)/2.

func NewProcedureIndicator added in v0.4.1

func NewProcedureIndicator(pi Term, env *Env) (ProcedureIndicator, error)

NewProcedureIndicator creates a new ProcedureIndicator from a term that matches Name/Arity.

func (ProcedureIndicator) Apply added in v0.3.0

func (p ProcedureIndicator) Apply(args ...Term) (Term, error)

Apply applies p to args.

func (ProcedureIndicator) String added in v0.3.0

func (p ProcedureIndicator) String() string

func (ProcedureIndicator) Term added in v0.3.0

func (p ProcedureIndicator) Term() Term

Term returns p as term.

type Promise added in v0.4.1

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 added in v0.9.0

func AcyclicTerm(t Term, k func(*Env) *Promise, env *Env) *Promise

AcyclicTerm checks if t is acyclic.

func Append added in v0.11.0

func Append(xs, ys, zs Term, k func(*Env) *Promise, env *Env) *Promise

Append succeeds iff zs is the concatenation of lists xs and ys.

func Arg

func Arg(nth, t, arg Term, k func(*Env) *Promise, env *Env) *Promise

Arg extracts nth argument of term as arg, or finds the argument position of arg in term as nth.

func AtomChars

func AtomChars(atom, chars Term, k func(*Env) *Promise, env *Env) *Promise

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

func AtomCodes(atom, codes Term, k func(*Env) *Promise, env *Env) *Promise

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

func AtomConcat(atom1, atom2, atom3 Term, k func(*Env) *Promise, env *Env) *Promise

AtomConcat concatenates atom1 and atom2 and unifies it with atom3.

func AtomLength

func AtomLength(atom, length Term, k func(*Env) *Promise, env *Env) *Promise

AtomLength counts the runes in atom and unifies the result with length.

func Between added in v0.9.0

func Between(lower, upper, value Term, k func(*Env) *Promise, env *Env) *Promise

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 Bool added in v0.4.1

func Bool(ok bool) *Promise

Bool returns a promise that simply returns (ok, nil).

func Catch added in v0.4.1

func Catch(recover func(error) *Promise, k func(context.Context) *Promise) *Promise

Catch returns a promise with a recovering function. Once a promise results in error, the error goes through ancestor promises looking for a recovering function that returns a non-nil promise to continue on.

func CharCode

func CharCode(char, code Term, k func(*Env) *Promise, env *Env) *Promise

CharCode converts a single-rune Atom char to an Integer code, or vice versa.

func Compare

func Compare(order, term1, term2 Term, k func(*Env) *Promise, env *Env) *Promise

Compare compares term1 and term2 and unifies order with <, =, or >.

func CopyTerm

func CopyTerm(in, out Term, k func(*Env) *Promise, env *Env) *Promise

CopyTerm clones in as out.

func Cut added in v0.4.1

func Cut(parent *Promise, k func(context.Context) *Promise) *Promise

Cut returns a promise that once the execution reaches it, it eliminates other possible choices.

func Delay added in v0.4.1

func Delay(k ...func(context.Context) *Promise) *Promise

Delay delays an execution of k.

func Environ added in v0.7.0

func Environ(key, value Term, k func(*Env) *Promise, env *Env) *Promise

Environ succeeds if an environment variable key has value.

func Error added in v0.4.1

func Error(err error) *Promise

Error returns a promise that simply returns (false, err).

func Functor

func Functor(t, name, arity Term, k func(*Env) *Promise, env *Env) *Promise

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 Halt added in v0.3.0

func Halt(n Term, k func(*Env) *Promise, env *Env) *Promise

Halt exits the process with exit code of n.

func KeySort added in v0.9.0

func KeySort(pairs, sorted Term, k func(*Env) *Promise, env *Env) *Promise

KeySort succeeds if sorted is a sorted list of pairs based on their keys.

func Length added in v0.10.0

func Length(list, length Term, k func(*Env) *Promise, env *Env) *Promise

Length succeeds iff list is a list of length.

func Nth0 added in v0.9.0

func Nth0(n, list, elem Term, k func(*Env) *Promise, env *Env) *Promise

Nth0 succeeds if elem is the n-th element of list, counting from 0.

func Nth1 added in v0.9.0

func Nth1(n, list, elem Term, k func(*Env) *Promise, env *Env) *Promise

Nth1 succeeds if elem is the n-th element of list, counting from 1.

func NumberChars

func NumberChars(num, chars Term, k func(*Env) *Promise, env *Env) *Promise

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

func NumberCodes(num, codes Term, k func(*Env) *Promise, env *Env) *Promise

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 Repeat

func Repeat(k func(context.Context) *Promise) *Promise

Repeat returns a promise that repeats k.

func SkipMaxList added in v0.10.0

func SkipMaxList(skip, max, list, suffix Term, k func(*Env) *Promise, env *Env) *Promise

SkipMaxList iterates over list up to max elements and unifies the number of skipped elements with skip and the rest with suffix.

func Sort added in v0.9.0

func Sort(list, sorted Term, k func(*Env) *Promise, env *Env) *Promise

Sort succeeds if sorted list of elements of list unifies with sorted.

func SubAtom

func SubAtom(atom, before, length, after, subAtom Term, k func(*Env) *Promise, env *Env) *Promise

SubAtom unifies subAtom with a sub atom of length which appears with before runes preceding it and after runes following it.

func SubsumesTerm added in v0.9.0

func SubsumesTerm(general, specific Term, k func(*Env) *Promise, env *Env) *Promise

SubsumesTerm succeeds if general and specific are unifiable without binding variables in specific.

func Succ added in v0.9.0

func Succ(x, s Term, k func(*Env) *Promise, env *Env) *Promise

Succ succeeds if s is the successor of non-negative integer x.

func TermVariables added in v0.9.0

func TermVariables(term, vars Term, k func(*Env) *Promise, env *Env) *Promise

TermVariables succeeds if vars unifies with a list of variables in term.

func Throw

func Throw(ball Term, _ func(*Env) *Promise, env *Env) *Promise

Throw throws ball as an exception.

func TypeAtom

func TypeAtom(t Term, k func(*Env) *Promise, env *Env) *Promise

TypeAtom checks if t is an atom.

func TypeCompound

func TypeCompound(t Term, k func(*Env) *Promise, env *Env) *Promise

TypeCompound checks if t is a compound term.

func TypeFloat

func TypeFloat(t Term, k func(*Env) *Promise, env *Env) *Promise

TypeFloat checks if t is a floating-point number.

func TypeInteger

func TypeInteger(t Term, k func(*Env) *Promise, env *Env) *Promise

TypeInteger checks if t is an integer.

func TypeVar

func TypeVar(t Term, k func(*Env) *Promise, env *Env) *Promise

TypeVar checks if t is a variable.

func Unify

func Unify(x, y Term, k func(*Env) *Promise, env *Env) *Promise

Unify unifies x and y without occurs check (i.e., X = f(X) is allowed).

func UnifyWithOccursCheck

func UnifyWithOccursCheck(x, y Term, k func(*Env) *Promise, env *Env) *Promise

UnifyWithOccursCheck unifies x and y with occurs check (i.e., X = f(X) is not allowed).

func Univ

func Univ(t, list Term, k func(*Env) *Promise, env *Env) *Promise

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.

func (*Promise) Force added in v0.4.1

func (p *Promise) Force(ctx context.Context) (bool, error)

Force enforces the delayed execution and returns the result. (i.e. trampoline)

type Resource added in v0.10.0

type Resource uint8

Resource is a resource required to complete execution.

const (
	ResourceFiniteMemory Resource = iota
)

Resource is one of these values.

func (Resource) Term added in v0.10.0

func (r Resource) Term() Term

Term returns an Atom for the Resource.

type SeqIterator added in v0.9.0

type SeqIterator struct {
	Seq Term
	Env *Env
	// contains filtered or unexported fields
}

SeqIterator is an iterator for a sequence.

func (*SeqIterator) Current added in v0.9.0

func (i *SeqIterator) Current() Term

Current returns the current element.

func (*SeqIterator) Next added in v0.9.0

func (i *SeqIterator) Next() bool

Next proceeds to the next element of the sequence and returns true if there's such an element.

type State added in v0.5.0

type State struct {
	VM
	// contains filtered or unexported fields
}

State represents the internal state of an interpreter.

func (*State) Abolish added in v0.5.0

func (state *State) Abolish(pi Term, k func(*Env) *Promise, env *Env) *Promise

Abolish removes the procedure indicated by pi from the database.

func (*State) Assert added in v0.9.0

func (state *State) Assert(t Term, env *Env) error

Assert appends t to the database.

func (*State) Asserta added in v0.5.0

func (state *State) Asserta(t Term, k func(*Env) *Promise, env *Env) *Promise

Asserta prepends t to the database.

func (*State) Assertz added in v0.5.0

func (state *State) Assertz(t Term, k func(*Env) *Promise, env *Env) *Promise

Assertz appends t to the database.

func (*State) BagOf added in v0.5.0

func (state *State) BagOf(template, goal, instances Term, k func(*Env) *Promise, env *Env) *Promise

BagOf collects all the solutions of goal as instances, which unify with template. instances may contain duplications.

func (*State) BuiltIn added in v0.5.0

func (state *State) BuiltIn(pi Term, k func(*Env) *Promise, env *Env) *Promise

BuiltIn declares a procedure indicated by pi is built-in and static.

func (*State) Call added in v0.5.0

func (state *State) Call(goal Term, k func(*Env) *Promise, env *Env) *Promise

Call executes goal. it succeeds if goal followed by k succeeds. A cut inside goal doesn't affect outside of Call.

func (*State) Call1 added in v0.9.0

func (state *State) Call1(closure, arg1 Term, k func(*Env) *Promise, env *Env) *Promise

Call1 succeeds if closure with an additional argument succeeds.

func (*State) Call2 added in v0.9.0

func (state *State) Call2(closure, arg1, arg2 Term, k func(*Env) *Promise, env *Env) *Promise

Call2 succeeds if closure with 2 additional arguments succeeds.

func (*State) Call3 added in v0.9.0

func (state *State) Call3(closure, arg1, arg2, arg3 Term, k func(*Env) *Promise, env *Env) *Promise

Call3 succeeds if closure with 3 additional arguments succeeds.

func (*State) Call4 added in v0.9.0

func (state *State) Call4(closure, arg1, arg2, arg3, arg4 Term, k func(*Env) *Promise, env *Env) *Promise

Call4 succeeds if closure with 4 additional arguments succeeds.

func (*State) Call5 added in v0.9.0

func (state *State) Call5(closure, arg1, arg2, arg3, arg4, arg5 Term, k func(*Env) *Promise, env *Env) *Promise

Call5 succeeds if closure with 5 additional arguments succeeds.

func (*State) Call6 added in v0.9.0

func (state *State) Call6(closure, arg1, arg2, arg3, arg4, arg5, arg6 Term, k func(*Env) *Promise, env *Env) *Promise

Call6 succeeds if closure with 6 additional arguments succeeds.

func (*State) Call7 added in v0.9.0

func (state *State) Call7(closure, arg1, arg2, arg3, arg4, arg5, arg6, arg7 Term, k func(*Env) *Promise, env *Env) *Promise

Call7 succeeds if closure with 7 additional arguments succeeds.

func (*State) CallNth added in v0.10.0

func (state *State) CallNth(goal, nth Term, k func(*Env) *Promise, env *Env) *Promise

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 (*State) Catch added in v0.5.0

func (state *State) Catch(goal, catcher, recover Term, k func(*Env) *Promise, env *Env) *Promise

Catch calls goal. If an exception is thrown and unifies with catcher, it calls recover.

func (*State) CharConversion added in v0.5.0

func (state *State) CharConversion(inChar, outChar Term, k func(*Env) *Promise, env *Env) *Promise

CharConversion registers a character conversion from inChar to outChar, or remove the conversion if inChar = outChar.

func (*State) Clause added in v0.5.0

func (state *State) Clause(head, body Term, k func(*Env) *Promise, env *Env) *Promise

Clause unifies head and body with H and B respectively where H :- B is in the database.

func (*State) Close added in v0.5.0

func (state *State) Close(streamOrAlias, options Term, k func(*Env) *Promise, env *Env) *Promise

Close closes a stream specified by streamOrAlias.

func (*State) CurrentCharConversion added in v0.5.0

func (state *State) CurrentCharConversion(inChar, outChar Term, k func(*Env) *Promise, env *Env) *Promise

CurrentCharConversion succeeds iff a conversion from inChar to outChar is defined.

func (*State) CurrentInput added in v0.5.0

func (state *State) CurrentInput(stream Term, k func(*Env) *Promise, env *Env) *Promise

CurrentInput unifies stream with the current input stream.

func (*State) CurrentOp added in v0.5.0

func (state *State) CurrentOp(priority, specifier, op Term, k func(*Env) *Promise, env *Env) *Promise

CurrentOp succeeds if operator is defined with priority and specifier.

func (*State) CurrentOutput added in v0.5.0

func (state *State) CurrentOutput(stream Term, k func(*Env) *Promise, env *Env) *Promise

CurrentOutput unifies stream with the current output stream.

func (*State) CurrentPredicate added in v0.5.0

func (state *State) CurrentPredicate(pi Term, k func(*Env) *Promise, env *Env) *Promise

CurrentPredicate matches pi with a predicate indicator of the user-defined procedures in the database.

func (*State) CurrentPrologFlag added in v0.5.0

func (state *State) CurrentPrologFlag(flag, value Term, k func(*Env) *Promise, env *Env) *Promise

CurrentPrologFlag succeeds iff flag is set to value.

func (*State) Dynamic added in v0.5.0

func (state *State) Dynamic(pi Term, k func(*Env) *Promise, env *Env) *Promise

Dynamic declares a procedure indicated by pi is user-defined dynamic.

func (*State) Expand added in v0.9.0

func (state *State) Expand(term Term, env *Env) (Term, error)

Expand expands term according to term_expansion/2 and DCG rules.

func (*State) ExpandTerm added in v0.5.0

func (state *State) ExpandTerm(term1, term2 Term, k func(*Env) *Promise, env *Env) *Promise

ExpandTerm transforms term1 according to term_expansion/2 and DCG rules then unifies with term2.

func (*State) FindAll added in v0.5.0

func (state *State) FindAll(template, goal, instances Term, k func(*Env) *Promise, env *Env) *Promise

FindAll collects all the solutions of goal as instances, which unify with template. instances may contain duplications.

func (*State) FlushOutput added in v0.5.0

func (state *State) FlushOutput(streamOrAlias Term, k func(*Env) *Promise, env *Env) *Promise

FlushOutput sends any buffered output to the stream.

func (*State) GetByte added in v0.5.0

func (state *State) GetByte(streamOrAlias, inByte Term, k func(*Env) *Promise, env *Env) *Promise

GetByte reads a byte from the stream represented by streamOrAlias and unifies it with inByte.

func (*State) GetChar added in v0.5.0

func (state *State) GetChar(streamOrAlias, char Term, k func(*Env) *Promise, env *Env) *Promise

GetChar reads a character from the stream represented by streamOrAlias and unifies it with char.

func (*State) Negation added in v0.5.0

func (state *State) Negation(goal Term, k func(*Env) *Promise, env *Env) *Promise

Negation calls goal and returns false if it succeeds. Otherwise, invokes the continuation.

func (*State) Op added in v0.5.0

func (state *State) Op(priority, specifier, op Term, k func(*Env) *Promise, env *Env) *Promise

Op defines operator with priority and specifier, or removes when priority is 0.

func (*State) Open added in v0.5.0

func (state *State) Open(SourceSink, mode, stream, options Term, k func(*Env) *Promise, env *Env) *Promise

Open opens SourceSink in mode and unifies with stream.

func (*State) Parser added in v0.5.0

func (state *State) Parser(r io.Reader, vars *[]ParsedVariable) *Parser

Parser creates a new parser from the current State and io.Reader. If non-nil, vars will hold the information on variables it parses.

func (*State) PeekByte added in v0.5.0

func (state *State) PeekByte(streamOrAlias, inByte Term, k func(*Env) *Promise, env *Env) *Promise

PeekByte peeks a byte from the stream represented by streamOrAlias and unifies it with inByte.

func (*State) PeekChar added in v0.5.0

func (state *State) PeekChar(streamOrAlias, char Term, k func(*Env) *Promise, env *Env) *Promise

PeekChar peeks a rune from the stream represented by streamOrAlias and unifies it with char.

func (*State) Phrase added in v0.9.0

func (state *State) Phrase(grBody, s0, s Term, k func(*Env) *Promise, env *Env) *Promise

Phrase succeeds if the difference list of s0-s satisfies the grammar rule of grBody.

func (*State) PutByte added in v0.5.0

func (state *State) PutByte(streamOrAlias, byt Term, k func(*Env) *Promise, env *Env) *Promise

PutByte outputs an integer byte to a stream represented by streamOrAlias.

func (*State) PutCode added in v0.5.0

func (state *State) PutCode(streamOrAlias, code Term, k func(*Env) *Promise, env *Env) *Promise

PutCode outputs code to the stream represented by streamOrAlias.

func (*State) ReadTerm added in v0.5.0

func (state *State) ReadTerm(streamOrAlias, out, options Term, k func(*Env) *Promise, env *Env) *Promise

ReadTerm reads from the stream represented by streamOrAlias and unifies with stream.

func (*State) Repeat added in v0.5.0

func (state *State) Repeat(k func(*Env) *Promise, env *Env) *Promise

Repeat repeats the continuation until it succeeds.

func (*State) Retract added in v0.5.0

func (state *State) Retract(t Term, k func(*Env) *Promise, env *Env) *Promise

Retract removes the first clause that matches with t.

func (*State) SetInput added in v0.5.0

func (state *State) SetInput(streamOrAlias Term, k func(*Env) *Promise, env *Env) *Promise

SetInput sets streamOrAlias as the current input stream.

func (*State) SetOf added in v0.5.0

func (state *State) SetOf(template, goal, instances Term, k func(*Env) *Promise, env *Env) *Promise

SetOf collects all the solutions of goal as instances, which unify with template. instances don't contain duplications.

func (*State) SetOutput added in v0.5.0

func (state *State) SetOutput(streamOrAlias Term, k func(*Env) *Promise, env *Env) *Promise

SetOutput sets streamOrAlias as the current output stream.

func (*State) SetPrologFlag added in v0.5.0

func (state *State) SetPrologFlag(flag, value Term, k func(*Env) *Promise, env *Env) *Promise

SetPrologFlag sets flag to value.

func (*State) SetStreamPosition added in v0.5.0

func (state *State) SetStreamPosition(streamOrAlias, position Term, k func(*Env) *Promise, env *Env) *Promise

SetStreamPosition sets the position property of the stream represented by streamOrAlias.

func (*State) SetUserInput added in v0.5.0

func (state *State) SetUserInput(r io.Reader, opts ...StreamOption)

SetUserInput sets the given reader as a stream with an alias of user_input.

func (*State) SetUserOutput added in v0.5.0

func (state *State) SetUserOutput(w io.Writer, opts ...StreamOption)

SetUserOutput sets the given writer as a stream with an alias of user_output.

func (*State) StreamProperty added in v0.5.0

func (state *State) StreamProperty(streamOrAlias, property Term, k func(*Env) *Promise, env *Env) *Promise

StreamProperty succeeds iff the stream represented by streamOrAlias has the stream property.

func (*State) Write added in v0.9.0

func (state *State) Write(w io.Writer, t Term, opts *WriteOptions, env *Env) error

Write outputs term to the writer.

func (*State) WriteTerm added in v0.5.0

func (state *State) WriteTerm(streamOrAlias, t, options Term, k func(*Env) *Promise, env *Env) *Promise

WriteTerm outputs term to stream with options.

type Stream added in v0.4.1

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

Stream is a prolog stream.

func NewStream added in v0.4.1

func NewStream(f io.ReadWriteCloser, mode StreamMode, opts ...StreamOption) *Stream

NewStream creates a new stream from an opened file.

func Open added in v0.4.1

func Open(name Atom, mode StreamMode, opts ...StreamOption) (*Stream, error)

Open opens a file and creates a new stream out of it.

func (*Stream) Close added in v0.4.1

func (s *Stream) Close() error

Close closes the underlying file of the stream.

type StreamMode added in v0.4.1

type StreamMode int

StreamMode describes what operations you can perform on the stream.

func (StreamMode) String added in v0.6.0

func (m StreamMode) String() string

type StreamOption added in v0.4.1

type StreamOption func(*Stream)

StreamOption describes an option on stream creation.

func WithAlias added in v0.4.1

func WithAlias(state *State, alias Atom) StreamOption

WithAlias sets an alias for the stream.

func WithEOFAction added in v0.4.1

func WithEOFAction(eofAction EOFAction) StreamOption

WithEOFAction sets eof_action for the stream.

func WithReposition added in v0.4.1

func WithReposition(b bool) StreamOption

WithReposition sets if the stream is random access.

func WithStreamType added in v0.4.1

func WithStreamType(streamType StreamType) StreamOption

WithStreamType sets type of the stream.

type StreamType added in v0.4.1

type StreamType int

StreamType describes what will be transferred in the stream, either text or binary.

const (
	// StreamTypeText means text.
	StreamTypeText StreamType = iota
	// StreamTypeBinary means binary.
	StreamTypeBinary
)

func (StreamType) String added in v0.6.0

func (t StreamType) String() string

type Term added in v0.4.1

type Term interface {
}

Term is a prolog term.

func CharList added in v0.11.0

func CharList(s string) Term

CharList returns a character list.

func CodeList added in v0.11.0

func CodeList(s string) Term

CodeList returns a character code list.

func Cons added in v0.4.1

func Cons(car, cdr Term) Term

Cons returns a list consists of a first element car and the rest cdr.

func List added in v0.4.1

func List(ts ...Term) Term

List returns a list of ts.

func ListRest added in v0.4.1

func ListRest(rest Term, ts ...Term) Term

ListRest returns a list of ts followed by rest.

func Pair added in v0.9.0

func Pair(k, v Term) Term

Pair returns a pair of k and v.

func Rulify added in v0.4.1

func Rulify(t Term, env *Env) Term

Rulify returns t if t is in a form of P:-Q, t:-true otherwise.

func Seq added in v0.4.1

func Seq(sep Atom, ts ...Term) Term

Seq returns a sequence of ts separated by sep.

func Slice added in v0.3.0

func Slice(list Term, env *Env) ([]Term, error)

Slice returns a Term slice containing the elements of list. It errors if the given Term is not a list.

type TermID added in v0.11.0

type TermID interface{}

TermID is an identifier for a Term.

func ID added in v0.11.0

func ID(t Term) TermID

ID returns a TermID for the Term.

type TermIDer added in v0.11.0

type TermIDer interface {
	TermID() TermID
}

TermIDer lets a Term which is not comparable per se return its TermID for comparison.

type Token added in v0.4.1

type Token struct {
	Kind TokenKind
	Val  string
}

Token is a smallest meaningful unit of prolog program.

type TokenKind added in v0.4.1

type TokenKind byte

TokenKind is a type of Token.

const (
	// TokenInvalid represents an invalid token.
	TokenInvalid TokenKind = iota

	// TokenInsufficient represents an insufficient token.
	TokenInsufficient

	// TokenEOF represents an end of token stream.
	TokenEOF

	// TokenLetterDigit represents a letter digit token.
	TokenLetterDigit

	// TokenGraphic represents a graphical token.
	TokenGraphic

	// TokenQuoted represents a quoted token.
	TokenQuoted

	// TokenSemicolon represents a semicolon token.
	TokenSemicolon

	// TokenCut represents a cut token.
	TokenCut

	// TokenVariable represents a variable token.
	TokenVariable

	// TokenInteger represents an integer token.
	TokenInteger

	// TokenFloatNumber represents a floating-point token.
	TokenFloatNumber

	// TokenDoubleQuotedList represents a double-quoted string.
	TokenDoubleQuotedList

	// TokenOpen represents an open parenthesis.
	TokenOpen

	// TokenOpenCT represents an open CT parenthesis.
	TokenOpenCT

	// TokenClose represents a close parenthesis.
	TokenClose

	// TokenOpenList represents an open bracket.
	TokenOpenList

	// TokenCloseList represents a close bracket.
	TokenCloseList

	// TokenOpenCurly represents an open brace.
	TokenOpenCurly

	// TokenCloseCurly represents a close brace.
	TokenCloseCurly

	// TokenBar represents a bar.
	TokenBar

	// TokenComma represents a comma.
	TokenComma

	// TokenEnd represents a period.
	TokenEnd
)

func (TokenKind) GoString added in v0.10.0

func (k TokenKind) GoString() string

GoString returns a string representation of TokenKind.

func (TokenKind) String added in v0.4.1

func (k TokenKind) String() string

type VM

type VM struct {

	// OnCall is a callback that is triggered when the VM reaches to the predicate.
	OnCall func(pi ProcedureIndicator, args []Term, env *Env)

	// OnExit is a callback that is triggered when the predicate succeeds and the VM continues.
	OnExit func(pi ProcedureIndicator, args []Term, env *Env)

	// OnFail is a callback that is triggered when the predicate fails and the VM backtracks.
	OnFail func(pi ProcedureIndicator, args []Term, env *Env)

	// OnRedo is a callback that is triggered when the VM retries the predicate as a result of backtrack.
	OnRedo func(pi ProcedureIndicator, args []Term, env *Env)

	// OnUnknown is a callback that is triggered when the VM reaches to an unknown predicate and also current_prolog_flag(unknown, warning).
	OnUnknown func(pi ProcedureIndicator, args []Term, env *Env)
	// 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) Arrive added in v0.5.0

func (vm *VM) Arrive(pi ProcedureIndicator, args []Term, k func(*Env) *Promise, env *Env) *Promise

Arrive is the entry point of the VM.

func (*VM) Register0

func (vm *VM) Register0(name string, p func(func(*Env) *Promise, *Env) *Promise)

Register0 registers a predicate of arity 0.

func (*VM) Register1

func (vm *VM) Register1(name string, p func(Term, func(*Env) *Promise, *Env) *Promise)

Register1 registers a predicate of arity 1.

func (*VM) Register2

func (vm *VM) Register2(name string, p func(Term, Term, func(*Env) *Promise, *Env) *Promise)

Register2 registers a predicate of arity 2.

func (*VM) Register3

func (vm *VM) Register3(name string, p func(Term, Term, Term, func(*Env) *Promise, *Env) *Promise)

Register3 registers a predicate of arity 3.

func (*VM) Register4

func (vm *VM) Register4(name string, p func(Term, Term, Term, Term, func(*Env) *Promise, *Env) *Promise)

Register4 registers a predicate of arity 4.

func (*VM) Register5

func (vm *VM) Register5(name string, p func(Term, Term, Term, Term, Term, func(*Env) *Promise, *Env) *Promise)

Register5 registers a predicate of arity 5.

func (*VM) Register6 added in v0.9.0

func (vm *VM) Register6(name string, p func(Term, Term, Term, Term, Term, Term, func(*Env) *Promise, *Env) *Promise)

Register6 registers a predicate of arity 6.

func (*VM) Register7 added in v0.9.0

func (vm *VM) Register7(name string, p func(Term, Term, Term, Term, Term, Term, Term, func(*Env) *Promise, *Env) *Promise)

Register7 registers a predicate of arity 7.

func (*VM) Register8 added in v0.9.0

func (vm *VM) Register8(name string, p func(Term, Term, Term, Term, Term, Term, Term, Term, func(*Env) *Promise, *Env) *Promise)

Register8 registers a predicate of arity 8.

type ValidDomain added in v0.10.0

type ValidDomain uint8

ValidDomain is the domain which the procedure defines.

const (
	ValidDomainCharacterCodeList ValidDomain = iota
	ValidDomainCloseOption
	ValidDomainFlagValue
	ValidDomainIOMode
	ValidDomainNonEmptyList
	ValidDomainNotLessThanZero
	ValidDomainOperatorPriority
	ValidDomainOperatorSpecifier
	ValidDomainPrologFlag
	ValidDomainReadOption
	ValidDomainSourceSink
	ValidDomainStream
	ValidDomainStreamOption
	ValidDomainStreamOrAlias
	ValidDomainStreamPosition
	ValidDomainStreamProperty
	ValidDomainWriteOption

	ValidDomainOrder
)

ValidDomain is one of these values.

func (ValidDomain) Term added in v0.10.0

func (vd ValidDomain) Term() Term

Term returns an Atom for the ValidDomain.

type ValidType added in v0.10.0

type ValidType uint8

ValidType is the correct type for an argument or one of its components.

const (
	ValidTypeAtom ValidType = iota
	ValidTypeAtomic
	ValidTypeByte
	ValidTypeCallable
	ValidTypeCharacter
	ValidTypeCompound
	ValidTypeEvaluable
	ValidTypeInByte
	ValidTypeInCharacter
	ValidTypeInteger
	ValidTypeList
	ValidTypeNumber
	ValidTypePredicateIndicator
	ValidTypePair
	ValidTypeFloat
)

ValidType is one of these values.

func (ValidType) Term added in v0.10.0

func (t ValidType) Term() Term

Term returns an Atom for the ValidType.

type Variable added in v0.4.1

type Variable string

Variable is a prolog variable.

func NewVariable added in v0.4.1

func NewVariable() Variable

NewVariable creates a new generated variable.

func (Variable) Generated added in v0.4.1

func (v Variable) Generated() bool

Generated checks if the variable is generated.

func (Variable) GoString added in v0.11.0

func (v Variable) GoString() string

type WriteOptions added in v0.10.0

type WriteOptions struct {
	IgnoreOps     bool
	Quoted        bool
	VariableNames map[Variable]Atom
	NumberVars    bool
	// contains filtered or unexported fields
}

WriteOptions specify how the Term writes itself.

Jump to

Keyboard shortcuts

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