parser

package
v0.6.3 Latest Latest
Warning

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

Go to latest
Published: Jun 29, 2025 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ArrayType

type ArrayType struct {
	Len  int
	Elem Type
}

func (*ArrayType) Expr

func (a *ArrayType) Expr(imports *Imports) string

func (*ArrayType) IsOpaque added in v0.3.0

func (a *ArrayType) IsOpaque() bool

func (*ArrayType) Require

func (a *ArrayType) Require() []string

type ChanType

type ChanType struct {
	Dir  ast.ChanDir
	Elem Type
}

func (*ChanType) Expr

func (ch *ChanType) Expr(imports *Imports) string

func (*ChanType) IsOpaque added in v0.3.0

func (ch *ChanType) IsOpaque() bool

func (*ChanType) Require

func (ch *ChanType) Require() []string

type Field

type Field struct {
	Name string
	Type Type
}

func (Field) IsOpaque added in v0.3.0

func (f Field) IsOpaque() bool

type FuncIOParam

type FuncIOParam struct {
	ParamName string
	Type      Type
	Variadic  bool
}

func (*FuncIOParam) Expr

func (fio *FuncIOParam) Expr(imports *Imports) string

func (*FuncIOParam) ExprWithName

func (fio *FuncIOParam) ExprWithName(imports *Imports, defaultName string) string

func (*FuncIOParam) IsNamed

func (f *FuncIOParam) IsNamed() bool

func (*FuncIOParam) IsOpaque added in v0.3.0

func (fio *FuncIOParam) IsOpaque() bool

func (*FuncIOParam) ParamNameOr

func (f *FuncIOParam) ParamNameOr(defaultValue string) string

func (*FuncIOParam) Require

func (fio *FuncIOParam) Require() []string

type FuncType

type FuncType struct {
	Args    []*FuncIOParam
	VarArg  *FuncIOParam
	Returns []*FuncIOParam
}

func (*FuncType) Expr

func (c *FuncType) Expr(imports *Imports) string

func (*FuncType) IsOpaque added in v0.3.0

func (f *FuncType) IsOpaque() bool

func (*FuncType) Require

func (f *FuncType) Require() []string

func (*FuncType) Signature

func (c *FuncType) Signature(imports *Imports, nameSupply bool) string

type ImportStatment added in v0.4.0

type ImportStatment struct {
	Name string
	Path string
}

type Imports added in v0.4.0

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

func (*Imports) Add added in v0.4.0

func (imp *Imports) Add(importPath string)

func (*Imports) GetName added in v0.4.0

func (imp *Imports) GetName(importPath string) string

func (*Imports) Slice added in v0.4.0

func (imp *Imports) Slice() []ImportStatment

type InterfaceType

type InterfaceType struct {
	Methods  []*Method
	Embedded []Type
}

func (*InterfaceType) Expr

func (i *InterfaceType) Expr(imports *Imports) string

func (*InterfaceType) Inlined added in v0.4.0

func (in *InterfaceType) Inlined(bc ParseContext) (*InterfaceType, error)

func (*InterfaceType) IsOpaque added in v0.3.0

func (in *InterfaceType) IsOpaque() bool

func (*InterfaceType) PlainName

func (*InterfaceType) PlainName() string

func (*InterfaceType) Require

func (in *InterfaceType) Require() []string

type MapType

type MapType struct {
	Key  Type
	Elem Type
}

func (*MapType) Expr

func (m *MapType) Expr(imports *Imports) string

func (*MapType) IsOpaque added in v0.3.0

func (m *MapType) IsOpaque() bool

func (*MapType) PlainName

func (*MapType) PlainName() string

func (*MapType) Require

func (m *MapType) Require() []string

type Method

type Method struct {
	Name string
	Func *FuncType
}

func (*Method) IsOpaque added in v0.3.0

func (m *Method) IsOpaque() bool

type NamedType

type NamedType struct {
	ImportPath string
	Name       string
	Params     []Type
}

func (*NamedType) Expr

func (n *NamedType) Expr(imports *Imports) string

func (*NamedType) IsOpaque added in v0.3.0

func (nt *NamedType) IsOpaque() bool

func (NamedType) PlainName

func (n NamedType) PlainName() string

func (*NamedType) Require

func (n *NamedType) Require() []string

func (*NamedType) TypeParams

func (*NamedType) TypeParams() []*TypeParam

type Namespace added in v0.4.0

