Documentation ¶
Overview ¶
The semantic package provides a graph structure that represents the meaning of a Flux script. An AST is converted into a semantic graph for use with other systems. Using a semantic graph representation of the Flux, enables highlevel meaning to be specified programatically.
The semantic structures are to be designed to facilitate the interpretation and compilation of Flux.
For example since Flux uses the javascript AST structures, arguments to a function are represented as a single positional argument that is always an object expression. The semantic graph validates that the AST correctly follows these semantics, and use structures that are strongly typed for this expectation.
Index ¶
- Constants
- Variables
- func Formatted(n Node, opts ...FormatOption) fmt.Formatter
- func GetPropertyAny(p *fbsemantic.Prop) (interface{}, error)
- func GetPropertyName(p *fbsemantic.Prop) (string, error)
- func ToAST(n Node) ast.Node
- func Walk(v Visitor, node Node)
- type Argument
- type ArgumentType
- type ArrayExpression
- type Assignment
- type BinaryExpression
- type Block
- type BooleanLiteral
- type BuiltinStatement
- type CallExpression
- type CollectionFB
- type ConditionalExpression
- type DateTimeLiteral
- type DictExpression
- type DurationLiteral
- type Expression
- type ExpressionStatement
- type File
- type FloatLiteral
- type FormatOption
- type FunctionExpression
- type FunctionParameter
- type FunctionParameters
- type Identifier
- type IdentifierExpression
- type ImportDeclaration
- type IndexExpression
- type Instantiator
- type IntegerLiteral
- type InterpolatedPart
- type Kind
- type Literal
- type Loc
- type LogicalExpression
- type MemberAssignment
- type MemberExpression
- type MonoType
- func ExtendObjectType(properties []PropertyType, extends *uint64) MonoType
- func NewAppType(collection fbsemantic.CollectionType, elemType MonoType) MonoType
- func NewArrayType(elemType MonoType) MonoType
- func NewDictType(keyType, valueType MonoType) MonoType
- func NewDynamicType() MonoType
- func NewFunctionType(retn MonoType, args []ArgumentType) MonoType
- func NewMonoType(tbl flatbuffers.Table, t fbsemantic.MonoType) (MonoType, error)
- func NewObjectType(properties []PropertyType) MonoType
- func NewStreamType(elemType MonoType) MonoType
- func NewVarType(i uint64) (MonoType, error)
- func NewVectorType(elemType MonoType) MonoType
- func (mt MonoType) Argument(i int) (*Argument, error)
- func (mt MonoType) Basic() (fbsemantic.Type, error)
- func (mt MonoType) CanonicalString() string
- func (mt MonoType) CollectionType() (fbsemantic.CollectionType, error)
- func (mt MonoType) ElemType() (MonoType, error)
- func (l MonoType) Equal(r MonoType) bool
- func (mt MonoType) Extends() (MonoType, bool, error)
- func (mt MonoType) KeyType() (MonoType, error)
- func (mt MonoType) Kind() Kind
- func (mt MonoType) Nature() Nature
- func (mt MonoType) NumArguments() (int, error)
- func (mt MonoType) NumProperties() (int, error)
- func (mt MonoType) PipeArgument() (*Argument, error)
- func (mt MonoType) RecordProperty(i int) (*RecordProperty, error)
- func (mt MonoType) ReturnType() (MonoType, error)
- func (mt MonoType) SortedArguments() ([]*Argument, error)
- func (mt MonoType) SortedProperties() ([]*RecordProperty, error)
- func (mt MonoType) String() string
- func (mt MonoType) ValueType() (MonoType, error)
- func (mt MonoType) VarNum() (uint64, error)
- type NativeVariableAssignment
- type Nature
- type NestingVisitor
- type Node
- type ObjectExpression
- type OptionStatement
- type Package
- type PackageClause
- type PolyType
- func (pt PolyType) CanonicalString() string
- func (pt PolyType) Constraint(i int) (*fbsemantic.Constraint, error)
- func (pt PolyType) Expr() (MonoType, error)
- func (pt PolyType) Instantiator(subst Substitutor) (Substitutor, error)
- func (pt PolyType) IsNil() bool
- func (pt PolyType) NumConstraints() int
- func (pt PolyType) NumVars() int
- func (pt *PolyType) SortedConstraints() ([]*fbsemantic.Constraint, error)
- func (pt PolyType) SortedVars() ([]*fbsemantic.Var, error)
- func (pt PolyType) String() string
- func (pt PolyType) Var(i int) (*fbsemantic.Var, error)
- type Property
- type PropertyKey
- type PropertyType
- type RecordProperty
- type RegexpLiteral
- type ReturnStatement
- type ScopedVisitor
- type Statement
- type StreamFB
- type StringExpression
- type StringExpressionPart
- type StringLiteral
- type Substitution
- type Substitutor
- type Symbol
- type TestStatement
- type TextPart
- type UnaryExpression
- type UnsignedIntegerLiteral
- type VarPropertyType
- type Visitor
Constants ¶
const ( Unknown = Kind(fbsemantic.MonoTypeNONE) Basic = Kind(fbsemantic.MonoTypeBasic) Var = Kind(fbsemantic.MonoTypeVar) Collection = Kind(fbsemantic.MonoTypeCollection) Record = Kind(fbsemantic.MonoTypeRecord) Fun = Kind(fbsemantic.MonoTypeFun) Dict = Kind(fbsemantic.MonoTypeDict) Dyn = Kind(fbsemantic.MonoTypeDynamic) )
Variables ¶
var ( BasicBool = newBasicType(fbsemantic.TypeBool) BasicInt = newBasicType(fbsemantic.TypeInt) BasicUint = newBasicType(fbsemantic.TypeUint) BasicFloat = newBasicType(fbsemantic.TypeFloat) BasicString = newBasicType(fbsemantic.TypeString) BasicDuration = newBasicType(fbsemantic.TypeDuration) BasicTime = newBasicType(fbsemantic.TypeTime) BasicRegexp = newBasicType(fbsemantic.TypeRegexp) BasicBytes = newBasicType(fbsemantic.TypeBytes) )
Functions ¶
func Formatted ¶
func Formatted(n Node, opts ...FormatOption) fmt.Formatter
Formatted produces a Formatter object suitable for printing using the standard fmt package. Currently only works for some expressions.
func GetPropertyAny ¶
func GetPropertyAny(p *fbsemantic.Prop) (interface{}, error)
func GetPropertyName ¶
func GetPropertyName(p *fbsemantic.Prop) (string, error)
Types ¶
type Argument ¶
type Argument struct {
*fbsemantic.Argument
}
Argument represents a function argument.
type ArrayExpression ¶
type ArrayExpression struct { Loc Elements []Expression Type MonoType }
func (*ArrayExpression) Copy ¶
func (e *ArrayExpression) Copy() Node
func (*ArrayExpression) FromBuf ¶
func (rcv *ArrayExpression) FromBuf(fb *fbsemantic.ArrayExpression) error
func (*ArrayExpression) NodeType ¶
func (*ArrayExpression) NodeType() string
func (*ArrayExpression) TypeOf ¶
func (e *ArrayExpression) TypeOf() MonoType
type Assignment ¶
type Assignment interface { Statement // contains filtered or unexported methods }
type BinaryExpression ¶
type BinaryExpression struct { Loc Operator ast.OperatorKind Left Expression Right Expression // contains filtered or unexported fields }
func (*BinaryExpression) Copy ¶
func (e *BinaryExpression) Copy() Node
func (*BinaryExpression) FromBuf ¶
func (rcv *BinaryExpression) FromBuf(fb *fbsemantic.BinaryExpression) error
func (*BinaryExpression) NodeType ¶
func (*BinaryExpression) NodeType() string
func (*BinaryExpression) TypeOf ¶
func (e *BinaryExpression) TypeOf() MonoType
type Block ¶
func (*Block) ReturnStatement ¶
func (s *Block) ReturnStatement() *ReturnStatement
type BooleanLiteral ¶
func (*BooleanLiteral) Copy ¶
func (l *BooleanLiteral) Copy() Node
func (*BooleanLiteral) FromBuf ¶
func (rcv *BooleanLiteral) FromBuf(fb *fbsemantic.BooleanLiteral) error
func (*BooleanLiteral) NodeType ¶
func (*BooleanLiteral) NodeType() string
func (*BooleanLiteral) TypeOf ¶
func (e *BooleanLiteral) TypeOf() MonoType
type BuiltinStatement ¶
type BuiltinStatement struct { Loc ID *Identifier }
func (*BuiltinStatement) Copy ¶
func (s *BuiltinStatement) Copy() Node
func (*BuiltinStatement) FromBuf ¶
func (rcv *BuiltinStatement) FromBuf(fb *fbsemantic.BuiltinStatement) error
func (*BuiltinStatement) NodeType ¶
func (s *BuiltinStatement) NodeType() string
type CallExpression ¶
type CallExpression struct { Loc Callee Expression Arguments *ObjectExpression Pipe Expression // contains filtered or unexported fields }
func (*CallExpression) Copy ¶
func (e *CallExpression) Copy() Node
func (*CallExpression) FromBuf ¶
func (rcv *CallExpression) FromBuf(fb *fbsemantic.CallExpression) error
func (*CallExpression) NodeType ¶
func (*CallExpression) NodeType() string
func (*CallExpression) TypeOf ¶
func (e *CallExpression) TypeOf() MonoType
type CollectionFB ¶
type CollectionFB struct {
// contains filtered or unexported fields
}
func (*CollectionFB) CollectionType ¶
func (a *CollectionFB) CollectionType() fbsemantic.CollectionType
func (*CollectionFB) ElementType ¶
func (a *CollectionFB) ElementType() (MonoType, error)
type ConditionalExpression ¶
type ConditionalExpression struct { Loc Test Expression Alternate Expression Consequent Expression }
func (*ConditionalExpression) Copy ¶
func (e *ConditionalExpression) Copy() Node
func (*ConditionalExpression) FromBuf ¶
func (rcv *ConditionalExpression) FromBuf(fb *fbsemantic.ConditionalExpression) error
func (*ConditionalExpression) NodeType ¶
func (*ConditionalExpression) NodeType() string
func (*ConditionalExpression) TypeOf ¶
func (e *ConditionalExpression) TypeOf() MonoType
type DateTimeLiteral ¶
func (*DateTimeLiteral) Copy ¶
func (l *DateTimeLiteral) Copy() Node
func (*DateTimeLiteral) FromBuf ¶
func (rcv *DateTimeLiteral) FromBuf(fb *fbsemantic.DateTimeLiteral) error
func (*DateTimeLiteral) NodeType ¶
func (*DateTimeLiteral) NodeType() string
func (*DateTimeLiteral) TypeOf ¶
func (e *DateTimeLiteral) TypeOf() MonoType
type DictExpression ¶
type DictExpression struct { Loc Elements []struct { Key Expression Val Expression } Type MonoType }
func (*DictExpression) Copy ¶
func (e *DictExpression) Copy() Node
func (*DictExpression) FromBuf ¶
func (rcv *DictExpression) FromBuf(fb *fbsemantic.DictExpression) error
func (*DictExpression) NodeType ¶
func (*DictExpression) NodeType() string
func (*DictExpression) TypeOf ¶
func (e *DictExpression) TypeOf() MonoType
type DurationLiteral ¶
func (*DurationLiteral) Copy ¶
func (l *DurationLiteral) Copy() Node
func (*DurationLiteral) FromBuf ¶
func (rcv *DurationLiteral) FromBuf(fb *fbsemantic.DurationLiteral) error
func (*DurationLiteral) NodeType ¶
func (*DurationLiteral) NodeType() string
func (*DurationLiteral) TypeOf ¶
func (e *DurationLiteral) TypeOf() MonoType
type Expression ¶
func ConjunctionsToExprSlice ¶
func ConjunctionsToExprSlice(expr Expression) []Expression
ConjunctionsToExprSlice finds all children of AndOperators that are not themselves AndOperators, and returns them in a slice. If the root node of expr is not an AndOperator, just returns expr.
AND / \ AND r => {p, q, r} / \ p q
func ExprsToConjunction ¶
func ExprsToConjunction(exprs ...Expression) Expression
ExprsToConjunction accepts a variable number of expressions and ANDs them together into a single expression.
AND / \ {p, q, r} => AND r / \ p q
func PartitionPredicates ¶
func PartitionPredicates(expr Expression, partitionFn func(expression Expression) (bool, error)) (passExpr, failExpr Expression, err error)
PartitionPredicates accepts a predicate expression, separates it into components that have been logically ANDed together, and applies partitionFn to them. Returns two expressions: one AND tree of the expressions for which partitionFn returned true, and an AND tree of expressions for which partitionFn returned false.
Suppose partitonFn returns true for p and r, and false for q:
AND passExpr failExpr / \ AND r => AND q / \ / \ p q p r
type ExpressionStatement ¶
type ExpressionStatement struct { Loc Expression Expression }
func (*ExpressionStatement) Copy ¶
func (s *ExpressionStatement) Copy() Node
func (*ExpressionStatement) FromBuf ¶
func (rcv *ExpressionStatement) FromBuf(fb *fbsemantic.ExpressionStatement) error
func (*ExpressionStatement) NodeType ¶
func (*ExpressionStatement) NodeType() string
type File ¶
type File struct { Loc Package *PackageClause Imports []*ImportDeclaration Body []Statement }
type FloatLiteral ¶
func (*FloatLiteral) Copy ¶
func (l *FloatLiteral) Copy() Node
func (*FloatLiteral) FromBuf ¶
func (rcv *FloatLiteral) FromBuf(fb *fbsemantic.FloatLiteral) error
func (*FloatLiteral) NodeType ¶
func (*FloatLiteral) NodeType() string
func (*FloatLiteral) TypeOf ¶
func (e *FloatLiteral) TypeOf() MonoType
type FormatOption ¶
type FormatOption func(*formatter)
type FunctionExpression ¶
type FunctionExpression struct { Loc Parameters *FunctionParameters Defaults *ObjectExpression Block *Block Vectorized *FunctionExpression // contains filtered or unexported fields }
FunctionExpression represents the definition of a function
func (*FunctionExpression) Copy ¶
func (e *FunctionExpression) Copy() Node
func (*FunctionExpression) FromBuf ¶
func (e *FunctionExpression) FromBuf(fb *fbsemantic.FunctionExpression) error
func (*FunctionExpression) GetFunctionBodyExpression ¶
func (e *FunctionExpression) GetFunctionBodyExpression() (Expression, bool)
GetFunctionBodyExpression will return the return value expression from the function block. This will only return an expression if there is exactly one expression in the block. It will return false as the second argument if the statement is more complex.
func (*FunctionExpression) NodeType ¶
func (*FunctionExpression) NodeType() string
func (*FunctionExpression) TypeOf ¶
func (e *FunctionExpression) TypeOf() MonoType
type FunctionParameter ¶
type FunctionParameter struct { Loc Key *Identifier }
FunctionParameter represents a function parameter.
func (*FunctionParameter) Copy ¶
func (p *FunctionParameter) Copy() Node
func (*FunctionParameter) FromBuf ¶
func (p *FunctionParameter) FromBuf(fb *fbsemantic.FunctionParameter) error
func (*FunctionParameter) NodeType ¶
func (*FunctionParameter) NodeType() string
type FunctionParameters ¶
type FunctionParameters struct { Loc List []*FunctionParameter Pipe *Identifier }
FunctionParameters represents the list of function parameters and which if any parameter is the pipe parameter.
func (*FunctionParameters) Copy ¶
func (p *FunctionParameters) Copy() Node
func (*FunctionParameters) NodeType ¶
func (*FunctionParameters) NodeType() string
type Identifier ¶
func (*Identifier) Copy ¶
func (i *Identifier) Copy() Node
func (*Identifier) FromBuf ¶
func (rcv *Identifier) FromBuf(fb *fbsemantic.Identifier) error
func (*Identifier) Key ¶
func (n *Identifier) Key() string
func (*Identifier) NodeType ¶
func (*Identifier) NodeType() string
type IdentifierExpression ¶
func (*IdentifierExpression) Copy ¶
func (e *IdentifierExpression) Copy() Node
func (*IdentifierExpression) FromBuf ¶
func (rcv *IdentifierExpression) FromBuf(fb *fbsemantic.IdentifierExpression) error
func (*IdentifierExpression) NodeType ¶
func (*IdentifierExpression) NodeType() string
func (*IdentifierExpression) TypeOf ¶
func (e *IdentifierExpression) TypeOf() MonoType
type ImportDeclaration ¶
type ImportDeclaration struct { Loc As *Identifier Path *StringLiteral }
func (*ImportDeclaration) Copy ¶
func (d *ImportDeclaration) Copy() Node
func (*ImportDeclaration) FromBuf ¶
func (rcv *ImportDeclaration) FromBuf(fb *fbsemantic.ImportDeclaration) error
func (*ImportDeclaration) NodeType ¶
func (*ImportDeclaration) NodeType() string
type IndexExpression ¶
type IndexExpression struct { Loc Array Expression Index Expression // contains filtered or unexported fields }
func (*IndexExpression) Copy ¶
func (e *IndexExpression) Copy() Node
func (*IndexExpression) FromBuf ¶
func (rcv *IndexExpression) FromBuf(fb *fbsemantic.IndexExpression) error
func (*IndexExpression) NodeType ¶
func (*IndexExpression) NodeType() string
func (*IndexExpression) TypeOf ¶
func (e *IndexExpression) TypeOf() MonoType
type Instantiator ¶
type Instantiator struct {
// contains filtered or unexported fields
}
func (*Instantiator) Fresh ¶
func (s *Instantiator) Fresh() uint64
type IntegerLiteral ¶
func (*IntegerLiteral) Copy ¶
func (l *IntegerLiteral) Copy() Node
func (*IntegerLiteral) FromBuf ¶
func (rcv *IntegerLiteral) FromBuf(fb *fbsemantic.IntegerLiteral) error
func (*IntegerLiteral) NodeType ¶
func (*IntegerLiteral) NodeType() string
func (*IntegerLiteral) TypeOf ¶
func (e *IntegerLiteral) TypeOf() MonoType
type InterpolatedPart ¶
type InterpolatedPart struct { Loc Expression Expression }
func (*InterpolatedPart) Copy ¶
func (p *InterpolatedPart) Copy() Node
func (*InterpolatedPart) NodeType ¶
func (*InterpolatedPart) NodeType() string
type Literal ¶
type Literal interface { Expression // contains filtered or unexported methods }
type Loc ¶
type Loc ast.SourceLocation
func (*Loc) FromBuf ¶
func (l *Loc) FromBuf(fb *fbsemantic.SourceLocation) error
func (Loc) Location ¶
func (l Loc) Location() ast.SourceLocation
type LogicalExpression ¶
type LogicalExpression struct { Loc Operator ast.LogicalOperatorKind Left Expression Right Expression // contains filtered or unexported fields }
func (*LogicalExpression) Copy ¶
func (e *LogicalExpression) Copy() Node
func (*LogicalExpression) FromBuf ¶
func (rcv *LogicalExpression) FromBuf(fb *fbsemantic.LogicalExpression) error
func (*LogicalExpression) NodeType ¶
func (*LogicalExpression) NodeType() string
func (*LogicalExpression) TypeOf ¶
func (e *LogicalExpression) TypeOf() MonoType
type MemberAssignment ¶
type MemberAssignment struct { Loc Member *MemberExpression Init Expression }
func (*MemberAssignment) Copy ¶
func (s *MemberAssignment) Copy() Node
func (*MemberAssignment) FromBuf ¶
func (rcv *MemberAssignment) FromBuf(fb *fbsemantic.MemberAssignment) error
func (*MemberAssignment) NodeType ¶
func (*MemberAssignment) NodeType() string
type MemberExpression ¶
type MemberExpression struct { Loc Object Expression Property Symbol // contains filtered or unexported fields }
func (*MemberExpression) Copy ¶
func (e *MemberExpression) Copy() Node
func (*MemberExpression) FromBuf ¶
func (rcv *MemberExpression) FromBuf(fb *fbsemantic.MemberExpression) error
func (*MemberExpression) NodeType ¶
func (*MemberExpression) NodeType() string
func (*MemberExpression) TypeOf ¶
func (e *MemberExpression) TypeOf() MonoType
type MonoType ¶
type MonoType struct {
// contains filtered or unexported fields
}
MonoType represents a monotype. This struct is a thin wrapper around Go code generated by the FlatBuffers compiler.
func ExtendObjectType ¶
func ExtendObjectType(properties []PropertyType, extends *uint64) MonoType
func NewAppType ¶
func NewAppType(collection fbsemantic.CollectionType, elemType MonoType) MonoType
func NewArrayType ¶
NewArrayType will construct a new Array MonoType where the inner element for the array is elemType.
func NewDictType ¶
NewDictType will construct a new Dict MonoType where the key element for the dict is keyType and the value element for the dict is valueType.
func NewDynamicType ¶
func NewDynamicType() MonoType
NewDynamicType will construct a new Dynamic MonoType
func NewFunctionType ¶
func NewFunctionType(retn MonoType, args []ArgumentType) MonoType
NewFunctionType will construct a new Function MonoType that has a return value that matches retn and arguments for each of the values in ArgumentType.
func NewMonoType ¶
func NewMonoType(tbl flatbuffers.Table, t fbsemantic.MonoType) (MonoType, error)
NewMonoType constructs a new monotype from a FlatBuffers table and the given kind of monotype.
func NewObjectType ¶
func NewObjectType(properties []PropertyType) MonoType
NewObjectType will construct a new Object MonoType with the properties in properties.
The MonoType will be constructed with the properties in the same order as they appear in the array.
func NewStreamType ¶
func NewVarType ¶
func NewVectorType ¶
func (MonoType) Argument ¶
Argument returns the argument give an ordinal position if this monotype is a function, and an error otherwise.
func (MonoType) Basic ¶
func (mt MonoType) Basic() (fbsemantic.Type, error)
Basic returns the basic type for this monotype if it is a basic type, and an error otherwise.
func (MonoType) CanonicalString ¶
CanonicalString returns a string representation of this monotype where the tvar numbers are contiguous and indexed starting at zero.
func (MonoType) CollectionType ¶
func (mt MonoType) CollectionType() (fbsemantic.CollectionType, error)
func (MonoType) ElemType ¶
ElemType returns the element type if this monotype is an array or vector, and an error otherise
func (MonoType) Extends ¶
Extends returns the extending type variable if this monotype is a record, and an error otherwise. If the type is a record but does not extend anything a false is returned.
func (MonoType) NumArguments ¶
NumArguments returns the number of arguments if this monotype is a function, and an error otherwise.
func (MonoType) NumProperties ¶
NumProperties returns the number of properties if this monotype is a record, and an error otherwise.
func (MonoType) PipeArgument ¶
PipeArgument will return the pipe argument if this monotype is a function and it has a pipe argument. If this monotype is a function with no pipe argument, nil will be returned. If this monotype is not a function, an error will be returned.
func (MonoType) RecordProperty ¶
func (mt MonoType) RecordProperty(i int) (*RecordProperty, error)
RecordProperty returns a property given its ordinal position if this monotype is a record, and an error otherwise.
func (MonoType) ReturnType ¶
func (MonoType) SortedArguments ¶
SortedArguments returns a slice of function arguments, sorted by argument name, if this monotype is a function.
func (MonoType) SortedProperties ¶
func (mt MonoType) SortedProperties() ([]*RecordProperty, error)
SortedProperties returns the properties for a Record monotype, sorted by key. It's possible that there are duplicate keys with different types, in this case, this function preserves their order.
type NativeVariableAssignment ¶
type NativeVariableAssignment struct { Loc Identifier *Identifier Init Expression Typ PolyType }
func (*NativeVariableAssignment) Copy ¶
func (s *NativeVariableAssignment) Copy() Node
func (*NativeVariableAssignment) FromBuf ¶
func (rcv *NativeVariableAssignment) FromBuf(fb *fbsemantic.NativeVariableAssignment) error
func (*NativeVariableAssignment) NodeType ¶
func (*NativeVariableAssignment) NodeType() string
type NestingVisitor ¶
type NestingVisitor interface { Visitor Nest() NestingVisitor }
type Node ¶
type Node interface { NodeType() string Copy() Node Location() ast.SourceLocation // contains filtered or unexported methods }
type ObjectExpression ¶
type ObjectExpression struct { Loc With *IdentifierExpression Properties []*Property // contains filtered or unexported fields }
func (*ObjectExpression) Copy ¶
func (e *ObjectExpression) Copy() Node
func (*ObjectExpression) FromBuf ¶
func (rcv *ObjectExpression) FromBuf(fb *fbsemantic.ObjectExpression) error
func (*ObjectExpression) NodeType ¶
func (*ObjectExpression) NodeType() string
func (*ObjectExpression) TypeOf ¶
func (e *ObjectExpression) TypeOf() MonoType
type OptionStatement ¶
type OptionStatement struct { Loc Assignment Assignment }
func (*OptionStatement) Copy ¶
func (s *OptionStatement) Copy() Node
func (*OptionStatement) FromBuf ¶
func (rcv *OptionStatement) FromBuf(fb *fbsemantic.OptionStatement) error
func (*OptionStatement) NodeType ¶
func (s *OptionStatement) NodeType() string
type Package ¶
type PackageClause ¶
type PackageClause struct { Loc Name *Identifier }
func (*PackageClause) Copy ¶
func (p *PackageClause) Copy() Node
func (*PackageClause) FromBuf ¶
func (rcv *PackageClause) FromBuf(fb *fbsemantic.PackageClause) error
func (*PackageClause) NodeType ¶
func (*PackageClause) NodeType() string
type PolyType ¶
type PolyType struct {
// contains filtered or unexported fields
}
PolyType represents a polytype. This struct is a thin wrapper around Go code generated by the FlatBuffers compiler.
func NewPolyType ¶
func NewPolyType(fb *fbsemantic.PolyType) (PolyType, error)
NewPolyType returns a new polytype given a flatbuffers polytype.
func (PolyType) CanonicalString ¶
CanonicalString returns a string representation for this polytype, where the tvar numbers are contiguous and indexed starting at zero. Tvar numbers are ordered by the order they appear in the monotype expression.
func (PolyType) Constraint ¶
func (pt PolyType) Constraint(i int) (*fbsemantic.Constraint, error)
Constraint returns the constraint at ordinal position i.
func (PolyType) Instantiator ¶
func (pt PolyType) Instantiator(subst Substitutor) (Substitutor, error)
func (PolyType) IsNil ¶
For testing we need an exported method that checks whether PolyType.fb is nil.
func (PolyType) NumConstraints ¶
NumConstraints returns the number of kind constraints in this polytype.
func (*PolyType) SortedConstraints ¶
func (pt *PolyType) SortedConstraints() ([]*fbsemantic.Constraint, error)
SortedConstraints returns the constraints for this polytype sorted by type variable and constraint kind.
func (PolyType) SortedVars ¶
func (pt PolyType) SortedVars() ([]*fbsemantic.Var, error)
type Property ¶
type Property struct { Loc Key PropertyKey Value Expression }
type PropertyKey ¶
type PropertyType ¶
type RecordProperty ¶
type RecordProperty struct {
// contains filtered or unexported fields
}
Property represents a property of a record.
func (*RecordProperty) Name ¶
func (p *RecordProperty) Name() string
Name returns the name of the property.
func (*RecordProperty) TypeOf ¶
func (p *RecordProperty) TypeOf() (MonoType, error)
TypeOf returns the type of the property.
type RegexpLiteral ¶
func (*RegexpLiteral) Copy ¶
func (l *RegexpLiteral) Copy() Node
func (*RegexpLiteral) FromBuf ¶
func (rcv *RegexpLiteral) FromBuf(fb *fbsemantic.RegexpLiteral) error
func (*RegexpLiteral) NodeType ¶
func (*RegexpLiteral) NodeType() string
func (*RegexpLiteral) TypeOf ¶
func (e *RegexpLiteral) TypeOf() MonoType
type ReturnStatement ¶
type ReturnStatement struct { Loc Argument Expression }
func (*ReturnStatement) Copy ¶
func (s *ReturnStatement) Copy() Node
func (*ReturnStatement) FromBuf ¶
func (rcv *ReturnStatement) FromBuf(fb *fbsemantic.ReturnStatement) error
func (*ReturnStatement) NodeType ¶
func (*ReturnStatement) NodeType() string
type ScopedVisitor ¶
type ScopedVisitor struct {
// contains filtered or unexported fields
}
ScopedVisitor will nest the given visitor when the scope changes.
func NewScopedVisitor ¶
func NewScopedVisitor(v NestingVisitor) ScopedVisitor
func (ScopedVisitor) Done ¶
func (v ScopedVisitor) Done(node Node)
func (ScopedVisitor) Visit ¶
func (v ScopedVisitor) Visit(node Node) Visitor
type StreamFB ¶
type StreamFB struct {
// contains filtered or unexported fields
}
func (*StreamFB) ElementType ¶
type StringExpression ¶
type StringExpression struct { Loc Parts []StringExpressionPart }
func (*StringExpression) Copy ¶
func (e *StringExpression) Copy() Node
func (*StringExpression) FromBuf ¶
func (rcv *StringExpression) FromBuf(fb *fbsemantic.StringExpression) error
func (*StringExpression) NodeType ¶
func (*StringExpression) NodeType() string
func (*StringExpression) TypeOf ¶
func (e *StringExpression) TypeOf() MonoType
type StringExpressionPart ¶
type StringExpressionPart interface { Node // contains filtered or unexported methods }
type StringLiteral ¶
func (*StringLiteral) Copy ¶
func (l *StringLiteral) Copy() Node
func (*StringLiteral) FromBuf ¶
func (rcv *StringLiteral) FromBuf(fb *fbsemantic.StringLiteral) error
func (*StringLiteral) Key ¶
func (n *StringLiteral) Key() string
func (*StringLiteral) NodeType ¶
func (*StringLiteral) NodeType() string
func (*StringLiteral) TypeOf ¶
func (e *StringLiteral) TypeOf() MonoType
type Substitution ¶
func (*Substitution) Fresh ¶
func (s *Substitution) Fresh() uint64
type TestStatement ¶
type TestStatement struct { Loc Assignment *NativeVariableAssignment }
func (*TestStatement) Copy ¶
func (s *TestStatement) Copy() Node
func (*TestStatement) FromBuf ¶
func (rcv *TestStatement) FromBuf(fb *fbsemantic.TestStatement) error
func (*TestStatement) NodeType ¶
func (s *TestStatement) NodeType() string
type UnaryExpression ¶
type UnaryExpression struct { Loc Operator ast.OperatorKind Argument Expression // contains filtered or unexported fields }
func (*UnaryExpression) Copy ¶
func (e *UnaryExpression) Copy() Node
func (*UnaryExpression) FromBuf ¶
func (rcv *UnaryExpression) FromBuf(fb *fbsemantic.UnaryExpression) error
func (*UnaryExpression) NodeType ¶
func (*UnaryExpression) NodeType() string
func (*UnaryExpression) TypeOf ¶
func (e *UnaryExpression) TypeOf() MonoType
type UnsignedIntegerLiteral ¶
func (*UnsignedIntegerLiteral) Copy ¶
func (l *UnsignedIntegerLiteral) Copy() Node
func (*UnsignedIntegerLiteral) FromBuf ¶
func (rcv *UnsignedIntegerLiteral) FromBuf(fb *fbsemantic.UnsignedIntegerLiteral) error
func (*UnsignedIntegerLiteral) NodeType ¶
func (*UnsignedIntegerLiteral) NodeType() string
func (*UnsignedIntegerLiteral) TypeOf ¶
func (e *UnsignedIntegerLiteral) TypeOf() MonoType
type VarPropertyType ¶
type VarPropertyType struct { Key interface{} Value MonoType }
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
Package semantictest contains utilities for testing the semantic package.
|
Package semantictest contains utilities for testing the semantic package. |