Documentation
¶
Index ¶
- Variables
- func Compare(a, b Interface, env *Env) int64
- func Contains(t, s Interface, env *Env) bool
- func Write(w io.Writer, t Interface, opts WriteTermOptions, env *Env) error
- type Atom
- type Compound
- type DoubleQuotes
- type Env
- type EofAction
- type Float
- type Integer
- type Interface
- type Operator
- type OperatorSpecifier
- type Operators
- type ParsedVariable
- type Parser
- type ParserOption
- type Stream
- type StreamMode
- type StreamType
- type UnexpectedTokenError
- type Variable
- type Variables
- type WriteTermOptions
Constants ¶
This section is empty.
Variables ¶
var ErrNotANumber = errors.New("not a number")
Functions ¶
Types ¶
type Atom ¶
type Atom string
Atom is a prolog atom.
func (Atom) Apply ¶ added in v0.3.0
Apply returns a Compound which Functor is the Atom and Args are the arguments. If the arguments are empty, then returns itself.
type Compound ¶
Compound is a prolog compound.
type DoubleQuotes ¶ added in v0.3.0
type DoubleQuotes int
const ( DoubleQuotesCodes DoubleQuotes = iota DoubleQuotesChars DoubleQuotesAtom )
func (DoubleQuotes) String ¶ added in v0.3.0
func (d DoubleQuotes) String() string
type Env ¶
type Env struct {
// contains filtered or unexported fields
}
Env is a mapping from variables to terms.
func (*Env) FreeVariables ¶
FreeVariables extracts variables in the given terms.
type Float ¶
type Float float64
Float is a prolog floating-point number.
type Integer ¶
type Integer int64
Integer is a prolog integer.
type Interface ¶
type Interface interface { fmt.Stringer Unify(Interface, bool, *Env) (*Env, bool) Unparse(func(syntax.Token), WriteTermOptions, *Env) }
Interface is a prolog term.
type Operator ¶
type Operator struct { Priority Integer // 1 ~ 1200 Specifier OperatorSpecifier Name Atom }
Operator is an operator definition.
type OperatorSpecifier ¶ added in v0.3.1
type OperatorSpecifier uint8
const ( OperatorSpecifierNone OperatorSpecifier = iota OperatorSpecifierFX OperatorSpecifierFY OperatorSpecifierXF OperatorSpecifierYF OperatorSpecifierXFX OperatorSpecifierXFY OperatorSpecifierYFX )
func (OperatorSpecifier) Term ¶ added in v0.3.1
func (s OperatorSpecifier) Term() Interface
type Operators ¶
type Operators []Operator
Operators are a list of operators sorted in a descending order of precedence.
type ParsedVariable ¶ added in v0.3.0
ParsedVariable is a set of information regarding a variable in a parsed term.
type Parser ¶
type Parser struct {
// contains filtered or unexported fields
}
Parser turns bytes into Interface.
type ParserOption ¶ added in v0.3.0
type ParserOption func(p *Parser)
ParserOption is option for NewParser.
func WithDoubleQuotes ¶ added in v0.3.0
func WithDoubleQuotes(quotes DoubleQuotes) ParserOption
WithDoubleQuotes sets how Parser handles double quotes.
func WithOperators ¶ added in v0.3.0
func WithOperators(operators *Operators) ParserOption
WithOperators sets operators for Parser.
func WithParsedVars ¶ added in v0.3.0
func WithParsedVars(vars *[]ParsedVariable) ParserOption
WithParsedVars sets where Parser to store information regarding parsed variables.
type Stream ¶
type Stream struct { Source io.Reader Sink io.Writer Closer io.Closer Mode StreamMode Alias Atom EofAction EofAction Reposition bool StreamType StreamType }
Stream is a prolog stream.
type StreamMode ¶
type StreamMode int
const ( StreamModeRead StreamMode = iota StreamModeWrite StreamModeAppend )
type UnexpectedTokenError ¶ added in v0.3.0
type UnexpectedTokenError struct { ExpectedKind syntax.TokenKind ExpectedVals []string Actual syntax.Token History []syntax.Token }
func (UnexpectedTokenError) Error ¶ added in v0.3.0
func (e UnexpectedTokenError) Error() string
type Variable ¶
type Variable string
Variable is a prolog variable.
func NewVariable ¶
func NewVariable() Variable