Documentation ¶
Index ¶
- type AtomNode
- func (node *AtomNode) NextPos() lexer.TokenPos
- func (node *AtomNode) Pos() lexer.TokenPos
- func (nb *AtomNode) SetType(NodeType)
- func (nb *AtomNode) SetValue(v constant.Value)
- func (node *AtomNode) State() NodeState
- func (node *AtomNode) String() string
- func (node *AtomNode) Type() NodeType
- func (nb *AtomNode) Value() constant.Value
- type BodyRelation
- type Entity
- type Esc
- type GoalNode
- func (node *GoalNode) NextPos() lexer.TokenPos
- func (node *GoalNode) Pos() lexer.TokenPos
- func (nb *GoalNode) SetType(NodeType)
- func (nb *GoalNode) SetValue(v constant.Value)
- func (node *GoalNode) State() NodeState
- func (node *GoalNode) String() string
- func (node *GoalNode) Type() NodeType
- func (nb *GoalNode) Value() constant.Value
- type GroundFormulaNode
- func (node *GroundFormulaNode) AddGroundTerm(term GroundTerm)
- func (node *GroundFormulaNode) Arity() uint
- func (node *GroundFormulaNode) Name() string
- func (node *GroundFormulaNode) NextPos() lexer.TokenPos
- func (node *GroundFormulaNode) Pos() lexer.TokenPos
- func (nb *GroundFormulaNode) SetType(NodeType)
- func (nb *GroundFormulaNode) SetValue(v constant.Value)
- func (node *GroundFormulaNode) State() NodeState
- func (node *GroundFormulaNode) Type() NodeType
- func (nb *GroundFormulaNode) Value() constant.Value
- type GroundRelation
- type GroundTerm
- type HeadRelation
- type InitRuleNode
- func (node *InitRuleNode) NextPos() lexer.TokenPos
- func (node *InitRuleNode) Pos() lexer.TokenPos
- func (nb *InitRuleNode) SetType(NodeType)
- func (nb *InitRuleNode) SetValue(v constant.Value)
- func (node *InitRuleNode) State() NodeState
- func (node *InitRuleNode) String() string
- func (node *InitRuleNode) Type() NodeType
- func (nb *InitRuleNode) Value() constant.Value
- type IntegerNode
- func (node *IntegerNode) NextPos() lexer.TokenPos
- func (node *IntegerNode) Pos() lexer.TokenPos
- func (nb *IntegerNode) SetType(NodeType)
- func (nb *IntegerNode) SetValue(v constant.Value)
- func (node *IntegerNode) State() NodeState
- func (node *IntegerNode) String() string
- func (node *IntegerNode) Type() NodeType
- func (nb *IntegerNode) Value() constant.Value
- type Node
- type NodeFlag
- type NodeIndex
- type NodePool
- type NodeState
- type NodeType
- type Relation
- type RoleDefinitionNode
- func (node *RoleDefinitionNode) NextPos() lexer.TokenPos
- func (node *RoleDefinitionNode) Pos() lexer.TokenPos
- func (nb *RoleDefinitionNode) SetType(NodeType)
- func (nb *RoleDefinitionNode) SetValue(v constant.Value)
- func (node *RoleDefinitionNode) State() NodeState
- func (node *RoleDefinitionNode) String() string
- func (node *RoleDefinitionNode) Type() NodeType
- func (nb *RoleDefinitionNode) Value() constant.Value
- type RoleReferenceNode
- func (node *RoleReferenceNode) Arity() uint
- func (node *RoleReferenceNode) Name() string
- func (node *RoleReferenceNode) NextPos() lexer.TokenPos
- func (node *RoleReferenceNode) Pos() lexer.TokenPos
- func (nb *RoleReferenceNode) SetType(NodeType)
- func (nb *RoleReferenceNode) SetValue(v constant.Value)
- func (node *RoleReferenceNode) State() NodeState
- func (node *RoleReferenceNode) String() string
- func (node *RoleReferenceNode) Type() NodeType
- func (nb *RoleReferenceNode) Value() constant.Value
- type Sentence
- type TerminalNode
- func (node *TerminalNode) NextPos() lexer.TokenPos
- func (node *TerminalNode) Pos() lexer.TokenPos
- func (nb *TerminalNode) SetType(NodeType)
- func (nb *TerminalNode) SetValue(v constant.Value)
- func (node *TerminalNode) State() NodeState
- func (node *TerminalNode) String() string
- func (node *TerminalNode) Type() NodeType
- func (nb *TerminalNode) Value() constant.Value
- type VarNode
- func (v *VarNode) NextPos() lexer.TokenPos
- func (node *VarNode) Pos() lexer.TokenPos
- func (nb *VarNode) SetType(NodeType)
- func (nb *VarNode) SetValue(v constant.Value)
- func (node *VarNode) State() NodeState
- func (v *VarNode) String() string
- func (node *VarNode) Type() NodeType
- func (nb *VarNode) Value() constant.Value
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AtomNode ¶
type AtomNode struct {
// contains filtered or unexported fields
}
func (*AtomNode) Pos ¶
The Node's position can be inferred from its TokenPos value. Its NextPos() is specific to the actual backing struct, it may depend on child nodes.
func (*AtomNode) SetType ¶
func (nb *AtomNode) SetType(NodeType)
Provide default implementations in the base type that panic or return nil.
type BodyRelation ¶
type BodyRelation interface { Relation // contains filtered or unexported methods }
Common type for relations that may appear in a body clause of `<=` inference.
type Entity ¶
type Entity interface { Node // contains filtered or unexported methods }
Common type for entities, objects presumed or hypothesized to exist in the game.
func RoleReference ¶
Construct a new node for a (role ...) relation. Can only appear in body relations, not as a head relation. When it appears as a base sentence it is the definition of that role (see above). Args:
pos marks the beginning of the relation's open paren name is the identifier of the role being referenced
type Esc ¶
type Esc uint16
Saved for future use; static analysis can use this segment for escape note.
type GoalNode ¶
type GoalNode struct {
// contains filtered or unexported fields
}
func Goal ¶
func Goal(pos lexer.TokenPos, role RoleReferenceNode, body []BodyRelation) *GoalNode
Terminal rules are of the form (<= terminal (...) ...) where the `terminal` keyword is the entire head relation, so we only really need to represent the body relations that the inference is drawn from.
func (*GoalNode) Pos ¶
The Node's position can be inferred from its TokenPos value. Its NextPos() is specific to the actual backing struct, it may depend on child nodes.
func (*GoalNode) SetType ¶
func (nb *GoalNode) SetType(NodeType)
Provide default implementations in the base type that panic or return nil.
type GroundFormulaNode ¶
type GroundFormulaNode struct {
// contains filtered or unexported fields
}
func (*GroundFormulaNode) AddGroundTerm ¶
func (node *GroundFormulaNode) AddGroundTerm(term GroundTerm)
func (*GroundFormulaNode) Arity ¶
func (node *GroundFormulaNode) Arity() uint
func (*GroundFormulaNode) Name ¶
func (node *GroundFormulaNode) Name() string
func (*GroundFormulaNode) NextPos ¶
func (node *GroundFormulaNode) NextPos() lexer.TokenPos
func (*GroundFormulaNode) Pos ¶
The Node's position can be inferred from its TokenPos value. Its NextPos() is specific to the actual backing struct, it may depend on child nodes.
func (*GroundFormulaNode) SetType ¶
func (nb *GroundFormulaNode) SetType(NodeType)
Provide default implementations in the base type that panic or return nil.
func (*GroundFormulaNode) Type ¶
func (node *GroundFormulaNode) Type() NodeType
The NodeType for a node determines how tree-walks of surrounding nodes will be conducted. It also provides a more refined typing than the golang type, especially for some nodes that undergo refinement during compilation passes.
type GroundRelation ¶
type GroundRelation interface { Relation GroundTerm }
Unifying type for Relations and Ground terms, i.e. entirely ground formulas.
type GroundTerm ¶
type GroundTerm interface { Node // contains filtered or unexported methods }
A ground term is an atom or relation that contains no variable terms. some relations are inherently grounded (non-variable atoms, literals) and can be immediately determined by type, this is the interface type for satisfying thet requirement. Note that a relation may be ground without itself being a direct member of this type, e.g. relation objects. See IsGround(Node) for a runtime test of a node's groundedness.
type HeadRelation ¶
type HeadRelation interface { Relation // contains filtered or unexported methods }
Common type for relations that may appear in the head clause of `<=` infer.
type InitRuleNode ¶
type InitRuleNode struct {
// contains filtered or unexported fields
}
Init definitions resemble a function that operates on a single relation term, with the expectation that the relation is Ground.
func (*InitRuleNode) NextPos ¶
func (node *InitRuleNode) NextPos() lexer.TokenPos
func (*InitRuleNode) Pos ¶
The Node's position can be inferred from its TokenPos value. Its NextPos() is specific to the actual backing struct, it may depend on child nodes.
func (*InitRuleNode) SetType ¶
func (nb *InitRuleNode) SetType(NodeType)
Provide default implementations in the base type that panic or return nil.
func (*InitRuleNode) String ¶
func (node *InitRuleNode) String() string
type IntegerNode ¶
type IntegerNode struct {
// contains filtered or unexported fields
}
func (*IntegerNode) NextPos ¶
func (node *IntegerNode) NextPos() lexer.TokenPos
func (*IntegerNode) Pos ¶
The Node's position can be inferred from its TokenPos value. Its NextPos() is specific to the actual backing struct, it may depend on child nodes.
func (*IntegerNode) SetType ¶
func (nb *IntegerNode) SetType(NodeType)
Provide default implementations in the base type that panic or return nil.
func (*IntegerNode) String ¶
func (node *IntegerNode) String() string
type Node ¶
Common interface for all Node types indicates their position and extent. Some additional Node subtypes (below) provide the semantic attribute of entire classes of Node types, selectively implemented by the backing structs that define the individual Node implementing types.
type NodeFlag ¶
type NodeFlag uint8
Small set of booleans that can be individually toggled or read.
type NodeIndex ¶
type NodeIndex uint32
A special integer type that refers to its index in a NodePool collection.
type NodePool ¶
Exported methods for the NodePool, responsible for the allocation and recycling of backing data for Node instances.
type NodeState ¶
type NodeState uint32
Shorthand for tiny literals or state-machine bits for individual passes.
type NodeType ¶
type NodeType uint8
A brief representation of the node's type for quick type-checking of AST Node instances. GDL types are few and, for the most part, distinct. The domains defined by games in GDL are a separate concern. For example, piece types and board position types could be considered classes and introduced into a type system, but in GDL that representation is a composite of atoms and the shape of relations concerning them, so that problem is contained in the unification of terms. Thus, we can narrow the scope of NodeType to the most primitive of lexical concerns of GDL, with room to grow for Plugg's representation of API entities, UI controls and visual elements.
const ( NT_INVALID NodeType = iota // Identifier naming and constant atoms NT_ATOM NT_INTEGER NT_GROUNDREL NT_VAR NT_RELATION // Boolean operator relations NT_TRUE NT_OR NT_AND NT_NOT NT_DISTINCT // Inference rule relations NT_INFER NT_NEXT NT_LEGAL NT_INPUT NT_DOES // Types that are derived from GDL builtins NT_DEFROLE NT_ROLEREF NT_INIT NT_TERMINAL NT_GOAL )
DO NOT DEPEND ON THE STABILITY OF THESE VALUES.
Enumeration of node types to an integer representation.
type Relation ¶
type Relation interface { Node Name() string Arity() uint // contains filtered or unexported methods }
Common type for relations, objects that give properties to entites or indicating a relationship between entities.
type RoleDefinitionNode ¶
type RoleDefinitionNode struct { Name string // contains filtered or unexported fields }
Role definitions are of the form `(role <IDENT>)`, strictly defining the set of player representations.
func (*RoleDefinitionNode) NextPos ¶
func (node *RoleDefinitionNode) NextPos() lexer.TokenPos
func (*RoleDefinitionNode) Pos ¶
The Node's position can be inferred from its TokenPos value. Its NextPos() is specific to the actual backing struct, it may depend on child nodes.
func (*RoleDefinitionNode) SetType ¶
func (nb *RoleDefinitionNode) SetType(NodeType)
Provide default implementations in the base type that panic or return nil.
func (*RoleDefinitionNode) String ¶
func (node *RoleDefinitionNode) String() string
func (*RoleDefinitionNode) Type ¶
func (node *RoleDefinitionNode) Type() NodeType
The NodeType for a node determines how tree-walks of surrounding nodes will be conducted. It also provides a more refined typing than the golang type, especially for some nodes that undergo refinement during compilation passes.
type RoleReferenceNode ¶
type RoleReferenceNode struct {
// contains filtered or unexported fields
}
Some expressions, such as `legal` and `does`, have parameters that implicitly refer to a role and not any other type of term. We can type-check them more effectively with a Node type that specifies that constraint.
func (*RoleReferenceNode) Arity ¶
func (node *RoleReferenceNode) Arity() uint
func (*RoleReferenceNode) Name ¶
func (node *RoleReferenceNode) Name() string
func (*RoleReferenceNode) NextPos ¶
func (node *RoleReferenceNode) NextPos() lexer.TokenPos
func (*RoleReferenceNode) Pos ¶
The Node's position can be inferred from its TokenPos value. Its NextPos() is specific to the actual backing struct, it may depend on child nodes.
func (*RoleReferenceNode) SetType ¶
func (nb *RoleReferenceNode) SetType(NodeType)
Provide default implementations in the base type that panic or return nil.
func (*RoleReferenceNode) String ¶
func (node *RoleReferenceNode) String() string
func (*RoleReferenceNode) Type ¶
func (node *RoleReferenceNode) Type() NodeType
The NodeType for a node determines how tree-walks of surrounding nodes will be conducted. It also provides a more refined typing than the golang type, especially for some nodes that undergo refinement during compilation passes.
type Sentence ¶
type Sentence interface { Node // contains filtered or unexported methods }
Common type for Sentence-level productions.
func RoleDefinition ¶
Construct a new node for a (role ...) sentence, defining the players. Args:
`pos` marks the beginning of the sentence `name` is the indentifier of the role within the game definition
type TerminalNode ¶
type TerminalNode struct {
// contains filtered or unexported fields
}
func (*TerminalNode) NextPos ¶
func (node *TerminalNode) NextPos() lexer.TokenPos
func (*TerminalNode) Pos ¶
The Node's position can be inferred from its TokenPos value. Its NextPos() is specific to the actual backing struct, it may depend on child nodes.
func (*TerminalNode) SetType ¶
func (nb *TerminalNode) SetType(NodeType)
Provide default implementations in the base type that panic or return nil.
func (*TerminalNode) String ¶
func (node *TerminalNode) String() string
type VarNode ¶
type VarNode struct {
// contains filtered or unexported fields
}
func (*VarNode) Pos ¶
The Node's position can be inferred from its TokenPos value. Its NextPos() is specific to the actual backing struct, it may depend on child nodes.
func (*VarNode) SetType ¶
func (nb *VarNode) SetType(NodeType)
Provide default implementations in the base type that panic or return nil.