semantic

package
v0.99.3 Latest Latest
Warning

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

Go to latest
Published: Jan 3, 2021 License: MIT Imports: 11 Imported by: 0

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

View Source
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 ToAST

func ToAST(n Node) ast.Node

ToAST will construct an AST from the semantic graph. The AST will not be preserved when going from AST -> semantic -> AST, but going from semantic -> AST -> semantic should result in the same graph.

func Walk

func Walk(v Visitor, node Node)

Types

type Argument

type Argument struct {
	*fbsemantic.Argument
}

Argument represents a function argument.

func (*Argument) TypeOf

func (a *Argument) TypeOf() (MonoType, error)

TypeOf returns the type of the function argument.

type ArgumentType

type ArgumentType struct {
	Name     []byte
	Type     MonoType
	Pipe     bool
	Optional bool
}

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 (*BinaryExpression) NodeType

func (*BinaryExpression) NodeType() string

func (*BinaryExpression) TypeOf

func (e *BinaryExpression) TypeOf() MonoType

type Block

type Block struct {
	Loc

	Body []Statement
}

func (*Block) Copy

func (s *Block) Copy() Node

func (*Block) FromBuf

func (rcv *Block) FromBuf(fb *fbsemantic.Block) error

func (*Block) NodeType

func (*Block) NodeType() string

func (*Block) ReturnStatement

func (s *Block) ReturnStatement() *ReturnStatement

type BooleanLiteral

type BooleanLiteral struct {
	Loc
	Value bool
}

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 (*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 ConditionalExpression

type ConditionalExpression struct {
	Loc

	Test       Expression
	Alternate  Expression
	Consequent Expression
}

func (*ConditionalExpression) Copy

func (e *ConditionalExpression) Copy() Node

func (*ConditionalExpression) FromBuf

func (*ConditionalExpression) NodeType

func (*ConditionalExpression) NodeType() string

func (*ConditionalExpression) TypeOf

func (e *ConditionalExpression) TypeOf() MonoType

type DateTimeLiteral

type DateTimeLiteral struct {
	Loc
	Value time.Time
}

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

type DurationLiteral struct {
	Loc
	Values []ast.Duration
}

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

type Expression interface {
	Node

	TypeOf() MonoType
	// contains filtered or unexported methods
}

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 (*ExpressionStatement) NodeType

func (*ExpressionStatement) NodeType() string

type File

type File struct {
	Loc

	Package *PackageClause
	Imports []*ImportDeclaration
	Body    []Statement
}

func (*File) Copy

func (p *File) Copy() Node

func (*File) FromBuf

func (rcv *File) FromBuf(fb *fbsemantic.File) error

func (*File) NodeType

func (*File) NodeType() string

type FloatLiteral

type FloatLiteral struct {
	Loc
	Value float64
}

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
	// contains filtered or unexported fields
}

FunctionExpression represents the definition of a function

func (*FunctionExpression) Copy

func (e *FunctionExpression) Copy() Node

func (*FunctionExpression) FromBuf

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 (*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

type Identifier struct {
	Loc

	Name string
}

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

type IdentifierExpression struct {
	Loc

	Name string
	// contains filtered or unexported fields
}

func (*IdentifierExpression) Copy

func (e *IdentifierExpression) Copy() Node

func (*IdentifierExpression) FromBuf

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 (*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 IntegerLiteral

type IntegerLiteral struct {
	Loc
	Value int64
}

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 Kind

type Kind fbsemantic.MonoType

Kind specifies a particular kind of monotype.

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
}

func (*LogicalExpression) Copy

func (e *LogicalExpression) Copy() Node

func (*LogicalExpression) FromBuf

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 (*MemberAssignment) NodeType

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

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 NewArrayType

func NewArrayType(elemType MonoType) MonoType

NewArrayType will construct a new Array MonoType where the inner element for the array is elemType.

func NewDictType

func NewDictType(keyType, valueType MonoType) MonoType

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

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

func (mt MonoType) Argument(i int) (*Argument, error)

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

func (mt MonoType) CanonicalString() string

CanonicalString returns a string representation of this monotype where the tvar numbers are contiguous and indexed starting at zero.

func (MonoType) ElemType

func (mt MonoType) ElemType() (MonoType, error)

ElemType returns the element type if this monotype is an array, and an error otherise.

func (MonoType) Equal

func (l MonoType) Equal(r MonoType) bool

func (MonoType) Extends

func (mt MonoType) Extends() (MonoType, bool, error)

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) KeyType

func (mt MonoType) KeyType() (MonoType, error)

KeyType returns the type for the key in a Dictionary.

func (MonoType) Kind

func (mt MonoType) Kind() Kind

Kind returns what kind of monotype the receiver is.

func (MonoType) Nature

func (mt MonoType) Nature() Nature

func (MonoType) NumArguments

func (mt MonoType) NumArguments() (int, error)