type Namespace struct {
	TypeParam []*TypeParam
	Local     *Package
	DotImport []*Package
}

type Package added in v0.4.0

type Package struct {
	DefaultName string
	Path        string
	Src         string
	Types       *TypeDeclarations
}

type ParseContext added in v0.4.0

type ParseContext interface {
	Import(importPath string) (*Package, error)
	ImportDir(pkgDir string) (*Package, error)
}

func New added in v0.4.0

func New() (ParseContext, error)

type ParseError added in v0.4.0

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

func (*ParseError) Error added in v0.4.0

func (pe *ParseError) Error() string

func (*ParseError) Expr added in v0.4.0

func (*ParseError) Expr(*Imports) string

func (*ParseError) IsOpaque added in v0.4.0

func (pe *ParseError) IsOpaque() bool

func (*ParseError) Require added in v0.4.0

func (pe *ParseError) Require() []string

func (*ParseError) TypeParams added in v0.4.0

func (pe *ParseError) TypeParams() []*TypeParam

type PointerType

type PointerType struct {
	Elem Type
}

func (*PointerType) Expr

func (ptr *PointerType) Expr(imports *Imports) string

func (*PointerType) IsOpaque added in v0.3.0

func (ptr *PointerType) IsOpaque() bool

func (*PointerType) Require

func (ptr *PointerType) Require() []string

type SliceType

type SliceType struct {
	Elem Type
}

func (*SliceType) Expr

func (s *SliceType) Expr(imports *Imports) string

func (*SliceType) IsOpaque added in v0.3.0

func (s *SliceType) IsOpaque() bool

func (*SliceType) Require

func (s *SliceType) Require() []string

type StructType

type StructType struct {
	Fields []*Field
}

func (*StructType) Expr

func (l *StructType) Expr(imports *Imports) string

func (*StructType) IsOpaque added in v0.3.0

func (s *StructType) IsOpaque() bool

func (*StructType) PlainName

func (s *StructType) PlainName() string

func (*StructType) Require

func (s *StructType) Require() []string

type Type

type Type interface {
	Expr(*Imports) string
	Require() []string
	IsOpaque() bool
	// contains filtered or unexported methods
}

type TypeConstraint

type TypeConstraint struct {
	Op   string
	Type Type
}

func (*TypeConstraint) Expr

func (tc *TypeConstraint) Expr(imports *Imports) string

func (*TypeConstraint) IsOpaque added in v0.3.0

func (tc *TypeConstraint) IsOpaque() bool

func (*TypeConstraint) Require

func (tc *TypeConstraint) Require() []string

type TypeDecl added in v0.4.0

type TypeDecl[B Type] struct {
	DefinedIn  string
	ImportPath string
	Name       string
	TypeParams []*TypeParam
	Body       B
}

func (*TypeDecl[B]) Expr added in v0.5.0

func (s *TypeDecl[B]) Expr(imports *Imports) string

func (*TypeDecl[B]) GenericExpr added in v0.5.0

func (s *TypeDecl[B]) GenericExpr(imports *Imports, backtype bool) string

func (*TypeDecl[B]) InstantiateName added in v0.5.0

func (s *TypeDecl[B]) InstantiateName(typeParams []Type) *NamedType

func (*TypeDecl[B]) IsOpaque added in v0.5.0

func (s *TypeDecl[B]) IsOpaque() bool

func (*TypeDecl[B]) Require added in v0.5.0

func (s *TypeDecl[B]) Require() []string

type TypeDeclarations

func (*TypeDeclarations) Merge added in v0.4.0

func (tds *TypeDeclarations) Merge(other *TypeDeclarations)

Merge merges other into tds

type TypeParam

type TypeParam struct {
	Name       string
	Constraint Type
}

func (*TypeParam) Expr

func (t *TypeParam) Expr(*Imports) string

func (*TypeParam) IsOpaque added in v0.3.0

func (t *TypeParam) IsOpaque() bool

func (*TypeParam) Require

func (t *TypeParam) Require() []string

type TypeUnion

type TypeUnion struct {
	Op string
	X  Type
	Y  Type
}

func (*TypeUnion) Expr

func (uni *TypeUnion) Expr(imports *Imports) string

func (*TypeUnion) IsOpaque added in v0.3.0

func (uni *TypeUnion) IsOpaque() bool

func (*TypeUnion) Require

func (uni *TypeUnion) Require() []string

Jump to

Keyboard shortcuts

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