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 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 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 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 NewArrayType(elemType MonoType) MonoType
- func NewDictType(keyType, valueType MonoType) MonoType
- func NewFunctionType(retn MonoType, args []ArgumentType) MonoType
- func NewMonoType(tbl flatbuffers.Table, t fbsemantic.MonoType) (MonoType, error)
- func NewObjectType(properties []PropertyType) MonoType
- func (mt MonoType) Argument(i int) (*Argument, error)
- func (mt MonoType) Basic() (fbsemantic.Type, error)
- func (mt MonoType) CanonicalString() string
- 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) 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 StringExpression
- type StringExpressionPart
- type StringLiteral
- type TestStatement
- type TextPart
- type UnaryExpression
- type UnsignedIntegerLiteral
- type Visitor
Constants ¶
const ( Unknown = Kind(fbsemantic.MonoTypeNONE) Basic = Kind(fbsemantic.MonoTypeBasic) Var = Kind(fbsemantic.MonoTypeVar) Arr = Kind(fbsemantic.MonoTypeArr) Record = Kind(fbsemantic.MonoTypeRecord) Fun = Kind(fbsemantic.MonoTypeFun) Dict = Kind(fbsemantic.MonoTypeDict) )
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 ¶ added in v0.50.0
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.
Types ¶
type Argument ¶ added in v0.68.0
type Argument struct {
*fbsemantic.Argument
}
Argument represents a function argument.
type ArgumentType ¶ added in v0.68.0
type ArrayExpression ¶
type ArrayExpression struct { Loc Elements []Expression Type MonoType }
func (*ArrayExpression) Copy ¶
func (e *ArrayExpression) Copy() Node
func (*ArrayExpression) FromBuf ¶ added in v0.57.0
func (rcv *ArrayExpression) FromBuf(fb *fbsemantic.ArrayExpression) error
func (*ArrayExpression) NodeType ¶
func (*ArrayExpression) NodeType() string
func (*ArrayExpression) TypeOf ¶ added in v0.58.0
func (e *ArrayExpression) TypeOf() MonoType
type Assignment ¶ added in v0.14.0
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 ¶ added in v0.57.0
func (rcv *BinaryExpression) FromBuf(fb *fbsemantic.BinaryExpression) error
func (*BinaryExpression) NodeType ¶
func (*BinaryExpression) NodeType() string
func (*BinaryExpression) TypeOf ¶ added in v0.58.0
func (e *BinaryExpression) TypeOf() MonoType
type Block ¶ added in v0.8.0
func (*Block) ReturnStatement ¶ added in v0.8.0
func (s *Block) ReturnStatement() *ReturnStatement
type BooleanLiteral ¶
func (*BooleanLiteral) Copy ¶
func (l *BooleanLiteral) Copy() Node
func (*BooleanLiteral) FromBuf ¶ added in v0.57.0
func (rcv *BooleanLiteral) FromBuf(fb *fbsemantic.BooleanLiteral) error
func (*BooleanLiteral) NodeType ¶
func (*BooleanLiteral) NodeType() string
func (*BooleanLiteral) TypeOf ¶ added in v0.58.0
func (e *BooleanLiteral) TypeOf() MonoType
type BuiltinStatement ¶ added in v0.14.0
type BuiltinStatement struct { Loc ID *Identifier }
func (*BuiltinStatement) Copy ¶ added in v0.14.0
func (s *BuiltinStatement) Copy() Node
func (*BuiltinStatement) FromBuf ¶ added in v0.57.0
func (rcv *BuiltinStatement) FromBuf(fb *fbsemantic.BuiltinStatement) error
func (*BuiltinStatement) NodeType ¶ added in v0.14.0
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 ¶ added in v0.57.0
func (rcv *CallExpression) FromBuf(fb *fbsemantic.CallExpression) error
func (*CallExpression) NodeType ¶
func (*CallExpression) NodeType() string
func (*CallExpression) TypeOf ¶ added in v0.58.0
func (e *CallExpression) TypeOf() MonoType
type ConditionalExpression ¶
type ConditionalExpression struct { Loc Test Expression Alternate Expression Consequent Expression }
func (*ConditionalExpression) Copy ¶
func (e *ConditionalExpression) Copy() Node
func (*ConditionalExpression) FromBuf ¶ added in v0.57.0
func (rcv *ConditionalExpression) FromBuf(fb *fbsemantic.ConditionalExpression) error
func (*ConditionalExpression) NodeType ¶
func (*ConditionalExpression) NodeType() string
func (*ConditionalExpression) TypeOf ¶ added in v0.58.0
func (e *ConditionalExpression) TypeOf() MonoType
type DateTimeLiteral ¶
func (*DateTimeLiteral) Copy ¶
func (l *DateTimeLiteral) Copy() Node
func (*DateTimeLiteral) FromBuf ¶ added in v0.57.0
func (rcv *DateTimeLiteral) FromBuf(fb *fbsemantic.DateTimeLiteral) error
func (*DateTimeLiteral) NodeType ¶
func (*DateTimeLiteral) NodeType() string
func (*DateTimeLiteral) TypeOf ¶ added in v0.58.0
func (e *DateTimeLiteral) TypeOf() MonoType
type DictExpression ¶ added in v0.99.0
type DictExpression struct { Loc Elements []struct { Key Expression Val Expression } Type MonoType }
func (*DictExpression) Copy ¶ added in v0.99.0
func (e *DictExpression) Copy() Node
func (*DictExpression) FromBuf ¶ added in v0.99.0
func (rcv *DictExpression) FromBuf(fb *fbsemantic.DictExpression) error
func (*DictExpression) NodeType ¶ added in v0.99.0
func (*DictExpression) NodeType() string
func (*DictExpression) TypeOf ¶ added in v0.99.0
func (e *DictExpression) TypeOf() MonoType
type DurationLiteral ¶
func (*DurationLiteral) Copy ¶
func (l *DurationLiteral) Copy() Node
func (*DurationLiteral) FromBuf ¶ added in v0.57.0
func (rcv *DurationLiteral) FromBuf(fb *fbsemantic.DurationLiteral) error
func (*DurationLiteral) NodeType ¶
func (*DurationLiteral) NodeType() string
func (*DurationLiteral) TypeOf ¶ added in v0.58.0
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 ¶ added in v0.57.0
func (rcv *ExpressionStatement) FromBuf(fb *fbsemantic.ExpressionStatement) error
func (*ExpressionStatement) NodeType ¶
func (*ExpressionStatement) NodeType() string
type File ¶ added in v0.13.0
type File struct { Loc Package *PackageClause Imports []*ImportDeclaration Body []Statement }
type FloatLiteral ¶
func (*FloatLiteral) Copy ¶
func (l *FloatLiteral) Copy() Node
func (*FloatLiteral) FromBuf ¶ added in v0.57.0
func (rcv *FloatLiteral) FromBuf(fb *fbsemantic.FloatLiteral) error
func (*FloatLiteral) NodeType ¶
func (*FloatLiteral) NodeType() string
func (*FloatLiteral) TypeOf ¶ added in v0.58.0
func (e *FloatLiteral) TypeOf() MonoType
type FormatOption ¶ added in v0.50.0
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 ¶ added in v0.57.0
func (e *FunctionExpression) FromBuf(fb *fbsemantic.FunctionExpression) error
func (*FunctionExpression) GetFunctionBodyExpression ¶ added in v0.68.0
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 ¶ added in v0.58.0
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 ¶ added in v0.57.0
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 ¶ added in v0.57.0
func (rcv *Identifier) FromBuf(fb *fbsemantic.Identifier) error
func (*Identifier) Key ¶ added in v0.12.0
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 ¶ added in v0.57.0
func (rcv *IdentifierExpression) FromBuf(fb *fbsemantic.IdentifierExpression) error
func (*IdentifierExpression) NodeType ¶
func (*IdentifierExpression) NodeType() string
func (*IdentifierExpression) TypeOf ¶ added in v0.58.0
func (e *IdentifierExpression) TypeOf() MonoType
type ImportDeclaration ¶ added in v0.8.0
type ImportDeclaration struct { Loc As *Identifier Path *StringLiteral }
func (*ImportDeclaration) Copy ¶ added in v0.8.0
func (d *ImportDeclaration) Copy() Node
func (*ImportDeclaration) FromBuf ¶ added in v0.57.0
func (rcv *ImportDeclaration) FromBuf(fb *fbsemantic.ImportDeclaration) error
func (*ImportDeclaration) NodeType ¶ added in v0.8.0
func (*ImportDeclaration) NodeType() string
type IndexExpression ¶ added in v0.7.1
type IndexExpression struct { Loc Array Expression Index Expression // contains filtered or unexported fields }
func (*IndexExpression) Copy ¶ added in v0.7.1
func (e *IndexExpression) Copy() Node
func (*IndexExpression) FromBuf ¶ added in v0.57.0
func (rcv *IndexExpression) FromBuf(fb *fbsemantic.IndexExpression) error
func (*IndexExpression) NodeType ¶ added in v0.7.1
func (*IndexExpression) NodeType() string
func (*IndexExpression) TypeOf ¶ added in v0.58.0
func (e *IndexExpression) TypeOf() MonoType
type IntegerLiteral ¶
func (*IntegerLiteral) Copy ¶
func (l *IntegerLiteral) Copy() Node
func (*IntegerLiteral) FromBuf ¶ added in v0.57.0
func (rcv *IntegerLiteral) FromBuf(fb *fbsemantic.IntegerLiteral) error
func (*IntegerLiteral) NodeType ¶
func (*IntegerLiteral) NodeType() string
func (*IntegerLiteral) TypeOf ¶ added in v0.58.0
func (e *IntegerLiteral) TypeOf() MonoType
type InterpolatedPart ¶ added in v0.41.0
type InterpolatedPart struct { Loc Expression Expression }
func (*InterpolatedPart) Copy ¶ added in v0.41.0
func (p *InterpolatedPart) Copy() Node
func (*InterpolatedPart) NodeType ¶ added in v0.41.0
func (*InterpolatedPart) NodeType() string
type Literal ¶
type Literal interface { Expression // contains filtered or unexported methods }
type Loc ¶ added in v0.68.0
type Loc ast.SourceLocation
func (*Loc) FromBuf ¶ added in v0.68.0
func (l *Loc) FromBuf(fb *fbsemantic.SourceLocation) error
func (Loc) Location ¶ added in v0.68.0
func (l Loc) Location() ast.SourceLocation
type LogicalExpression ¶
type LogicalExpression struct { Loc Operator ast.LogicalOperatorKind Left Expression Right Expression }
func (*LogicalExpression) Copy ¶
func (e *LogicalExpression) Copy() Node
func (*LogicalExpression) FromBuf ¶ added in v0.57.0
func (rcv *LogicalExpression) FromBuf(fb *fbsemantic.LogicalExpression) error
func (*LogicalExpression) NodeType ¶
func (*LogicalExpression) NodeType() string
func (*LogicalExpression) TypeOf ¶ added in v0.58.0
func (e *LogicalExpression) TypeOf() MonoType
type MemberAssignment ¶ added in v0.14.0
type MemberAssignment struct { Loc Member *MemberExpression Init Expression }
func (*MemberAssignment) Copy ¶ added in v0.14.0
func (s *MemberAssignment) Copy() Node
func (*MemberAssignment) FromBuf ¶ added in v0.57.0
func (rcv *MemberAssignment) FromBuf(fb *fbsemantic.MemberAssignment) error
func (*MemberAssignment) NodeType ¶ added in v0.14.0
func (*MemberAssignment) NodeType() string
type MemberExpression ¶
type MemberExpression struct { Loc Object Expression Property string // contains filtered or unexported fields }
func (*MemberExpression) Copy ¶
func (e *MemberExpression) Copy() Node
func (*MemberExpression) FromBuf ¶ added in v0.57.0
func (rcv *MemberExpression) FromBuf(fb *fbsemantic.MemberExpression) error
func (*MemberExpression) NodeType ¶
func (*MemberExpression) NodeType() string
func (*MemberExpression) TypeOf ¶ added in v0.58.0
func (e *MemberExpression) TypeOf() MonoType
type MonoType ¶ added in v0.68.0
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 ¶ added in v0.68.0
func ExtendObjectType(properties []PropertyType, extends *uint64) MonoType
func NewArrayType ¶
NewArrayType will construct a new Array MonoType where the inner element for the array is elemType.
func NewDictType ¶ added in v0.96.0
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 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 ¶ added in v0.68.0
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 (MonoType) Argument ¶ added in v0.68.0
Argument returns the argument give an ordinal position if this monotype is a function, and an error otherwise.
func (MonoType) Basic ¶ added in v0.68.0
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 ¶ added in v0.68.0
CanonicalString returns a string representation of this monotype where the tvar numbers are contiguous and indexed starting at zero.
func (MonoType) ElemType ¶ added in v0.68.0
ElemType returns the element type if this monotype is an array, and an error otherise.
func (MonoType) Extends ¶ added in v0.68.0
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 ¶ added in v0.68.0
NumArguments returns the number of arguments if this monotype is a function, and an error otherwise.
func (MonoType) NumProperties ¶ added in v0.68.0
NumProperties returns the number of properties if this monotype is a record, and an error otherwise.
func (MonoType) PipeArgument ¶ added in v0.81.0
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 ¶ added in v0.81.0
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 ¶ added in v0.68.0
func (MonoType) SortedArguments ¶ added in v0.68.0
SortedArguments returns a slice of function arguments, sorted by argument name, if this monotype is a function.
func (MonoType) SortedProperties ¶ added in v0.68.0
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 ¶ added in v0.8.0
type NativeVariableAssignment struct { Loc Identifier *Identifier Init Expression Typ PolyType }
func (*NativeVariableAssignment) Copy ¶ added in v0.8.0
func (s *NativeVariableAssignment) Copy() Node
func (*NativeVariableAssignment) FromBuf ¶ added in v0.57.0
func (rcv *NativeVariableAssignment) FromBuf(fb *fbsemantic.NativeVariableAssignment) error
func (*NativeVariableAssignment) NodeType ¶ added in v0.8.0
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 ¶ added in v0.57.0
func (rcv *ObjectExpression) FromBuf(fb *fbsemantic.ObjectExpression) error
func (*ObjectExpression) NodeType ¶
func (*ObjectExpression) NodeType() string
func (*ObjectExpression) TypeOf ¶ added in v0.58.0
func (e *ObjectExpression) TypeOf() MonoType
type OptionStatement ¶
type OptionStatement struct { Loc Assignment Assignment }
func (*OptionStatement) Copy ¶
func (s *OptionStatement) Copy() Node
func (*OptionStatement) FromBuf ¶ added in v0.57.0
func (rcv *OptionStatement) FromBuf(fb *fbsemantic.OptionStatement) error
func (*OptionStatement) NodeType ¶
func (s *OptionStatement) NodeType() string
type Package ¶ added in v0.8.0
func DeserializeFromFlatBuffer ¶ added in v0.57.0
type PackageClause ¶ added in v0.8.0
type PackageClause struct { Loc Name *Identifier }
func (*PackageClause) Copy ¶ added in v0.8.0
func (p *PackageClause) Copy() Node
func (*PackageClause) FromBuf ¶ added in v0.57.0
func (rcv *PackageClause) FromBuf(fb *fbsemantic.PackageClause) error
func (*PackageClause) NodeType ¶ added in v0.8.0
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 ¶ added in v0.68.0
func NewPolyType(fb *fbsemantic.PolyType) (PolyType, error)
NewPolyType returns a new polytype given a flatbuffers polytype.
func (PolyType) CanonicalString ¶ added in v0.68.0
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 ¶ added in v0.68.0
func (pt PolyType) Constraint(i int) (*fbsemantic.Constraint, error)
Constraint returns the constraint at ordinal position i.
func (PolyType) IsNil ¶ added in v0.68.0
For testing we need an exported method that checks whether PolyType.fb is nil.
func (PolyType) NumConstraints ¶ added in v0.68.0
NumConstraints returns the number of kind constraints in this polytype.
func (PolyType) NumVars ¶ added in v0.68.0
NumVars returns the number of type variables in this polytype.
func (*PolyType) SortedConstraints ¶ added in v0.68.0
func (pt *PolyType) SortedConstraints() ([]*fbsemantic.Constraint, error)
SortedConstraints returns the constraints for this polytype sorted by type variable and constraint kind.
func (PolyType) SortedVars ¶ added in v0.68.0
func (pt PolyType) SortedVars() ([]*fbsemantic.Var, error)
type Property ¶
type Property struct { Loc Key PropertyKey Value Expression }
type PropertyKey ¶ added in v0.12.0
type PropertyType ¶ added in v0.68.0
type RecordProperty ¶ added in v0.81.0
type RecordProperty struct {
// contains filtered or unexported fields
}
Property represents a property of a record.
func (*RecordProperty) Name ¶ added in v0.81.0
func (p *RecordProperty) Name() string
Name returns the name of the property.
func (*RecordProperty) TypeOf ¶ added in v0.81.0
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 ¶ added in v0.57.0
func (rcv *RegexpLiteral) FromBuf(fb *fbsemantic.RegexpLiteral) error
func (*RegexpLiteral) NodeType ¶
func (*RegexpLiteral) NodeType() string
func (*RegexpLiteral) TypeOf ¶ added in v0.58.0
func (e *RegexpLiteral) TypeOf() MonoType
type ReturnStatement ¶
type ReturnStatement struct { Loc Argument Expression }
func (*ReturnStatement) Copy ¶
func (s *ReturnStatement) Copy() Node
func (*ReturnStatement) FromBuf ¶ added in v0.57.0
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 StringExpression ¶ added in v0.41.0
type StringExpression struct { Loc Parts []StringExpressionPart }
func (*StringExpression) Copy ¶ added in v0.41.0
func (e *StringExpression) Copy() Node
func (*StringExpression) FromBuf ¶ added in v0.57.0
func (rcv *StringExpression) FromBuf(fb *fbsemantic.StringExpression) error
func (*StringExpression) NodeType ¶ added in v0.41.0
func (*StringExpression) NodeType() string
func (*StringExpression) TypeOf ¶ added in v0.58.0
func (e *StringExpression) TypeOf() MonoType
type StringExpressionPart ¶ added in v0.41.0
type StringExpressionPart interface { Node // contains filtered or unexported methods }
type StringLiteral ¶
func (*StringLiteral) Copy ¶
func (l *StringLiteral) Copy() Node
func (*StringLiteral) FromBuf ¶ added in v0.57.0
func (rcv *StringLiteral) FromBuf(fb *fbsemantic.StringLiteral) error
func (*StringLiteral) Key ¶ added in v0.12.0
func (n *StringLiteral) Key() string
func (*StringLiteral) NodeType ¶
func (*StringLiteral) NodeType() string
func (*StringLiteral) TypeOf ¶ added in v0.58.0
func (e *StringLiteral) TypeOf() MonoType
type TestStatement ¶ added in v0.19.0
type TestStatement struct { Loc Assignment *NativeVariableAssignment }
func (*TestStatement) Copy ¶ added in v0.19.0
func (s *TestStatement) Copy() Node
func (*TestStatement) FromBuf ¶ added in v0.57.0
func (rcv *TestStatement) FromBuf(fb *fbsemantic.TestStatement) error
func (*TestStatement) NodeType ¶ added in v0.19.0
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 ¶ added in v0.57.0
func (rcv *UnaryExpression) FromBuf(fb *fbsemantic.UnaryExpression) error
func (*UnaryExpression) NodeType ¶
func (*UnaryExpression) NodeType() string
func (*UnaryExpression) TypeOf ¶ added in v0.58.0
func (e *UnaryExpression) TypeOf() MonoType
type UnsignedIntegerLiteral ¶
func (*UnsignedIntegerLiteral) Copy ¶
func (l *UnsignedIntegerLiteral) Copy() Node
func (*UnsignedIntegerLiteral) FromBuf ¶ added in v0.57.0
func (rcv *UnsignedIntegerLiteral) FromBuf(fb *fbsemantic.UnsignedIntegerLiteral) error
func (*UnsignedIntegerLiteral) NodeType ¶
func (*UnsignedIntegerLiteral) NodeType() string
func (*UnsignedIntegerLiteral) TypeOf ¶ added in v0.58.0
func (e *UnsignedIntegerLiteral) TypeOf() MonoType
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
Package semantictest contains utilities for testing the semantic package.
|
Package semantictest contains utilities for testing the semantic package. |