parser

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Apr 28, 2024 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 interface {
	Name() *NamedType
	Instantiate(params []Type) Type
}

type TypeDeclarations

func (*TypeDeclarations) Merge added in v0.4.0

func (td *TypeDeclarations) Merge(other *TypeDeclarations)

type TypeFuncDecl

type TypeFuncDecl struct {
	DefinedIn  string
	ImportPath string
	Name       string
	TypeParams []*TypeParam
	Body       *FuncType
}

func (*TypeFuncDecl) Expr

func (fn *TypeFuncDecl) Expr(imports *Imports) string

func (*TypeFuncDecl) GenericExpr

func (fn *TypeFuncDecl) GenericExpr(imports *Imports, backtype bool) string

func (*TypeFuncDecl) IsOpaque added in v0.3.0

func (fn *TypeFuncDecl) IsOpaque() bool

func (*TypeFuncDecl) PlainName

func (fn *TypeFuncDecl) PlainName() string

func (*TypeFuncDecl) Require

func (fn *TypeFuncDecl) Require() []string

type TypeInterfaceDecl

type TypeInterfaceDecl struct {
	DefinedIn  string
	ImportPath string
	Name       string
	TypeParams []*TypeParam
	Body       *InterfaceType
}

func (*TypeInterfaceDecl) Expr

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

func (*TypeInterfaceDecl) GenericExpr

func (s *TypeInterfaceDecl) GenericExpr(imports *Imports, backtype bool) string

func (*TypeInterfaceDecl) IsOpaque added in v0.3.0

func (in *TypeInterfaceDecl) IsOpaque() bool

func (*TypeInterfaceDecl) PlainName

func (s *TypeInterfaceDecl) PlainName() string

func (*TypeInterfaceDecl) Require

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

type TypeNameDecl added in v0.4.0

type TypeNameDecl struct {
	DefinedIn  string
	ImportPath string
	Name       string
	TypeParams []*TypeParam
	Body       *NamedType
}

func (*TypeNameDecl) Expr added in v0.4.0

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

func (*TypeNameDecl) GenericExpr added in v0.4.0

func (n *TypeNameDecl) GenericExpr(imports *Imports, backtype bool) string

func (*TypeNameDecl) IsOpaque added in v0.4.0

func (fn *TypeNameDecl) IsOpaque() bool

func (*TypeNameDecl) Require added in v0.4.0

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

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 TypeStructDecl

type TypeStructDecl struct {
	DefinedIn  string
	ImportPath string
	Name       string
	TypeParams []*TypeParam
	Body       *StructType
}

func (*TypeStructDecl) Expr

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

func (*TypeStructDecl) GenericExpr

func (s *TypeStructDecl) GenericExpr(imports *Imports, backtype bool) string

func (*TypeStructDecl) InstantiateName added in v0.4.0

func (s *TypeStructDecl) InstantiateName(typeParams []Type) *NamedType

func (*TypeStructDecl) IsOpaque added in v0.3.0

func (s *TypeStructDecl) IsOpaque() bool

func (*TypeStructDecl) Require

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

type TypeUnresolvedDecl added in v0.4.0

type TypeUnresolvedDecl struct {
	DefinedIn  string
	ImportPath string
	Name       string
	TypeParams []*TypeParam
	Body       *unknwonType
}

func (*TypeUnresolvedDecl) Expr added in v0.4.0

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

func (*TypeUnresolvedDecl) GenericExpr added in v0.4.0

func (n *TypeUnresolvedDecl) GenericExpr(imports *Imports, backtype bool) string

func (*TypeUnresolvedDecl) IsOpaque added in v0.4.0

func (fn *TypeUnresolvedDecl) IsOpaque() bool

func (*TypeUnresolvedDecl) Require added in v0.4.0

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

Jump to

Keyboard shortcuts

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