dsl

package
v0.0.0-...-9fc4353 Latest Latest
Warning

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

Go to latest
Published: May 19, 2026 License: MIT Imports: 20 Imported by: 0

Documentation

Index

Constants

View Source
const (
	IncompatibleDefinitions     = "definitions are incompatible"
	IncompatibleTypeParameters  = "type parameters do not match"
	IncompatibleBaseDefinitions = "base definitions are incompatible"
)
View Source
const (
	Bool           = "bool"
	Int8           = "int8"
	Uint8          = "uint8"
	Int16          = "int16"
	Uint16         = "uint16"
	Int32          = "int32"
	Uint32         = "uint32"
	Int64          = "int64"
	Uint64         = "uint64"
	Size           = "size"
	Float32        = "float32"
	Float64        = "float64"
	ComplexFloat32 = "complexfloat32"
	ComplexFloat64 = "complexfloat64"
	String         = "string"
	Date           = "date"
	Time           = "time"
	DateTime       = "datetime"
)
View Source
const (
	FunctionSize           = "size"
	FunctionDimensionIndex = "dimensionIndex"
	FunctionDimensionCount = "dimensionCount"
)

Variables

View Source
var (
	TokenTypeString             = expressionLexer.Symbols()["String"]
	TokenTypeFloat              = expressionLexer.Symbols()["Float"]
	TokenTypeInt                = expressionLexer.Symbols()["Int"]
	TokenTypeAs                 = expressionLexer.Symbols()["As"]
	TokenTypeIdent              = expressionLexer.Symbols()["Ident"]
	TokenTypeOpenParen          = expressionLexer.Symbols()["OpenParen"]
	TokenTypeCloseParen         = expressionLexer.Symbols()["CloseParen"]
	TokenTypeComma              = expressionLexer.Symbols()["Comma"]
	TokenTypeOpenBracket        = expressionLexer.Symbols()["OpenBracket"]
	TokenTypeCloseBracket       = expressionLexer.Symbols()["CloseBracket"]
	TokenTypeDot                = expressionLexer.Symbols()["Dot"]
	TokenTypePow                = expressionLexer.Symbols()["Pow"]
	TokenTypePlus               = expressionLexer.Symbols()["Plus"]
	TokenTypeMinus              = expressionLexer.Symbols()["Minus"]
	TokenTypeStar               = expressionLexer.Symbols()["Star"]
	TokenTypeSlash              = expressionLexer.Symbols()["Slash"]
	TokenTypeColon              = expressionLexer.Symbols()["Colon"]
	TokenTypeUnterminatedString = expressionLexer.Symbols()["UnterminatedString"]
)
View Source
var (
	Zero = big.NewInt(0)

	MaxInt8 = big.NewInt(math.MaxInt8)
	MinInt8 = big.NewInt(math.MinInt8)

	MaxInt16 = big.NewInt(math.MaxInt16)
	MinInt16 = big.NewInt(math.MinInt16)

	MaxInt32 = big.NewInt(math.MaxInt32)
	MinInt32 = big.NewInt(math.MinInt32)

	MaxInt64 = big.NewInt(math.MaxInt64)
	MinInt64 = big.NewInt(math.MinInt64)

	MaxUint8 = big.NewInt(math.MaxUint8)

	MaxUint16 = big.NewInt(math.MaxUint16)

	MaxUint32 = big.NewInt(math.MaxUint32)

	MaxUint64 = func() *big.Int {
		var i big.Int
		i.SetUint64(math.MaxUint64)
		return &i
	}()

	MaxSize = MaxUint64
)
View Source
var (
	Int8Type           = &SimpleType{Name: Int8, ResolvedDefinition: PrimitiveInt8}
	Int16Type          = &SimpleType{Name: Int16, ResolvedDefinition: PrimitiveInt16}
	Int32Type          = &SimpleType{Name: Int32, ResolvedDefinition: PrimitiveInt32}
	Int64Type          = &SimpleType{Name: Int64, ResolvedDefinition: PrimitiveInt64}
	Uint8Type          = &SimpleType{Name: Uint8, ResolvedDefinition: PrimitiveUint8}
	Uint16Type         = &SimpleType{Name: Uint16, ResolvedDefinition: PrimitiveUint16}
	Uint32Type         = &SimpleType{Name: Uint32, ResolvedDefinition: PrimitiveUint32}
	Uint64Type         = &SimpleType{Name: Uint64, ResolvedDefinition: PrimitiveUint64}
	SizeType           = &SimpleType{Name: Size, ResolvedDefinition: PrimitiveSize}
	BoolType           = &SimpleType{Name: Bool, ResolvedDefinition: PrimitiveBool}
	Float32Type        = &SimpleType{Name: Float32, ResolvedDefinition: PrimitiveFloat32}
	Float64Type        = &SimpleType{Name: Float64, ResolvedDefinition: PrimitiveFloat64}
	ComplexFloat32Type = &SimpleType{Name: ComplexFloat32, ResolvedDefinition: PrimitiveComplexFloat32}
	ComplexFloat64Type = &SimpleType{Name: ComplexFloat64, ResolvedDefinition: PrimitiveComplexFloat64}
	StringType         = &SimpleType{Name: String, ResolvedDefinition: PrimitiveString}
)
View Source
var (
	PrimitiveBool           = PrimitiveDefinition(Bool)
	PrimitiveInt8           = PrimitiveDefinition(Int8)
	PrimitiveUint8          = PrimitiveDefinition(Uint8)
	PrimitiveInt16          = PrimitiveDefinition(Int16)
	PrimitiveUint16         = PrimitiveDefinition(Uint16)
	PrimitiveInt32          = PrimitiveDefinition(Int32)
	PrimitiveUint32         = PrimitiveDefinition(Uint32)
	PrimitiveInt64          = PrimitiveDefinition(Int64)
	PrimitiveUint64         = PrimitiveDefinition(Uint64)
	PrimitiveSize           = PrimitiveDefinition(Size)
	PrimitiveFloat32        = PrimitiveDefinition(Float32)
	PrimitiveFloat64        = PrimitiveDefinition(Float64)
	PrimitiveComplexFloat32 = PrimitiveDefinition(ComplexFloat32)
	PrimitiveComplexFloat64 = PrimitiveDefinition(ComplexFloat64)
	PrimitiveString         = PrimitiveDefinition(String)
	PrimitiveDate           = PrimitiveDefinition(Date)
	PrimitiveTime           = PrimitiveDefinition(Time)
	PrimitiveDateTime       = PrimitiveDefinition(DateTime)
)
View Source
var ErrNoCommonType = errors.New("no common type")