NumArguments returns the number of arguments if this monotype is a function, and an error otherwise.

func (MonoType) NumProperties

func (mt MonoType) NumProperties() (int, error)

NumProperties returns the number of properties if this monotype is a record, and an error otherwise.

func (MonoType) PipeArgument

func (mt MonoType) PipeArgument() (*Argument, error)

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 (mt MonoType) ReturnType() (MonoType, error)

func (MonoType) SortedArguments

func (mt MonoType) SortedArguments() ([]*Argument, error)

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.

func (MonoType) String

func (mt MonoType) String() string

String returns a string representation of this monotype.

func (MonoType) ValueType

func (mt MonoType) ValueType() (MonoType, error)

ValueType returns the type for the value in a Dictionary.

func (MonoType) VarNum

func (mt MonoType) VarNum() (uint64, error)

VarNum returns the type variable number if this monotype is a type variable, and an error otherwise.

type NativeVariableAssignment

type NativeVariableAssignment struct {
	Loc

	Identifier *Identifier
	Init       Expression

	Typ PolyType
}

func (*NativeVariableAssignment) Copy

func (s *NativeVariableAssignment) Copy() Node

func (*NativeVariableAssignment) FromBuf

func (*NativeVariableAssignment) NodeType

func (*NativeVariableAssignment) NodeType() string

type Nature

type Nature int

Nature is the primitive description of a type.

const (
	Invalid Nature = iota
	String
	Bytes
	Int
	UInt
	Float
	Bool
	Time
	Duration
	Regexp
	Array
	Object
	Function
	Dictionary
)

func (Nature) String

func (n Nature) String() 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 (*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 Package struct {
	Loc

	Package string
	Files   []*File
}

func DeserializeFromFlatBuffer

func DeserializeFromFlatBuffer(buf []byte) (*Package, error)

func New

func New(pkg *ast.Package) (*Package, error)

New creates a semantic graph from the provided AST

func (*Package) Copy

func (p *Package) Copy() Node

func (*Package) FromBuf

func (rcv *Package) FromBuf(fb *fbsemantic.Package) error

func (*Package) NodeType

func (*Package) NodeType() string

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

func (pt PolyType) CanonicalString() string

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) Expr

func (pt PolyType) Expr() (MonoType, error)

Expr returns the monotype expression for this polytype.

func (PolyType) IsNil

func (pt PolyType) IsNil() bool

For testing we need an exported method that checks whether PolyType.fb is nil.

func (PolyType) NumConstraints

func (pt PolyType) NumConstraints() int

NumConstraints returns the number of kind constraints in this polytype.

func (PolyType) NumVars

func (pt PolyType) NumVars() int

NumVars returns the number of type variables 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)

func (PolyType) String

func (pt PolyType) String() string

String returns a string representation for this polytype.

func (PolyType) Var

func (pt PolyType) Var(i int) (*fbsemantic.Var, error)

Var returns the type variable at ordinal position i.

type Property

type Property struct {
	Loc

	Key   PropertyKey
	Value Expression
}

func (*Property) Copy

func (p *Property) Copy() Node

func (*Property) FromBuf

func (rcv *Property) FromBuf(fb *fbsemantic.Property) error

func (*Property) NodeType

func (*Property) NodeType() string

type PropertyKey

type PropertyKey interface {
	Node
	Key() string
}

type PropertyType

type PropertyType struct {
	Key   []byte
	Value MonoType
}

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

type RegexpLiteral struct {
	Loc
	Value *regexp.Regexp
}

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 Statement

type Statement interface {
	Node
	// contains filtered or unexported methods
}

type StringExpression

type StringExpression struct {
	Loc
	Parts []StringExpressionPart
}

func (*StringExpression) Copy

func (e *StringExpression) Copy() Node

func (*StringExpression) FromBuf

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

type StringLiteral struct {
	Loc
	Value string
}

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 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 TextPart

type TextPart struct {
	Loc
	Value string
}

func (*TextPart) Copy

func (p *TextPart) Copy() Node

func (*TextPart) NodeType

func (*TextPart) 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

type UnsignedIntegerLiteral struct {
	Loc
	Value uint64
}

func (*UnsignedIntegerLiteral) Copy

func (l *UnsignedIntegerLiteral) Copy() Node

func (*UnsignedIntegerLiteral) FromBuf

func (*UnsignedIntegerLiteral) NodeType

func (*UnsignedIntegerLiteral) NodeType() string

func (*UnsignedIntegerLiteral) TypeOf

func (e *UnsignedIntegerLiteral) TypeOf() MonoType

type Visitor

type Visitor interface {
	Visit(node Node) Visitor
	Done(node Node)
}

func CreateVisitor

func CreateVisitor(f func(Node)) Visitor

Directories

Path Synopsis
Package semantictest contains utilities for testing the semantic package.
Package semantictest contains utilities for testing the semantic package.

Jump to

Keyboard shortcuts

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