ddptypes

package
v0.5.0-alpha Latest Latest
Warning

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

Go to latest
Published: Nov 2, 2024 License: MIT Imports: 0 Imported by: 1

Documentation

Index

Constants

View Source
const (
	INVALID_GENDER GrammaticalGender = -1
	MASKULIN                         = iota
	FEMININ
	NEUTRUM
)

Variables

View Source
var VARIABLE = Variable{}

Functions

func DeepEqual

func DeepEqual(t1, t2 Type) bool

checks wether t1 equals t2, that is, wether t1 and t2 refer to the same type throughout TypeAliases and TypeDefs and also List Types

func Equal

func Equal(t1, t2 Type) bool

checks wether t1 equals t2, that is, wether t1 and t2 refer to the same type throughout TypeAliases but not TypeDefs

func IsAny

func IsAny(t Type) bool

func IsList

func IsList(t Type) bool

func IsNumeric

func IsNumeric(t Type) bool

func IsPrimitive

func IsPrimitive(t Type) bool

func IsPrimitiveOrVoid

func IsPrimitiveOrVoid(t Type) bool

func IsStruct

func IsStruct(t Type) bool

func IsTypeAlias

func IsTypeAlias(t Type) bool

func IsTypeDef

func IsTypeDef(t Type) bool

func IsVoid

func IsVoid(t Type) bool

func ParamTypesEqual

func ParamTypesEqual(p1, p2 ParameterType) bool

func StructurallyEqual

func StructurallyEqual(t1, t2 *StructType) bool

checks wether two structs are structurally equal, that is their fields have the same type and are in the same order even ignoring TypeDefs

Types

type GrammaticalGender

type GrammaticalGender int

enum Type for the grammatical gender of a type

type ListType

type ListType struct {
	Underlying Type
}

func CastList

func CastList(t Type) (ListType, bool)

acts like primitiveType, ok := t.(ListType) but respects TypeAliases

func (ListType) Gender

func (ListType) Gender() GrammaticalGender

func (ListType) String

func (listType ListType) String() string

type ParameterType

type ParameterType struct {
	Type        Type
	IsReference bool
}

represents the type of a function parameter which may be a reference

func (ParameterType) String

func (paramType ParameterType) String() string

type PrimitiveType

type PrimitiveType int

enum type for primitive types (+ void)

const (
	ZAHL          PrimitiveType = iota // int64
	KOMMAZAHL                          // float64
	WAHRHEITSWERT                      // bool
	BUCHSTABE                          // int32
	TEXT                               // string
)

func CastPrimitive

func CastPrimitive(t Type) (PrimitiveType, bool)

acts like primitiveType, ok := t.(PrimitiveType) but respects TypeAliases

func (PrimitiveType) Gender

func (p PrimitiveType) Gender() GrammaticalGender

func (PrimitiveType) String

func (p PrimitiveType) String() string

type StructField

type StructField struct {
	// name of the field
	Name string
	// type of the field
	Type Type
}

represents a single field of a struct

type StructType

type StructType struct {
	// name of the struct
	Name string
	// grammatical gender of the struct name
	GramGender GrammaticalGender
	// fields of the struct
	// in order of declaration
	Fields []StructField
}

represents the type of a ddp struct

func CastStruct

func CastStruct(t Type) (*StructType, bool)

acts like primitiveType, ok := t.(*StructType) but respects TypeAliases

func (*StructType) Gender

func (t *StructType) Gender() GrammaticalGender

func (*StructType) String

func (t *StructType) String() string

type Type

type Type interface {

	// the grammatical Gender of the Type
	Gender() GrammaticalGender
	// string representation of the type (its name)
	String() string
	// contains filtered or unexported methods
}

holds information about a DDP-Type

func GetListUnderlying

func GetListUnderlying(typ Type) Type

gets the underlying type of a List if typ is not a list it is returned unchanged

func GetNestedListUnderlying

func GetNestedListUnderlying(typ Type) Type

gets the underlying type for nested lists if typ is not a list type typ is returned

func GetUnderlying

func GetUnderlying(t Type) Type

returns the underlying type for nested TypeAliases

func ListTrueUnderlying

func ListTrueUnderlying(typ Type) Type

func TrueUnderlying

func TrueUnderlying(t Type) Type

returns the underlying type for nested TypeAliases and TypeDefs

type TypeAlias

type TypeAlias struct {
	Name       string
	Underlying Type
	GramGender GrammaticalGender
}

a type alias only refers to another type with a new name

func CastTypeAlias

func CastTypeAlias(t Type) (*TypeAlias, bool)

func (*TypeAlias) Gender

func (a *TypeAlias) Gender() GrammaticalGender

func (*TypeAlias) String

func (a *TypeAlias) String() string

type TypeDef

type TypeDef struct {
	Name       string
	Underlying Type
	GramGender GrammaticalGender
}

a typedef defines a new type that is equal to another

func CastTypeDef

func CastTypeDef(t Type) (*TypeDef, bool)

func (*TypeDef) Gender

func (d *TypeDef) Gender() GrammaticalGender

func (*TypeDef) String

func (d *TypeDef) String() string

type Variable

type Variable struct{}

func (Variable) Gender

func (Variable) Gender() GrammaticalGender

func (Variable) String

func (Variable) String() string

type VoidType

type VoidType struct{}

func (VoidType) Gender

func (VoidType) Gender() GrammaticalGender

func (VoidType) String

func (VoidType) String() string

Jump to

Keyboard shortcuts

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