Functions

func ExpressionsEqual

func ExpressionsEqual(a, b Expression) bool

func GetPrimitiveWidth

func GetPrimitiveWidth(t PrimitiveDefinition) int

func GetProtocolSchemaString

func GetProtocolSchemaString(protocol *ProtocolDefinition, symbolTable SymbolTable) string

func IsGeneric

func IsGeneric(t TypeDefinition) bool

func IsIntegralPrimitive

func IsIntegralPrimitive(prim PrimitiveDefinition) bool

func IsIntegralType

func IsIntegralType(t Type) bool

func IsSignedPrimitive

func IsSignedPrimitive(prim PrimitiveDefinition) bool

func MkTypeSyntaxRewriter

func MkTypeSyntaxRewriter[TContext any](writer TypeSyntaxWriter[TContext]) func(typeOrTypeDef Node, context TContext) string

func PatternsEqual

func PatternsEqual(a, b Pattern) bool

func TypeContainsGenericTypeParameter

func TypeContainsGenericTypeParameter(node Type) bool

Returns true if the type is generic (not concrete)

func TypeDefinitionsEqual

func TypeDefinitionsEqual(a, b TypeDefinition) bool

func TypeHasNullOption

func TypeHasNullOption(node Type) bool

Returns true if the type is Optional

func TypeToShortSyntax

func TypeToShortSyntax(t Type, qualified bool) string

func TypesEqual

func TypesEqual(a, b Type) bool

func UnmarshalFieldsOrProtocolStepsYAML

func UnmarshalFieldsOrProtocolStepsYAML[T fieldOrProtocolStep](elements *[]*T, value *yaml.Node) error

func Visit

func Visit(root Node, visitorFunc VisitorFunc)

Visits a Node tree from the given root.

func VisitWithContext

func VisitWithContext[T any](root Node, context T, visitor VisitorWithContextFunc[T])

Visits a Node tree from the given root, threading a context parameter throughout.

Types

type AliasRemoved

type AliasRemoved struct {
	DefinitionPair
}

type Array

type Array struct {
	NodeMeta
	Dimensions *ArrayDimensions `json:"dimensions,omitempty"`
}

func (*Array) HasKnownNumberOfDimensions

func (a *Array) HasKnownNumberOfDimensions() bool

func (*Array) IsFixed

func (a *Array) IsFixed() bool

type ArrayDimension

type ArrayDimension struct {
	NodeMeta
	Comment string  `json:"comment,omitempty"`
	Name    *string `json:"name,omitempty"`
	Length  *uint64 `json:"length,omitempty"`
}

func (*ArrayDimension) UnmarshalYAML

func (dimension *ArrayDimension) UnmarshalYAML(value *yaml.Node) error

type ArrayDimensions

type ArrayDimensions []*ArrayDimension

func (ArrayDimensions) MarshalJSON

func (dims ArrayDimensions) MarshalJSON() ([]byte, error)

type BinaryExpression

type BinaryExpression struct {
	NodeMeta
	Left         Expression     `json:"left"`
	Operator     BinaryOperator `json:"op"`
	Right        Expression     `json:"right"`
	ResolvedType Type           `json:"-"`
}

func (*BinaryExpression) GetResolvedType

func (b *BinaryExpression) GetResolvedType() Type

func (*BinaryExpression) IsReference

func (b *BinaryExpression) IsReference() bool

func (*BinaryExpression) MarshalJSON

func (e *BinaryExpression) MarshalJSON() ([]byte, error)

type BinaryOperator

type BinaryOperator int
const (
	BinaryOpAdd BinaryOperator = iota
	BinaryOpSub
	BinaryOpMul
	BinaryOpDiv
	BinaryOpPow
)

func (*BinaryOperator) MarshalJSON

func (op *BinaryOperator) MarshalJSON() ([]byte, error)

func (BinaryOperator) Precedence

func (o BinaryOperator) Precedence() int

type CompatibilityChange

type CompatibilityChange struct {
	DefinitionPair
}

type ComputedField

type ComputedField struct {
	NodeMeta
	Name       string     `json:"name"`
	Comment    string     `json:"comment,omitempty"`
	Expression Expression `json:"expression"`
}

type ComputedFieldScope

type ComputedFieldScope struct {
	Record          *RecordDefinition
	RewrittenFields map[*ComputedField]*ComputedField
	CurrentFields   []*ComputedField
	Variables       []*DeclarationPattern
}

type ComputedFields

type ComputedFields []*ComputedField

func (*ComputedFields) UnmarshalYAML

func (computedFields *ComputedFields) UnmarshalYAML(value *yaml.Node) error

type DeclarationPattern

type DeclarationPattern struct {
	TypePattern
	Identifier string `json:"identifier"`
}

type DefinitionChange

type DefinitionChange interface {
	PreviousDefinition() TypeDefinition
	LatestDefinition() TypeDefinition
}

type DefinitionChangeIncompatible

type DefinitionChangeIncompatible struct {
	DefinitionPair
	Reason string
}

type DefinitionMeta

type DefinitionMeta struct {
	NodeMeta
	Name           string                  `json:"name"`
	Namespace      string                  `json:"-"`
	TypeParameters []*GenericTypeParameter `json:"typeParameters,omitempty"`
	TypeArguments  []Type                  `json:"typeArguments,omitempty"`
	Comment        string                  `json:"comment,omitempty"`
}

---------------------------------------------------------------------------- DefinitionMeta

func (*DefinitionMeta) GetQualifiedName

func (meta *DefinitionMeta) GetQualifiedName() string

func (*DefinitionMeta) UnmarshalYAML

func (meta *DefinitionMeta) UnmarshalYAML(value *yaml.Node) error

type DefinitionPair

type DefinitionPair struct {
	Old TypeDefinition
	New TypeDefinition
}

func (*DefinitionPair) LatestDefinition

func (tc *DefinitionPair) LatestDefinition() TypeDefinition

func (*DefinitionPair) PreviousDefinition

func (tc *DefinitionPair) PreviousDefinition() TypeDefinition

type Dimensionality

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

type DiscardPattern

type DiscardPattern struct {
	NodeMeta
}

type EnumChange

type EnumChange struct {
	DefinitionPair
	BaseTypeChange TypeChange
	ValuesAdded    []string
	ValuesRemoved  []string
	ValuesChanged  []string
}

type EnumDefinition

type EnumDefinition struct {
	*DefinitionMeta `yaml:"-,inline"`
	BaseType        Type       `json:"base,omitempty"`
	IsFlags         bool       `json:"-"`
	Values          EnumValues `json:"values"`
}

---------------------------------------------------------------------------- Enums

func (*EnumDefinition) GetDefinitionMeta

func (e *EnumDefinition) GetDefinitionMeta() *DefinitionMeta

func (*EnumDefinition) GetZeroValue

func (e *EnumDefinition) GetZeroValue() *EnumValue

func (*EnumDefinition) UnmarshalYAML

func (enum *EnumDefinition) UnmarshalYAML(value *yaml.Node) error

type EnumValue

type EnumValue struct {
	NodeMeta
	Symbol       string  `json:"symbol"`
	Comment      string  `json:"comment,omitempty"`
	IntegerValue big.Int `json:"value"`
}

type EnumValues

type EnumValues []*EnumValue

func UnmarshalEnumValues

func UnmarshalEnumValues(flags bool, value *yaml.Node) (*EnumValues, error)

type Environment

type Environment struct {
	Namespaces  []*Namespace `json:"namespaces"`
	SymbolTable SymbolTable  `json:"-"`
}

---------------------------------------------------------------------------- Environment + Namespace

func Validate

func Validate(namespaces []*Namespace) (*Environment, error)

func ValidateEvolution

func ValidateEvolution(latest *Environment, predecessors []*Environment, versionLabels []string) (*Environment, []string, error)

func (*Environment) GetNodeMeta

func (n *Environment) GetNodeMeta() *NodeMeta

func (*Environment) GetTopLevelNamespace

func (n *Environment) GetTopLevelNamespace() *Namespace

type EvolutionContext

type EvolutionContext struct {
	BasePairs     map[string]map[string]*DefinitionPair
	SemanticPairs map[string]map[string]*DefinitionPair
	Changes       map[string]map[string]DefinitionChange
}

type Expression

type Expression interface {
	Node
	GetResolvedType() Type
	IsReference() bool
	// contains filtered or unexported methods
}

func ParseExpression

func ParseExpression(input string, lineOffset, columnOffet int) (Expression, error)

func UnmarshalExpression

func UnmarshalExpression(value *yaml.Node) (Expression, error)

func UnmarshalSwitchExpression

func UnmarshalSwitchExpression(targetNode *yaml.Node, caseNodes []*yaml.Node) (Expression, error)

type Field

type Field struct {
	NodeMeta
	Name    string `json:"name"`
	Comment string `json:"comment,omitempty"`
	Type    Type   `json:"type"`
}

type Fields

type Fields []*Field

---------------------------------------------------------------------------- Fields

func (*Fields) UnmarshalYAML

func (fields *Fields) UnmarshalYAML(value *yaml.Node) error

type FloatingPointLiteralExpression

type FloatingPointLiteralExpression struct {
	NodeMeta
	Value        string
	ResolvedType Type
}

func (*FloatingPointLiteralExpression) GetResolvedType

func (e *FloatingPointLiteralExpression) GetResolvedType() Type

func (*FloatingPointLiteralExpression) IsReference

func (e *FloatingPointLiteralExpression) IsReference() bool

func (*FloatingPointLiteralExpression) MarshalJSON

func (e *FloatingPointLiteralExpression) MarshalJSON() ([]byte, error)

type FunctionCallExpression

type FunctionCallExpression struct {
	NodeMeta
	FunctionName string       `json:"function"`
	Arguments    []Expression `json:"arguments"`
	ResolvedType Type         `json:"-"`
}

func (*FunctionCallExpression) GetResolvedType

func (e *FunctionCallExpression) GetResolvedType() Type

func (*FunctionCallExpression) IsReference

func (e *FunctionCallExpression) IsReference() bool

func (*FunctionCallExpression) MarshalJSON

func (e *FunctionCallExpression) MarshalJSON() ([]byte, error)

type GeneralizedType

type GeneralizedType struct {
	NodeMeta
	Cases          TypeCases
	Dimensionality Dimensionality
}

func ToGeneralizedType

func ToGeneralizedType(t Type) *GeneralizedType

func ToUnionOfUnderlyingTypes

func ToUnionOfUnderlyingTypes(t *GeneralizedType) *GeneralizedType

Convert a Union's TypeCases to their respective underlying Types

func UnmarshalArrayYAML

func UnmarshalArrayYAML(value *yaml.Node) (*GeneralizedType, error)

func UnmarshalMapYAML

func UnmarshalMapYAML(value *yaml.Node) (*GeneralizedType, error)

func UnmarshalStreamYAML

func UnmarshalStreamYAML(value *yaml.Node) (*GeneralizedType, error)

func UnmarshalUnionYAML

func UnmarshalUnionYAML(value *yaml.Node) (*GeneralizedType, error)

func UnmarshalVectorYAML

func UnmarshalVectorYAML(value *yaml.Node) (*GeneralizedType, error)

func (*GeneralizedType) MarshalJSON

func (t *GeneralizedType) MarshalJSON() ([]byte, error)

func (*GeneralizedType) ToScalar

func (t *GeneralizedType) ToScalar() Type

type GenericTypeParameter

type GenericTypeParameter struct {
	NodeMeta
	Name string
}

---------------------------------------------------------------------------- Generics

func (*GenericTypeParameter) GetDefinitionMeta

func (p *GenericTypeParameter) GetDefinitionMeta() *DefinitionMeta

func (*GenericTypeParameter) MarshalJSON

func (t *GenericTypeParameter) MarshalJSON() ([]byte, error)

type IntegerLiteralExpression

type IntegerLiteralExpression struct {
	NodeMeta
	Value        big.Int
	ResolvedType Type
}

func (*IntegerLiteralExpression) GetResolvedType

func (e *IntegerLiteralExpression) GetResolvedType() Type

func (*IntegerLiteralExpression) IsReference

func (e *IntegerLiteralExpression) IsReference() bool

func (*IntegerLiteralExpression) MarshalJSON

func (e *IntegerLiteralExpression) MarshalJSON() ([]byte, error)

type Map

type Map struct {
	NodeMeta
	KeyType Type `json:"keyType"`
}

Map implements Dimensionality on a GeneralizedType. The Value type of the map is the Cases of the GeneralizedType.

type MarshaledBytes

type MarshaledBytes []byte

func (MarshaledBytes) MarshalJSON

func (b MarshaledBytes) MarshalJSON() ([]byte, error)

type MemberAccessExpression

type MemberAccessExpression struct {
	NodeMeta
	Target       Expression       `json:"target,omitempty"`
	Member       string           `json:"member,omitempty"`
	Kind         MemberAccessKind `json:"kind"`
	ResolvedType Type             `json:"-"`
}

func (*MemberAccessExpression) GetResolvedType

func (e *MemberAccessExpression) GetResolvedType() Type

func (*MemberAccessExpression) IsReference

func (e *MemberAccessExpression) IsReference() bool

func (*MemberAccessExpression) MarshalJSON

func (e *MemberAccessExpression) MarshalJSON() ([]byte, error)

type MemberAccessKind

type MemberAccessKind int
const (
	MemberAccessUnknown MemberAccessKind = iota
	MemberAccessField
	MemberAccessComputedField
	MemberAccessVariable
)

func (*MemberAccessKind) MarshalJSON

func (k *MemberAccessKind) MarshalJSON() ([]byte, error)

type NamedType

type NamedType struct {
	*DefinitionMeta
	Type `json:"type"`
}

---------------------------------------------------------------------------- Named types (arrays etc.)

func (*NamedType) GetDefinitionMeta

func (nt *NamedType) GetDefinitionMeta() *DefinitionMeta

func (*NamedType) GetNodeMeta

func (n *NamedType) GetNodeMeta() *NodeMeta

type NamedTypeChange

type NamedTypeChange struct {
	DefinitionPair
	TypeChange TypeChange
}

type Namespace

type Namespace struct {
	Name              string                        `json:"name"`
	TypeDefinitions   TypeDefinitions               `json:"types,omitempty"`
	Protocols         []*ProtocolDefinition         `json:"protocols,omitempty"`
	Versions          []string                      `json:"-"`
	DefinitionChanges map[string][]DefinitionChange `json:"-"`
	References        []*Namespace                  `json:"-"`
	IsTopLevel        bool                          `json:"-"`
}

func ParsePackageContents

func ParsePackageContents(pkgInfo *packaging.PackageInfo) (*Namespace, error)

func ParseYamlInDir

func ParseYamlInDir(path string, namespaceName string) (*Namespace, error)

Parses all model YAML files, combining them into a single Namespace path can be a single YAML file or a directory containing YAML files

func (*Namespace) GetAllChildReferences

func (n *Namespace) GetAllChildReferences() []*Namespace

Returns the flattened set of all direct+indirectly referenced namespaces (e.g. imports)

func (*Namespace) GetNodeMeta

func (n *Namespace) GetNodeMeta() *NodeMeta

func (*Namespace) UnmarshalYAML

func (ns *Namespace) UnmarshalYAML(value *yaml.Node) error

type Node

type Node interface {
	GetNodeMeta() *NodeMeta
}

---------------------------------------------------------------------------- Node

func Rewrite

func Rewrite(node Node, rewriterFunc RewriterFunc) Node

Rewrites a Node by visiting it from the given root. If the given node in an *Environment, the symbol table will be updated.

func RewriteWithContext

func RewriteWithContext[T any](node Node, context T, rewriter RewriterWithContextFunc[T]) Node

Rewrites a Node by visiting it from the given root, threading a context parameter throughout. If the given node in an *Environment, the symbol table will be updated.

type NodeMeta

type NodeMeta struct {
	File        string         `json:"-"`
	Line        int            `json:"-"`
	Column      int            `json:"-"`
	Annotations map[string]any `json:"-"`
}

func (*NodeMeta) Equals

func (n *NodeMeta) Equals(other *NodeMeta) bool

func (*NodeMeta) GetNodeMeta

func (n *NodeMeta) GetNodeMeta() *NodeMeta

func (*NodeMeta) String

func (n *NodeMeta) String() string

type Pattern

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

func UnmarshalPattern

func UnmarshalPattern(patternNode *yaml.Node) (Pattern, error)

type PrimitiveDefinition

type PrimitiveDefinition string

---------------------------------------------------------------------------- Primitive types

func GetPrimitiveType

func GetPrimitiveType(t Type) (primitive PrimitiveDefinition, ok bool)

func (PrimitiveDefinition) GetDefinitionMeta

func (t PrimitiveDefinition) GetDefinitionMeta() *DefinitionMeta

func (PrimitiveDefinition) GetNodeMeta

func (n PrimitiveDefinition) GetNodeMeta() *NodeMeta

type PrimitiveKind

type PrimitiveKind int
const (
	PrimitiveKindInteger PrimitiveKind = iota
	PrimitiveKindFloatingPoint
	PrimitiveKindComplexFloatingPoint
	PrimitiveKindOther
	PrimitiveKindNotPrimitive
)

func GetKindIfPrimitive

func GetKindIfPrimitive(t Type) (primitiveKind PrimitiveKind, ok bool)

func GetPrimitiveKind

func GetPrimitiveKind(t PrimitiveDefinition) PrimitiveKind

type ProtocolChange

type ProtocolChange struct {
	DefinitionPair
	PreviousSchema string
	StepsRemoved   []*ProtocolStep
	StepChanges    []TypeChange
	StepsReordered []*ProtocolStep
}

type ProtocolDefinition

type ProtocolDefinition struct {
	*DefinitionMeta
	Sequence ProtocolSteps              `json:"sequence"`
	Versions map[string]*ProtocolChange `json:"-"`
}

---------------------------------------------------------------------------- Protocols

func (*ProtocolDefinition) GetDefinitionMeta

func (p *ProtocolDefinition) GetDefinitionMeta() *DefinitionMeta

func (*ProtocolDefinition) UnmarshalYAML

func (protocol *ProtocolDefinition) UnmarshalYAML(value *yaml.Node) error

type ProtocolRemoved

type ProtocolRemoved struct {
	DefinitionPair
}

type ProtocolSchema

type ProtocolSchema struct {
	Protocol *ProtocolDefinition `json:"protocol"`
	Types    []TypeDefinition    `json:"types"`
}

func GetProtocolSchema

func GetProtocolSchema(protocol *ProtocolDefinition, symbolTable SymbolTable) *ProtocolSchema

type ProtocolStep

type ProtocolStep Field

func (*ProtocolStep) IsStream

func (s *ProtocolStep) IsStream() bool

type ProtocolSteps

type ProtocolSteps []*ProtocolStep

func (*ProtocolSteps) UnmarshalYAML

func (steps *ProtocolSteps) UnmarshalYAML(value *yaml.Node) error

type RecordChange

type RecordChange struct {
	DefinitionPair
	FieldsAdded   []*Field
	FieldRemoved  []bool
	FieldChanges  []TypeChange
	NewFieldIndex []int
}

type RecordDefinition

type RecordDefinition struct {
	*DefinitionMeta
	Fields         Fields         `json:"fields"`
	ComputedFields ComputedFields `json:"computedFields,omitempty"`
}

---------------------------------------------------------------------------- Records

func (*RecordDefinition) GetDefinitionMeta

func (r *RecordDefinition) GetDefinitionMeta() *DefinitionMeta

func (*RecordDefinition) UnmarshalYAML

func (rec *RecordDefinition) UnmarshalYAML(value *yaml.Node) error

type Rewriter

type Rewriter struct {
	// contains filtered or unexported fields
}

func (*Rewriter) DefaultRewrite

func (rewriter *Rewriter) DefaultRewrite(node Node) Node

func (*Rewriter) Rewrite

func (rewriter *Rewriter) Rewrite(node Node) Node

type RewriterFunc

type RewriterFunc func(self *Rewriter, node Node) Node

type RewriterWithContext

type RewriterWithContext[T any] struct {
	// contains filtered or unexported fields
}

func (*RewriterWithContext[T]) DefaultRewrite

func (rewriter *RewriterWithContext[T]) DefaultRewrite(node Node, context T) Node

func (*RewriterWithContext[T]) Rewrite

func (rewriter *RewriterWithContext[T]) Rewrite(node Node, context T) Node

type RewriterWithContextFunc

type RewriterWithContextFunc[T any] func(node Node, context T, self *RewriterWithContext[T]) Node

type SimpleType

type SimpleType struct {
	NodeMeta
	Name               string
	TypeArguments      []Type
	ResolvedDefinition TypeDefinition
}

func (*SimpleType) MarshalJSON

func (t *SimpleType) MarshalJSON() ([]byte, error)

type SinkWarningOrError

type SinkWarningOrError func(node Node, format string, args ...interface{})

type Stream

type Stream struct {
	NodeMeta
}

type StringLiteralExpression

type StringLiteralExpression struct {
	NodeMeta
	Value        string
	ResolvedType Type
}

func (*StringLiteralExpression) GetResolvedType

func (e *StringLiteralExpression) GetResolvedType() Type

func (*StringLiteralExpression) IsReference

func (e *StringLiteralExpression) IsReference() bool

func (*StringLiteralExpression) MarshalJSON

func (e *StringLiteralExpression) MarshalJSON() ([]byte, error)

type SubscriptArgument

type SubscriptArgument struct {
	NodeMeta
	Label string     `json:"label,omitempty"`
	Value Expression `json:"expression"`
}

type SubscriptExpression

type SubscriptExpression struct {
	NodeMeta
	Target       Expression           `json:"target,omitempty"`
	Arguments    []*SubscriptArgument `json:"arguments"`
	ResolvedType Type                 `json:"-"`
}

func (*SubscriptExpression) GetResolvedType

func (e *SubscriptExpression) GetResolvedType() Type

func (*SubscriptExpression) IsReference

func (e *SubscriptExpression) IsReference() bool

func (*SubscriptExpression) MarshalJSON

func (e *SubscriptExpression) MarshalJSON() ([]byte, error)

type SwitchCase

type SwitchCase struct {
	NodeMeta
	Pattern    Pattern    `json:"pattern"`
	Expression Expression `json:"expression"`
}

type SwitchExpression

type SwitchExpression struct {
	NodeMeta
	Target       Expression    `json:"target"`
	Cases        []*SwitchCase `json:"cases"`
	ResolvedType Type          `json:"-"`
}

func (*SwitchExpression) GetResolvedType

func (e *SwitchExpression) GetResolvedType() Type

func (*SwitchExpression) IsReference

func (e *SwitchExpression) IsReference() bool

func (*SwitchExpression) MarshalJSON

func (e *SwitchExpression) MarshalJSON() ([]byte, error)

type SymbolTable

type SymbolTable map[string]TypeDefinition

func (SymbolTable) Clone

func (st SymbolTable) Clone() SymbolTable

func (SymbolTable) GetGenericTypeDefinition

func (st SymbolTable) GetGenericTypeDefinition(possiblyGenericType TypeDefinition) TypeDefinition

type Type

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

---------------------------------------------------------------------------- Type

func GetCommonType

func GetCommonType(a, b Type) (Type, error)

func GetUnderlyingType

func GetUnderlyingType(t Type) Type

func NormalizeGenericTypeParameters

func NormalizeGenericTypeParameters(t Type) Type

Returns a type where all generic type parameter references are replaces with type parameters with names "T1", "T2", etc.

func UnmarshalGenericNode

func UnmarshalGenericNode(value *yaml.Node) (Type, error)

func UnmarshalTypeYAML

func UnmarshalTypeYAML(value *yaml.Node) (Type, error)

type TypeCase

type TypeCase struct {
	NodeMeta
	Tag         string `json:"tag,omitempty"`
	ExplicitTag bool   `json:"explicitTag,omitempty"`
	Type        Type   `json:"type"`
}

func (*TypeCase) IsNullType

func (tc *TypeCase) IsNullType() bool

func (*TypeCase) MarshalJSON

func (tc *TypeCase) MarshalJSON() ([]byte, error)

type TypeCases

type TypeCases []*TypeCase

func UnmarshalTypeCases

func UnmarshalTypeCases(value *yaml.Node) (TypeCases, error)

func (*TypeCases) HasNullOption

func (tcs *TypeCases) HasNullOption() bool

func (*TypeCases) IsOptional

func (tcs *TypeCases) IsOptional() bool

func (*TypeCases) IsSingle

func (tcs *TypeCases) IsSingle() bool

func (*TypeCases) IsUnion

func (tcs *TypeCases) IsUnion() bool

func (TypeCases) MarshalJSON

func (tcs TypeCases) MarshalJSON() ([]byte, error)

type TypeChange

type TypeChange interface {
	OldType() Type
	NewType() Type
	Inverse() TypeChange
}

type TypeChangeComplexToComplex

type TypeChangeComplexToComplex struct{ TypePair }

func (*TypeChangeComplexToComplex) Inverse

func (tc *TypeChangeComplexToComplex) Inverse() TypeChange

type TypeChangeDefinitionChanged

type TypeChangeDefinitionChanged struct {
	TypePair
	DefinitionChange
}

func (*TypeChangeDefinitionChanged) Inverse

type TypeChangeIncompatible

type TypeChangeIncompatible struct{ TypePair }

func (*TypeChangeIncompatible) Inverse

func (tc *TypeChangeIncompatible) Inverse() TypeChange

type TypeChangeNumberToNumber

type TypeChangeNumberToNumber struct{ TypePair }

func (*TypeChangeNumberToNumber) Inverse

func (tc *TypeChangeNumberToNumber) Inverse() TypeChange

type TypeChangeNumberToString

type TypeChangeNumberToString struct{ TypePair }

func (*TypeChangeNumberToString) Inverse

func (tc *TypeChangeNumberToString) Inverse() TypeChange

type TypeChangeOptionalToScalar

type TypeChangeOptionalToScalar struct{ TypePair }

func (*TypeChangeOptionalToScalar) Inverse

func (tc *TypeChangeOptionalToScalar) Inverse() TypeChange

type TypeChangeOptionalToUnion

type TypeChangeOptionalToUnion struct {
	TypePair
	TypeIndex int
}

func (*TypeChangeOptionalToUnion) Inverse

func (tc *TypeChangeOptionalToUnion) Inverse() TypeChange

type TypeChangeOptionalTypeChanged

type TypeChangeOptionalTypeChanged struct {
	TypePair
	InnerChange TypeChange
}

func (*TypeChangeOptionalTypeChanged) Inverse

type TypeChangeScalarToOptional

type TypeChangeScalarToOptional struct{ TypePair }

func (*TypeChangeScalarToOptional) Inverse

func (tc *TypeChangeScalarToOptional) Inverse() TypeChange

type TypeChangeScalarToUnion

type TypeChangeScalarToUnion struct {
	TypePair
	TypeIndex int
}

func (*TypeChangeScalarToUnion) Inverse

func (tc *TypeChangeScalarToUnion) Inverse() TypeChange

type TypeChangeStepAdded

type TypeChangeStepAdded struct{ TypePair }

func (*TypeChangeStepAdded) Inverse

func (tc *TypeChangeStepAdded) Inverse() TypeChange

type TypeChangeStreamTypeChanged

type TypeChangeStreamTypeChanged struct {
	TypePair
	InnerChange TypeChange
}

func (*TypeChangeStreamTypeChanged) Inverse

type TypeChangeStringToNumber

type TypeChangeStringToNumber struct{ TypePair }

func (*TypeChangeStringToNumber) Inverse

func (tc *TypeChangeStringToNumber) Inverse() TypeChange

type TypeChangeUnionToOptional

type TypeChangeUnionToOptional struct {
	TypePair
	TypeIndex int
}

func (*TypeChangeUnionToOptional) Inverse

func (tc *TypeChangeUnionToOptional) Inverse() TypeChange

type TypeChangeUnionToScalar

type TypeChangeUnionToScalar struct {
	TypePair
	TypeIndex int
}

func (*TypeChangeUnionToScalar) Inverse

func (tc *TypeChangeUnionToScalar) Inverse() TypeChange

type TypeChangeUnionTypesetChanged

type TypeChangeUnionTypesetChanged struct {
	TypePair
	OldMatches []bool
	NewMatches []bool
}

func (*TypeChangeUnionTypesetChanged) Inverse

type TypeChangeVectorTypeChanged

type TypeChangeVectorTypeChanged struct {
	TypePair
	InnerChange TypeChange
}

func (*TypeChangeVectorTypeChanged) Inverse

type TypeConversionExpression

type TypeConversionExpression struct {
	NodeMeta
	Expression Expression `json:"expression"`
	Type       Type       `json:"type"`
}

func (*TypeConversionExpression) GetResolvedType

func (e *TypeConversionExpression) GetResolvedType() Type

func (*TypeConversionExpression) IsReference

func (e *TypeConversionExpression) IsReference() bool

func (*TypeConversionExpression) MarshalJSON

func (e *TypeConversionExpression) MarshalJSON() ([]byte, error)

type TypeDefinition

type TypeDefinition interface {
	Node
	GetDefinitionMeta() *DefinitionMeta
}

---------------------------------------------------------------------------- TypeDefinition

func MakeGenericType

func MakeGenericType(genericTypeDefinition TypeDefinition, typeArguments []Type, shallow bool) (TypeDefinition, error)

func UnmarshalTypeDefinition

func UnmarshalTypeDefinition(value *yaml.Node, definitionMeta *DefinitionMeta) (TypeDefinition, error)

type TypeDefinitions

type TypeDefinitions []TypeDefinition

func (*TypeDefinitions) MarshalJSON

func (tc *TypeDefinitions) MarshalJSON() ([]byte, error)

type TypePair

type TypePair struct {
	Old Type
	New Type
}

func (*TypePair) NewType

func (tc *TypePair) NewType() Type

func (*TypePair) OldType

func (tc *TypePair) OldType() Type

func (TypePair) Swap

func (tc TypePair) Swap() TypePair

type TypePattern

type TypePattern struct {
	NodeMeta
	Type Type `json:"type"`
}

type TypeSyntaxWriter

type TypeSyntaxWriter[TContext any] func(self TypeSyntaxWriter[TContext], typeOrTypeDef Node, context TContext) string

func (TypeSyntaxWriter[TContext]) ToSyntax

func (writer TypeSyntaxWriter[TContext]) ToSyntax(typeOrTypeDef Node, context TContext) string

type UnaryExpression

type UnaryExpression struct {
	NodeMeta
	Operator   UnaryOperator `json:"op"`
	Expression Expression    `json:"expression"`
}

func (*UnaryExpression) GetResolvedType

func (e *UnaryExpression) GetResolvedType() Type

func (*UnaryExpression) IsReference

func (e *UnaryExpression) IsReference() bool

func (*UnaryExpression) MarshalJSON

func (e *UnaryExpression) MarshalJSON() ([]byte, error)

type UnaryOperator

type UnaryOperator int
const (
	UnaryOpNegate UnaryOperator = iota
)

type ValidationPass

type ValidationPass func(env *Environment, errorSink *validation.ErrorSink) *Environment

type Vector

type Vector struct {
	NodeMeta
	Length *uint64 `json:"length,omitempty"`
}

func (*Vector) IsFixed

func (v *Vector) IsFixed() bool

type Visitor

type Visitor struct {
	// contains filtered or unexported fields
}

func (Visitor) Visit

func (visitor Visitor) Visit(node Node)

func (Visitor) VisitChildren

func (visitor Visitor) VisitChildren(node Node)

type VisitorFunc

type VisitorFunc func(self Visitor, node Node)

type VisitorWithContext

type VisitorWithContext[T any] struct {
	// contains filtered or unexported fields
}

func (VisitorWithContext[T]) Visit

func (visitor VisitorWithContext[T]) Visit(node Node, context T)

func (VisitorWithContext[T]) VisitChildren

func (visitor VisitorWithContext[T]) VisitChildren(node Node, context T)

type VisitorWithContextFunc

type VisitorWithContextFunc[T any] func(self VisitorWithContext[T], node Node, context T)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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