gc

package module
v1.0.7 Latest Latest
Warning

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

Go to latest
Published: May 7, 2026 License: BSD-3-Clause Imports: 18 Imported by: 0

README

gc

Package GC is a Go compiler front end. (Work in progress, API unstable)

Installation

$ go get github.com/next-bin/go-sqlite3/pkg/gc2

Documentation: pkg.go.dev/github.com/next-bin/go-sqlite3/pkg/gc2

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (

	// ExtendedErrors optionally amends errors with a stack mini trace. Intended
	// for debugging only.
	ExtendedErrors bool
)
View Source
var Keywords = map[string]Ch{
	"break":       BREAK,
	"case":        CASE,
	"chan":        CHAN,
	"const":       CONST,
	"continue":    CONTINUE,
	"default":     DEFAULT,
	"defer":       DEFER,
	"else":        ELSE,
	"fallthrough": FALLTHROUGH,
	"for":         FOR,
	"func":        FUNC,
	"go":          GO,
	"goto":        GOTO,
	"if":          IF,
	"import":      IMPORT,
	"interface":   INTERFACE,
	"map":         MAP,
	"package":     PACKAGE,
	"range":       RANGE,
	"return":      RETURN,
	"select":      SELECT,
	"struct":      STRUCT,
	"switch":      SWITCH,
	"type":        TYPE,
	"var":         VAR,
}

Keywords represents the mapping of identifiers to Go reserved names.

Functions

This section is empty.

Types

type ABI

type ABI struct {
	ByteOrder binary.ByteOrder

	Types map[Kind]AbiType
	// contains filtered or unexported fields
}

ABI describes selected parts of the Application Binary Interface.

func NewABI

func NewABI(os, arch string) (*ABI, error)

NewABI creates an ABI based on the os+arch pair.

type AbiType

type AbiType struct {
	Size       int64
	Align      int
	FieldAlign int
}

type AliasDecl

type AliasDecl struct {
	Ident     Token
	Eq        Token
	TypeNode  Node
	Semicolon Token
	// contains filtered or unexported fields
}

AliasDecl describes a type alias.

AliasDecl = identifier "=" Type .

func (AliasDecl) IsUncheckedType

func (t AliasDecl) IsUncheckedType() bool

IsUncheckedType returns true when a type check of a Node was not performed.

func (AliasDecl) LexicalScope

func (n AliasDecl) LexicalScope() *Scope

LexicalScope returns the lexical scope n appears in.

func (*AliasDecl) Position

func (n *AliasDecl) Position() (r token.Position)

Position implements Node.

func (*AliasDecl) Source

func (n *AliasDecl) Source(full bool) []byte

Source implements Node.

func (*AliasDecl) Tokens

func (n *AliasDecl) Tokens() []Token

Tokens returns the tokens n consist of.

func (AliasDecl) Type

func (t AliasDecl) Type() Type

Type returns the type of a node or Invalid if the type is unknown/undetermined.

type AliasType

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

AliasType represents an alias type.

func (AliasType) IsUncheckedType

func (t AliasType) IsUncheckedType() bool

IsUncheckedType returns true when a type check of a Node was not performed.

func (*AliasType) Kind

func (t *AliasType) Kind() Kind

Kind implements Type.

func (*AliasType) Position

func (t *AliasType) Position() (r token.Position)

Position implements Node.

func (AliasType) Source

func (AliasType) Source(bool) []byte

Source implements Node. It returns nil.

func (*AliasType) String

func (t *AliasType) String() string

func (AliasType) Tokens

func (AliasType) Tokens() []Token

Tokens implements Node. It returns nil.

func (AliasType) Type

func (t AliasType) Type() Type

Type returns the type of a node or Invalid if the type is unknown/undetermined.

type Arguments

type Arguments struct {
	PrimaryExpr Expression
	LParen      Token
	TypeArg     Node
	Comma       Token
	ExprList    []*ExprListItem
	Ellipsis    Token
	Comma2      Token
	RParen      Token
	// contains filtered or unexported fields
}

Arguments describes a call or conversion.

Arguments = PrimaryExpr "(" [ ( ExpressionList | Type [ "," ExpressionList ] ) [ "..." ] [ "," ] ] ")" .

func (Arguments) IsUncheckedType

func (t Arguments) IsUncheckedType() bool

IsUncheckedType returns true when a type check of a Node was not performed.

func (*Arguments) Position

func (n *Arguments) Position() (r token.Position)

Position implements Node.

func (*Arguments) SetValue

func (v *Arguments) SetValue(val constant.Value)

SetValue implements Expression

func (*Arguments) Source

func (n *Arguments) Source(full bool) []byte

Source implements Node.

func (*Arguments) Tokens

func (n *Arguments) Tokens() []Token

Tokens returns the tokens n consist of.

func (Arguments) Type

func (t Arguments) Type() Type

Type returns the type of a node or Invalid if the type is unknown/undetermined.

func (Arguments) Value

func (v Arguments) Value() constant.Value

Value implements Expression

type ArrayType

type ArrayType struct {
	Elem Type
	Len  int64
	// contains filtered or unexported fields
}

ArrayType represents an array type.

func (*ArrayType) Kind

func (t *ArrayType) Kind() Kind

Kind implements Type.

func (*ArrayType) Position

func (t *ArrayType) Position() (r token.Position)

Position implements Node.

func (ArrayType) Source

func (ArrayType) Source(bool) []byte

Source implements Node. It returns nil.

func (*ArrayType) String

func (t *ArrayType) String() string

func (ArrayType) Tokens

func (ArrayType) Tokens() []Token

Tokens implements Node. It returns nil.

type ArrayTypeNode

type ArrayTypeNode struct {
	LBracket    Token
	ArrayLength Expression
	Ellipsis    Token
	RBracket    Token
	ElementType Node
	// contains filtered or unexported fields
}

ArrayTypeNode describes a channel type.

ArrayType   = "[" ArrayLength "]" ElementType .
ArrayLength = Expression | "..."

func (ArrayTypeNode) IsUncheckedType

func (t ArrayTypeNode) IsUncheckedType() bool

IsUncheckedType returns true when a type check of a Node was not performed.

func (*ArrayTypeNode) Position

func (n *ArrayTypeNode) Position() (r token.Position)

Position implements Node.

func (*ArrayTypeNode) Source

func (n *ArrayTypeNode) Source(full bool) []byte

Source implements Node.

func (*ArrayTypeNode) Tokens

func (n *ArrayTypeNode) Tokens() []Token

Tokens returns the tokens n consist of.

func (ArrayTypeNode) Type

func (t ArrayTypeNode) Type() Type

Type returns the type of a node or Invalid if the type is unknown/undetermined.

type Assignment

type Assignment struct {
	LExprList []*ExprListItem
	AssOp     Token
	RExprList []*ExprListItem
	Semicolon Token
	// contains filtered or unexported fields
}

Assignment describes a short variable declaration.

Assignment = ExpressionList assign_op ExpressionList .

func (*Assignment) Position

func (n *Assignment) Position() (r token.Position)

Position implements Node.

func (*Assignment) Source

func (n *Assignment) Source(full bool) []byte

Source implements Node.

func (*Assignment) Tokens

func (n *Assignment) Tokens() []Token

Tokens returns the tokens n consist of.

type BasicLit

type BasicLit struct {
	Token Token
	// contains filtered or unexported fields
}

BasicLit represents a basic literal.

func (BasicLit) IsUncheckedType

func (t BasicLit) IsUncheckedType() bool

IsUncheckedType returns true when a type check of a Node was not performed.

func (*BasicLit) Position

func (n *BasicLit) Position() (r token.Position)

Position implements Node.

func (*BasicLit) SetValue

func (v *BasicLit) SetValue(val constant.Value)

SetValue implements Expression

func (*BasicLit) Source

func (n *BasicLit) Source(full bool) []byte

Source implements Node.

func (*BasicLit) Tokens

func (n *BasicLit) Tokens() []Token

Tokens returns the tokens n consist of.

func (BasicLit) Type

func (t BasicLit) Type() Type

Type returns the type of a node or Invalid if the type is unknown/undetermined.

func (BasicLit) Value

func (v BasicLit) Value() constant.Value

Value implements Expression

type BinaryExpr

type BinaryExpr struct {
	A  Expression
	Op Token
	B  Expression
	// contains filtered or unexported fields
}

BinaryExpr describes a binary expression.

func (BinaryExpr) IsUncheckedType

func (t BinaryExpr) IsUncheckedType() bool

IsUncheckedType returns true when a type check of a Node was not performed.

func (*BinaryExpr) Position

func (n *BinaryExpr) Position() (r token.Position)

Position implements Node.

func (*BinaryExpr) SetValue

func (v *BinaryExpr) SetValue(val constant.Value)

SetValue implements Expression

func (*BinaryExpr) Source

func (n *BinaryExpr) Source(full bool) []byte

Source implements Node.

func (*BinaryExpr) Tokens

func (n *BinaryExpr) Tokens() []Token

Tokens returns the tokens n consist of.

func (BinaryExpr) Type

func (t BinaryExpr) Type() Type

Type returns the type of a node or Invalid if the type is unknown/undetermined.

func (BinaryExpr) Value

func (v BinaryExpr) Value() constant.Value

Value implements Expression

type Block

type Block struct {
	LBrace        Token
	StatementList []Node
	RBrace        Token
	Semicolon     Token
	Scope         *Scope
}

Block describes a compound statement.

Block = "{" StatementList "}" .

func (*Block) Position

func (n *Block) Position() (r token.Position)

Position implements Node.

func (*Block) Source

func (n *Block) Source(full bool) []byte

Source implements Node.

func (*Block) Tokens

func (n *Block) Tokens() []Token

Tokens returns the tokens n consist of.

type BreakStmt

type BreakStmt struct {
	Break     Token
	Label     Token
	Semicolon Token
}

BreakStmt describes a continue statement.

BreakStmt = "break" [ Label ] .

func (*BreakStmt) Position

func (n *BreakStmt) Position() (r token.Position)

Position implements Node.

func (*BreakStmt) Source

func (n *BreakStmt) Source(full bool) []byte

Source implements Node.

func (*BreakStmt) Tokens

func (n *BreakStmt) Tokens() []Token

Tokens returns the tokens n consist of.

type Ch

type Ch rune

Ch represents the lexical value of a Token. Valid values of type Ch are non-zero.

const (
	ADD_ASSIGN     Ch // +=
	AND_ASSIGN        // &=
	AND_NOT           // &^
	AND_NOT_ASSIGN    // &^=
	ARROW             // <-
	BREAK             // break
	CASE              // case
	CHAN              // chan
	CONST             // const
	CONTINUE          // continue
	DEC               // --
	DEFAULT           // default
	DEFER             // defer
	DEFINE            // :=
	ELLIPSIS          // ...
	ELSE              // else
	EOF               // end of file
	EQ                // ==
	FALLTHROUGH       // fallthrough
	FLOAT_LIT         // floating point literal
	FOR               // for
	FUNC              // func
	GE                // >=
	GO                // go
	GOTO              // goto
	IDENTIFIER        // identifier
	IF                // if
	IMAG_LIT          // imaginary literal
	IMPORT            // import
	INC               // ++
	INTERFACE         // interface
	INT_LIT           // integer literal
	LAND              // &&
	LE                // <=
	LOR               // ||
	MAP               // map
	MUL_ASSIGN        // *=
	NE                // !=
	OR_ASSIGN         // |=
	PACKAGE           // package
	QUO_ASSIGN        // /=
	RANGE             // range
	REM_ASSIGN        // %=
	RETURN            // return
	RUNE_LIT          // rune literal
	SELECT            // select
	SHL               // <<
	SHL_ASSIGN        // <<=
	SHR               // >>
	SHR_ASSIGN        // >>=
	STRING_LIT        // string literal
	STRUCT            // struct
	SUB_ASSIGN        // -=
	SWITCH            // switch
	TILDE             // ~
	TYPE              // type
	VAR               // var
	XOR_ASSIGN        // ^=

)

Named values of Ch.

func (Ch) String

func (i Ch) String() string

type ChanDir

type ChanDir int

ChanDir represents a channel direction.

const (
	SendRecv ChanDir = iota
	SendOnly
	RecvOnly
)

Values of type ChanDir.

type ChannelType

type ChannelType struct {
	Dir  ChanDir
	Elem Type
	// contains filtered or unexported fields
}

ChannelType represents a channel type.

func (*ChannelType) Kind

func (t *ChannelType) Kind() Kind

Kind implements Type.

func (*ChannelType) Position

func (t *ChannelType) Position() (r token.Position)

Position implements Node.

func (ChannelType) Source

func (ChannelType) Source(bool) []byte

Source implements Node. It returns nil.

func (*ChannelType) String

func (t *ChannelType) String() string

func (ChannelType) Tokens

func (ChannelType) Tokens() []Token

Tokens implements Node. It returns nil.

type ChannelTypeNode

type ChannelTypeNode struct {
	ArrowPre    Token
	Chan        Token
	ArrayPost   Token
	ElementType Node
	// contains filtered or unexported fields
}

ChannelTypeNode describes a channel type.

ChannelTypeNode = ( "chan" | "chan" "<-" | "<-" "chan" ) ElementType .

func (*ChannelTypeNode) Position

func (n *ChannelTypeNode) Position() (r token.Position)

Position implements Node.

func (*ChannelTypeNode) Source

func (n *ChannelTypeNode) Source(full bool) []byte

Source implements Node.

func (*ChannelTypeNode) Tokens

func (n *ChannelTypeNode) Tokens() []Token

Tokens returns the tokens n consist of.

type CommCase

type CommCase struct {
	CaseOrDefault Token
	Statement     Node
}

CommCase describes an communication clause case.

CommCase   = "case" ( SendStmt | RecvStmt ) | "default" .

func (*CommCase) Position

func (n *CommCase) Position() (r token.Position)

Position implements Node.

func (*CommCase) Source

func (n *CommCase) Source(full bool) []byte

Source implements Node.

func (*CommCase) Tokens

func (n *CommCase) Tokens() []Token

Tokens returns the tokens n consist of.

type CommClause

type CommClause struct {
	CommCase      *CommCase
	Colon         Token
	StatementList []Node
}

CommClause describes an select statement communication clause.

CommClause = CommCase ":" StatementList .

func (*CommClause) Position

func (n *CommClause) Position() (r token.Position)

Position implements Node.

func (*CommClause) Source

func (n *CommClause) Source(full bool) []byte

Source implements Node.

func (*CommClause) Tokens

func (n *CommClause) Tokens() []Token

Tokens returns the tokens n consist of.

type CompositeLit

type CompositeLit struct {
	LiteralType  Node
	LiteralValue *LiteralValue
	// contains filtered or unexported fields
}

CompositeLit describes a composite literal.

CompositeLit = LiteralType LiteralValue .

func (CompositeLit) IsUncheckedType

func (t CompositeLit) IsUncheckedType() bool

IsUncheckedType returns true when a type check of a Node was not performed.

func (*CompositeLit) Position

func (n *CompositeLit) Position() (r token.Position)

Position implements Node.

func (*CompositeLit) SetValue

func (v *CompositeLit) SetValue(val constant.Value)

SetValue implements Expression

func (*CompositeLit) Source

func (n *CompositeLit) Source(full bool) []byte

Source implements Node.

func (*CompositeLit) Tokens

func (n *CompositeLit) Tokens() []Token

Tokens returns the tokens n consist of.

func (CompositeLit) Type

func (t CompositeLit) Type() Type

Type returns the type of a node or Invalid if the type is unknown/undetermined.

func (CompositeLit) Value

func (v CompositeLit) Value() constant.Value

Value implements Expression

type ConstDecl

type ConstDecl struct {
	Const      Token
	LParen     Token
	ConstSpecs []*ConstSpec
	RParen     Token
	Semicolon  Token
}

ConstDecl describes a constant declaration.

ConstDecl = "const" ( ConstSpec | "(" { ConstSpec ";" } ")" ) .

func (*ConstDecl) Position

func (n *ConstDecl) Position() (r token.Position)

Position implements Node.

func (*ConstDecl) Source

func (n *ConstDecl) Source(full bool) []byte

Source implements Node.

func (*ConstDecl) Tokens

func (n *ConstDecl) Tokens() []Token

Tokens returns the tokens n consist of.

type ConstSpec

type ConstSpec struct {
	IdentifierList []*IdentListItem
	Type           Node
	Eq             Token
	ExprList       []*ExprListItem
	Semicolon      Token
	// contains filtered or unexported fields
}

ConstSpec describes a constant specification.

ConstSpec = IdentifierList [ [ Type ] "=" ExpressionList ] .

func (*ConstSpec) Position

func (n *ConstSpec) Position() (r token.Position)

Position implements Node.

func (*ConstSpec) Source

func (n *ConstSpec) Source(full bool) []byte

Source implements Node.

func (*ConstSpec) Tokens

func (n *ConstSpec) Tokens() []Token

Tokens returns the tokens n consist of.

type Constant

type Constant struct {
	Expr  Expression
	Ident Token
	// contains filtered or unexported fields
}

Constant represents a Go constant.

func (Constant) IsUncheckedType

func (t Constant) IsUncheckedType() bool

IsUncheckedType returns true when a type check of a Node was not performed.

func (*Constant) Position

func (n *Constant) Position() (r token.Position)

Position implements Node.

func (*Constant) SetValue

func (v *Constant) SetValue(val constant.Value)

SetValue implements Expression

func (*Constant) Source

func (n *Constant) Source(full bool) []byte

Source implements Node.

func (*Constant) Tokens

func (n *Constant) Tokens() []Token

Tokens returns the tokens n consist of.

func (Constant) Type

func (t Constant) Type() Type

Type returns the type of a node or Invalid if the type is unknown/undetermined.

func (Constant) Value

func (v Constant) Value() constant.Value

Value implements Expression

type ContinueStmt

type ContinueStmt struct {
	Continue  Token
	Label     Token
	Semicolon Token
}

ContinueStmt describes a continue statement.

ContinueStmt = "continue" [ Label ] .

func (*ContinueStmt) Position

func (n *ContinueStmt) Position() (r token.Position)

Position implements Node.

func (*ContinueStmt) Source

func (n *ContinueStmt) Source(full bool) []byte

Source implements Node.

func (*ContinueStmt) Tokens

func (n *ContinueStmt) Tokens() []Token

Tokens returns the tokens n consist of.

type Conversion

type Conversion struct {
	ConvertType Node
	LParen      Token
	Expr        Expression
	Comma       Token
	RParen      Token
	// contains filtered or unexported fields
}

Conversion describes a conversion.

Conversion = Type "(" Expression [ "," ] ")" .

func (Conversion) IsUncheckedType

func (t Conversion) IsUncheckedType() bool

IsUncheckedType returns true when a type check of a Node was not performed.

func (*Conversion) Position

func (n *Conversion) Position() (r token.Position)

Position implements Node.

func (*Conversion) SetValue

func (v *Conversion) SetValue(val constant.Value)

SetValue implements Expression

func (*Conversion) Source

func (n *Conversion) Source(full bool) []byte

Source implements Node.

func (*Conversion) Tokens

func (n *Conversion) Tokens() []Token

Tokens returns the tokens n consist of.

func (Conversion) Type

func (t Conversion) Type() Type

Type returns the type of a node or Invalid if the type is unknown/undetermined.

func (Conversion) Value

func (v Conversion) Value() constant.Value

Value implements Expression

type DeferStmt

type DeferStmt struct {
	Defer     Token
	Expr      Expression
	Semicolon Token
}

DeferStmt describes a defer statement.

DeferStmt = "defer" Expression .

func (*DeferStmt) Position

func (n *DeferStmt) Position() (r token.Position)

Position implements Node.

func (*DeferStmt) Source

func (n *DeferStmt) Source(full bool) []byte

Source implements Node.

func (*DeferStmt) Tokens

func (n *DeferStmt) Tokens() []Token

Tokens returns the tokens n consist of.

type EmbeddedField

type EmbeddedField struct {
	Star     Token
	TypeName *TypeNameNode
}

EmbeddedField describes an embeded field.

EmbeddedField = [ "*" ] TypeName .

func (*EmbeddedField) Position

func (n *EmbeddedField) Position() (r token.Position)

Position implements Node.

func (*EmbeddedField) Source

func (n *EmbeddedField) Source(full bool) []byte

Source implements Node.

func (*EmbeddedField) Tokens

func (n *EmbeddedField) Tokens() []Token

Tokens returns the tokens n consist of.

type EmptyStmt

type EmptyStmt struct {
	Semicolon Token
}

EmptyStmt describes an empty statement.

EmptyStmt = .

func (*EmptyStmt) Position

func (n *EmptyStmt) Position() (r token.Position)

Position implements Node.

func (*EmptyStmt) Source

func (n *EmptyStmt) Source(full bool) []byte

Source implements Node.

func (*EmptyStmt) Tokens

func (n *EmptyStmt) Tokens() []Token

Tokens returns the tokens n consist of.

type ExprCaseClause

type ExprCaseClause struct {
	ExprSwitchCase *ExprSwitchCase
	Colon          Token
	StatementList  []Node
}

ExprCaseClause describes an expression switch case clause.

ExprCaseClause = ExprSwitchCase ":" StatementList .

func (*ExprCaseClause) Position

func (n *ExprCaseClause) Position() (r token.Position)

Position implements Node.

func (*ExprCaseClause) Source

func (n *ExprCaseClause) Source(full bool) []byte

Source implements Node.

func (*ExprCaseClause) Tokens

func (n *ExprCaseClause) Tokens() []Token

Tokens returns the tokens n consist of.

type ExprListItem

type ExprListItem struct {
	Expr  Expression
	Comma Token
}

ExprListItem describes an item of an expression list.

ExpressionList = Expression { "," Expression } .

func (*ExprListItem) Position

func (n *ExprListItem) Position() (r token.Position)

Position implements Node.

func (*ExprListItem) Source

func (n *ExprListItem) Source(full bool) []byte

Source implements Node.

func (*ExprListItem) Tokens

func (n *ExprListItem) Tokens() []Token

Tokens returns the tokens n consist of.

type ExprSwitchCase

type ExprSwitchCase struct {
	CaseOrDefault Token
	ExprList      []*ExprListItem
}

ExprSwitchCase describes an expression switch case.

ExprSwitchCase = "case" ExpressionList | "default" .

func (*ExprSwitchCase) Position

func (n *ExprSwitchCase) Position() (r token.Position)

Position implements Node.

func (*ExprSwitchCase) Source

func (n *ExprSwitchCase) Source(full bool) []byte

Source implements Node.

func (*ExprSwitchCase) Tokens

func (n *ExprSwitchCase) Tokens() []Token

Tokens returns the tokens n consist of.

type Expression

type Expression interface {
	Node
	Type() Type
	Value() constant.Value
	SetValue(constant.Value)
	// contains filtered or unexported methods
}

Expression represents a computation.

type ExpressionStmt

type ExpressionStmt struct {
	Expr      Expression
	Semicolon Token
}

ExpressionStmt describes an expression statement.

func (*ExpressionStmt) Position

func (n *ExpressionStmt) Position() (r token.Position)

Position implements Node.

func (*ExpressionStmt) Source

func (n *ExpressionStmt) Source(full bool) []byte

Source implements Node.

func (*ExpressionStmt) Tokens

func (n *ExpressionStmt) Tokens() []Token

Tokens returns the tokens n consist of.

type ExpressionSwitchStmt

type ExpressionSwitchStmt struct {
	Switch          Token
	SimpleStmt      Node
	Semicolon       Token
	Expr            Expression
	LBrace          Token
	ExprCaseClauses []*ExprCaseClause
	RBrace          Token
	Semicolon2      Token
	Scope           *Scope // Implicit scope of the switch statement
}

ExpressionSwitchStmt describes an expression switch statement.

ExprSwitchStmt = "switch" [ SimpleStmt ";" ] [ Expression ] "{" { ExprCaseClause } "}" .

func (*ExpressionSwitchStmt) Position

func (n *ExpressionSwitchStmt) Position() (r token.Position)

Position implements Node.

func (*ExpressionSwitchStmt) Source

func (n *ExpressionSwitchStmt) Source(full bool) []byte

Source implements Node.

func (*ExpressionSwitchStmt) Tokens

func (n *ExpressionSwitchStmt) Tokens() []Token

Tokens returns the tokens n consist of.

type FallthroughStmt

type FallthroughStmt struct {
	Fallthrough Token
	Semicolon   Token
}

FallthroughStmt describes a fallthrough statement.

FallthroughStmt = "fallthrough" .

func (*FallthroughStmt) Position

func (n *FallthroughStmt) Position() (r token.Position)

Position implements Node.

func (*FallthroughStmt) Source

func (n *FallthroughStmt) Source(full bool) []byte

Source implements Node.

func (*FallthroughStmt) Tokens

func (n *FallthroughStmt) Tokens() []Token

Tokens returns the tokens n consist of.

type Field

type Field struct {
	Name string
	// contains filtered or unexported fields
}

Field represents a struct field.

func NewField

func NewField(name string, typ Type) *Field

NewField returns a newly created struct field.

func (*Field) Index

func (n *Field) Index() int

Index returns n's zero-base index.

func (Field) IsUncheckedType

func (t Field) IsUncheckedType() bool

IsUncheckedType returns true when a type check of a Node was not performed.

func (Field) Type

func (t Field) Type() Type

Type returns the type of a node or Invalid if the type is unknown/undetermined.

type FieldDecl

type FieldDecl struct {
	IdentifierList []*IdentListItem
	Type           Node
	EmbeddedField  *EmbeddedField
	Tag            Token
	Semicolon      Token
}

FieldDecl describes a field declaration.

FieldDecl = (IdentifierList Type | EmbeddedField) [ Tag ] .

func (*FieldDecl) Position

func (n *FieldDecl) Position() (r token.Position)

Position implements Node.

func (*FieldDecl) Source

func (n *FieldDecl) Source(full bool) []byte

Source implements Node.

func (*FieldDecl) Tokens

func (n *FieldDecl) Tokens() []Token

Tokens returns the tokens n consist of.

type ForClause

type ForClause struct {
	InitStmt   Node
	Semicolon  Token
	Condition  Expression
	Semicolon2 Token
	PostStmt   Node
}

ForClause describes a for clause.

ForClause = [ InitStmt ] ";" [ Condition ] ";" [ PostStmt ] .

func (*ForClause) Position

func (n *ForClause) Position() (r token.Position)

Position implements Node.

func (*ForClause) Source

func (n *ForClause) Source(full bool) []byte

Source implements Node.

func (*ForClause) Tokens

func (n *ForClause) Tokens() []Token

Tokens returns the tokens n consist of.

type ForStmt

type ForStmt struct {
	For         Token
	ForClause   *ForClause
	RangeClause *RangeClause
	Block       *Block
	Semicolon   Token
	Scope       *Scope // Implicit scope of the for statement
}

ForStmt describes a for statement.

ForStmt = "for" [ Condition | ForClause | RangeClause ] Block .

func (*ForStmt) Position

func (n *ForStmt) Position() (r token.Position)

Position implements Node.

func (*ForStmt) Source

func (n *ForStmt) Source(full bool) []byte

Source implements Node.

func (*ForStmt) Tokens

func (n *ForStmt) Tokens() []Token

Tokens returns the tokens n consist of.

type FunctionDecl

type FunctionDecl struct {
	Func           Token
	FunctionName   Token
	TypeParameters *TypeParameters
	Signature      *Signature
	FunctionBody   *Block
	Semicolon      Token
	// contains filtered or unexported fields
}

FunctionDecl describes a function declaration.

FunctionDecl = "func" FunctionName [ TypeParameters ] Signature [ FunctionBody ] .

func (FunctionDecl) IsUncheckedType

func (t FunctionDecl) IsUncheckedType() bool

IsUncheckedType returns true when a type check of a Node was not performed.

func (*FunctionDecl) Position

func (n *FunctionDecl) Position() (r token.Position)

Position implements Node.

func (*FunctionDecl) Source

func (n *FunctionDecl) Source(full bool) []byte

Source implements Node.

func (*FunctionDecl) Tokens

func (n *FunctionDecl) Tokens() []Token

Tokens returns the tokens n consist of.

func (FunctionDecl) Type

func (t FunctionDecl) Type() Type

Type returns the type of a node or Invalid if the type is unknown/undetermined.

type FunctionLit

type FunctionLit struct {
	Func         Token
	Signature    *Signature
	FunctionBody *Block
	// contains filtered or unexported fields
}

FunctionLit describes a function literal.

FunctionLit = "func" Signature FunctionBody .

func (FunctionLit) IsUncheckedType

func (t FunctionLit) IsUncheckedType() bool

IsUncheckedType returns true when a type check of a Node was not performed.

func (*FunctionLit) Position

func (n *FunctionLit) Position() (r token.Position)

Position implements Node.

func (*FunctionLit) SetValue

func (v *FunctionLit) SetValue(val constant.Value)

SetValue implements Expression

func (*FunctionLit) Source

func (n *FunctionLit) Source(full bool) []byte

Source implements Node.

func (*FunctionLit) Tokens

func (n *FunctionLit) Tokens() []Token

Tokens returns the tokens n consist of.

func (FunctionLit) Type

func (t FunctionLit) Type() Type

Type returns the type of a node or Invalid if the type is unknown/undetermined.

func (FunctionLit) Value

func (v FunctionLit) Value() constant.Value

Value implements Expression

type FunctionType

type FunctionType struct {
	Parameters *TupleType
	Result     *TupleType

	IsVariadic bool
	// contains filtered or unexported fields
}

FunctionType represents a channel type.

func (*FunctionType) Kind

func (t *FunctionType) Kind() Kind

Kind implements Type.

func (*FunctionType) Position

func (t *FunctionType) Position() (r token.Position)

Position implements Node.

func (FunctionType) Source

func (FunctionType) Source(bool) []byte

Source implements Node. It returns nil.

func (*FunctionType) String

func (t *FunctionType) String() string

func (FunctionType) Tokens

func (FunctionType) Tokens() []Token

Tokens implements Node. It returns nil.

type FunctionTypeNode

type FunctionTypeNode struct {
	Func      Token
	Signature *Signature
	// contains filtered or unexported fields
}

FunctionTypeNode describes a function type.

FunctionTypeNode = "func" Signature .

func (FunctionTypeNode) IsUncheckedType

func (t FunctionTypeNode) IsUncheckedType() bool

IsUncheckedType returns true when a type check of a Node was not performed.

func (*FunctionTypeNode) Position

func (n *FunctionTypeNode) Position() (r token.Position)

Position implements Node.

func (*FunctionTypeNode) Source

func (n *FunctionTypeNode) Source(full bool) []byte

Source implements Node.

func (*FunctionTypeNode) Tokens

func (n *FunctionTypeNode) Tokens() []Token

Tokens returns the tokens n consist of.

func (FunctionTypeNode) Type

func (t FunctionTypeNode) Type() Type

Type returns the type of a node or Invalid if the type is unknown/undetermined.

type GenericOperand

type GenericOperand struct {
	OperandName Node
	TypeArgs    *TypeArgs
	// contains filtered or unexported fields
}

GenericOperand describes an operand name and type arguments.

GenericOperand = OperandName TypeArgs .

func (GenericOperand) IsUncheckedType

func (t GenericOperand) IsUncheckedType() bool

IsUncheckedType returns true when a type check of a Node was not performed.

func (*GenericOperand) Position

func (n *GenericOperand) Position() (r token.Position)

Position implements Node.

func (*GenericOperand) SetValue

func (v *GenericOperand) SetValue(val constant.Value)

SetValue implements Expression

func (*GenericOperand) Source

func (n *GenericOperand) Source(full bool) []byte

Source implements Node.

func (*GenericOperand) Tokens

func (n *GenericOperand) Tokens() []Token

Tokens returns the tokens n consist of.

func (GenericOperand) Type

func (t GenericOperand) Type() Type

Type returns the type of a node or Invalid if the type is unknown/undetermined.

func (GenericOperand) Value

func (v GenericOperand) Value() constant.Value

Value implements Expression

type GoStmt

type GoStmt struct {
	Go        Token
	Expr      Expression
	Semicolon Token
}

GoStmt describes a go statement.

GoStmt = "go" Expression .

func (*GoStmt) Position

func (n *GoStmt) Position() (r token.Position)

Position implements Node.

func (*GoStmt) Source

func (n *GoStmt) Source(full bool) []byte

Source implements Node.

func (*GoStmt) Tokens

func (n *GoStmt) Tokens() []Token

Tokens returns the tokens n consist of.

type GotoStmt

type GotoStmt struct {
	Goto      Token
	Label     Token
	Semicolon Token
}

GotoStmt describes a goto statement.

GotoStmt = "goto" Label .

func (*GotoStmt) Position

func (n *GotoStmt) Position() (r token.Position)

Position implements Node.

func (*GotoStmt) Source

func (n *GotoStmt) Source(full bool) []byte

Source implements Node.

func (*GotoStmt) Tokens

func (n *GotoStmt) Tokens() []Token

Tokens returns the tokens n consist of.

type Ident

type Ident struct {
	Token Token
	// contains filtered or unexported fields
}

Ident represents an unqualified operand/type name.

func (Ident) IsUncheckedType

func (t Ident) IsUncheckedType() bool

IsUncheckedType returns true when a type check of a Node was not performed.

func (Ident) LexicalScope

func (n Ident) LexicalScope() *Scope

LexicalScope returns the lexical scope n appears in.

func (*Ident) Position

func (n *Ident) Position() (r token.Position)

Position implements Node.

func (*Ident) ResolvedTo

func (n *Ident) ResolvedTo() Node

ResolvedTo returns the node n refers to. Valid after type checking.

func (*Ident) SetValue

func (v *Ident) SetValue(val constant.Value)

SetValue implements Expression

func (*Ident) Source

func (n *Ident) Source(full bool) []byte

Source implements Node.

func (*Ident) Tokens

func (n *Ident) Tokens() []Token

Tokens returns the tokens n consist of.

func (Ident) Type

func (t Ident) Type() Type

Type returns the type of a node or Invalid if the type is unknown/undetermined.

func (Ident) Value

func (v Ident) Value() constant.Value

Value implements Expression

type IdentListItem

type IdentListItem struct {
	Ident Token
	Comma Token
}

IdentListItem describes an item of an identifier list.

func (*IdentListItem) Position

func (n *IdentListItem) Position() (r token.Position)

Position implements Node.

func (*IdentListItem) Source

func (n *IdentListItem) Source(full bool) []byte

Source implements Node.

func (*IdentListItem) Tokens

func (n *IdentListItem) Tokens() []Token

Tokens returns the tokens n consist of.

type IfStmt

type IfStmt struct {
	If         Token
	SimpleStmt Node
	Semicolon  Token
	Expr       Expression
	Block      *Block
	Else       Token
	ElsePart   Node
	Semicolon2 Token
	Scope      *Scope // Implicit scope of the if statement
}

IfStmt describes an if statement.

IfStmt = "if" [ SimpleStmt ";" ] Expression Block [ "else" ( IfStmt | Block ) ] .

func (*IfStmt) Position

func (n *IfStmt) Position() (r token.Position)

Position implements Node.

func (*IfStmt) Source

func (n *IfStmt) Source(full bool) []byte

Source implements Node.

func (*IfStmt) Tokens

func (n *IfStmt) Tokens() []Token

Tokens returns the tokens n consist of.

type ImportDecl

type ImportDecl struct {
	Import      Token
	LParen      Token
	ImportSpecs []*ImportSpec
	RParen      Token
	Semicolon   Token
}

ImportDecl describes an import declaration.

ImportDecl = "import" ( ImportSpec | "(" { ImportSpec ";" } ")" ) .

func (*ImportDecl) Position

func (n *ImportDecl) Position() (r token.Position)

Position implements Node.

func (*ImportDecl) Source

func (n *ImportDecl) Source(full bool) []byte

Source implements Node.

func (*ImportDecl) Tokens

func (n *ImportDecl) Tokens() []Token

Tokens returns the tokens n consist of.

type ImportSpec

type ImportSpec struct {
	Qualifier  Token
	ImportPath Token
	Semicolon  Token
}

ImportSpec describes an import specification.

ImportSpec = [ "." | PackageName ] ImportPath .

func (*ImportSpec) Position

func (n *ImportSpec) Position() (r token.Position)

Position implements Node.

func (*ImportSpec) Source

func (n *ImportSpec) Source(full bool) []byte

Source implements Node.

func (*ImportSpec) Tokens

func (n *ImportSpec) Tokens() []Token

Tokens returns the tokens n consist of.

type IncDecStmt

type IncDecStmt struct {
	Expr      Expression
	Op        Token
	Semicolon Token
	// contains filtered or unexported fields
}

IncDecStmt describes an increment or decrement statemen.

IncDecStmt = Expression ( "++" | "--" ) .

func (*IncDecStmt) Position

func (n *IncDecStmt) Position() (r token.Position)

Position implements Node.

func (*IncDecStmt) Source

func (n *IncDecStmt) Source(full bool) []byte

Source implements Node.

func (*IncDecStmt) Tokens

func (n *IncDecStmt) Tokens() []Token

Tokens returns the tokens n consist of.

type Index

type Index struct {
	PrimaryExpr Expression
	LBracket    Token
	Expr        Expression
	RBracket    Token
	// contains filtered or unexported fields
}

Index describes an index.

Index = "[" Expression "]" .

func (Index) IsUncheckedType

func (t Index) IsUncheckedType() bool

IsUncheckedType returns true when a type check of a Node was not performed.

func (*Index) Position

func (n *Index) Position() (r token.Position)

Position implements Node.

func (*Index) SetValue

func (v *Index) SetValue(val constant.Value)

SetValue implements Expression

func (*Index) Source

func (n *Index) Source(full bool) []byte

Source implements Node.

func (*Index) Tokens

func (n *Index) Tokens() []Token

Tokens returns the tokens n consist of.

func (Index) Type

func (t Index) Type() Type

Type returns the type of a node or Invalid if the type is unknown/undetermined.

func (Index) Value

func (v Index) Value() constant.Value

Value implements Expression

type InterfaceType

type InterfaceType struct {
	Elems []Node //TODO
	// contains filtered or unexported fields
}

InterfaceType represents an interface type.

func (*InterfaceType) Kind

func (t *InterfaceType) Kind() Kind

Kind implements Type.

func (*InterfaceType) Position

func (t *InterfaceType) Position() (r token.Position)

Position implements Node.

func (InterfaceType) Source

func (InterfaceType) Source(bool) []byte

Source implements Node. It returns nil.

func (*InterfaceType) String

func (t *InterfaceType) String() string

func (InterfaceType) Tokens

func (InterfaceType) Tokens() []Token

Tokens implements Node. It returns nil.

type InterfaceTypeNode

type InterfaceTypeNode struct {
	Interface      Token
	LBrace         Token
	InterfaceElems []Node
	RBrace         Token
	// contains filtered or unexported fields
}

InterfaceTypeNode describes an interface type.

InterfaceTypeNode = "interface" "{" { InterfaceElem ";" } "}" .

func (InterfaceTypeNode) IsUncheckedType

func (t InterfaceTypeNode) IsUncheckedType() bool

IsUncheckedType returns true when a type check of a Node was not performed.

func (*InterfaceTypeNode) Position

func (n *InterfaceTypeNode) Position() (r token.Position)

Position implements Node.

func (*InterfaceTypeNode) Source

func (n *InterfaceTypeNode) Source(full bool) []byte

Source implements Node.

func (*InterfaceTypeNode) Tokens

func (n *InterfaceTypeNode) Tokens() []Token

Tokens returns the tokens n consist of.

func (InterfaceTypeNode) Type

func (t InterfaceTypeNode) Type() Type

Type returns the type of a node or Invalid if the type is unknown/undetermined.

type InvalidType

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

InvalidType represents an invalid type.

func (*InvalidType) Kind

func (t *InvalidType) Kind() Kind

Kind implements Type.

func (*InvalidType) Position

func (t *InvalidType) Position() (r token.Position)

Position implements Node. Position returns a zero value.

func (InvalidType) Source

func (InvalidType) Source(bool) []byte

Source implements Node. It returns nil.

func (*InvalidType) String

func (t *InvalidType) String() string

func (InvalidType) Tokens

func (InvalidType) Tokens() []Token

Tokens implements Node. It returns nil.

type KeyedElement

type KeyedElement struct {
	Key     Node
	Colon   Token
	Element Node
	Comma   Token
	// contains filtered or unexported fields
}

KeyedElement describes an optionally keyed element.

KeyedElement = [ Key ":" ] Element .

func (KeyedElement) IsUncheckedType

func (t KeyedElement) IsUncheckedType() bool

IsUncheckedType returns true when a type check of a Node was not performed.

func (*KeyedElement) Position

func (n *KeyedElement) Position() (r token.Position)

Position implements Node.

func (*KeyedElement) Source

func (n *KeyedElement) Source(full bool) []byte

Source implements Node.

func (*KeyedElement) Tokens

func (n *KeyedElement) Tokens() []Token

Tokens returns the tokens n consist of.

func (KeyedElement) Type

func (t KeyedElement) Type() Type

Type returns the type of a node or Invalid if the type is unknown/undetermined.

type Kind

type Kind int

A Kind represents the specific kind of type that a Type represents. The zero Kind is not a valid kind.

const (
	InvalidKind Kind = iota // <invalid type>

	Array          // array
	Bool           // bool
	Chan           // chan
	Complex128     // complex128
	Complex64      // complex64
	Defined        // typename
	Float32        // float32
	Float64        // float64
	Function       // function
	Int            // int
	Int16          // int16
	Int32          // int32
	Int64          // int64
	Int8           // int8
	Interface      // interface
	Map            // map
	Pointer        // pointer
	Slice          // slice
	String         // string
	Struct         // struct
	Tuple          // tuple
	Uint           // uint
	Uint16         // uint16
	Uint32         // uint32
	Uint64         // uint64
	Uint8          // uint8
	Uintptr        // uintptr
	UnsafePointer  // unsafe.Pointer
	UntypedBool    // untyped bool
	UntypedComplex // untyped complex
	UntypedFloat   // untyped float
	UntypedInt     // untyped int
	UntypedNil     // untyped nil
	UntypedString  // untyped string
)

Values of type Kind

func (Kind) String

func (i Kind) String() string

type LabeledStmt

type LabeledStmt struct {
	Label     Token
	Colon     Token
	Statement Node
}

LabeledStmt describes a labeled statement.

LabeledStmt = Label ":" Statement .

func (*LabeledStmt) Position

func (n *LabeledStmt) Position() (r token.Position)

Position implements Node.

func (*LabeledStmt) Source

func (n *LabeledStmt) Source(full bool) []byte

Source implements Node.

func (*LabeledStmt) Tokens

func (n *LabeledStmt) Tokens() []Token

Tokens returns the tokens n consist of.

type LiteralValue

type LiteralValue struct {
	LBrace      Token
	ElementList []*KeyedElement
	RBrace      Token
}

LiteralValue describes a composite literal value.

LiteralValue = "{" [ ElementList [ "," ] ] "}" .

func (*LiteralValue) Position

func (n *LiteralValue) Position() (r token.Position)

Position implements Node.

func (*LiteralValue) Source

func (n *LiteralValue) Source(full bool) []byte

Source implements Node.

func (*LiteralValue) Tokens

func (n *LiteralValue) Tokens() []Token

Tokens returns the tokens n consist of.

type MapType

type MapType struct {
	Elem Type
	Key  Type
	// contains filtered or unexported fields
}

MapType represents a map type.

func (*MapType) Kind

func (t *MapType) Kind() Kind

Kind implements Type.

func (*MapType) Position

func (t *MapType) Position() (r token.Position)

Position implements Node.

func (MapType) Source

func (MapType) Source(bool) []byte

Source implements Node. It returns nil.

func (*MapType) String

func (t *MapType) String() string

func (MapType) Tokens

func (MapType) Tokens() []Token

Tokens implements Node. It returns nil.

type MapTypeNode

type MapTypeNode struct {
	Map         Token
	LBracket    Token
	KeyType     Node
	RBracket    Token
	ElementType Node
	// contains filtered or unexported fields
}

MapTypeNode describes a map type.

MapTypeNode = "map" "[" KeyType "]" ElementType .

func (*MapTypeNode) Position

func (n *MapTypeNode) Position() (r token.Position)

Position implements Node.

func (*MapTypeNode) Source

func (n *MapTypeNode) Source(full bool) []byte

Source implements Node.

func (*MapTypeNode) Tokens

func (n *MapTypeNode) Tokens() []Token

Tokens returns the tokens n consist of.

type MethodDecl

type MethodDecl struct {
	Func         Token
	Receiver     *Parameters
	MethodName   Token
	Signature    *Signature
	FunctionBody *Block
	Semicolon    Token
	// contains filtered or unexported fields
}

MethodDecl describes a method declaration.

MethodDecl = "func" Receiver MethodName Signature [ FunctionBody ] .

func (MethodDecl) IsUncheckedType

func (t MethodDecl) IsUncheckedType() bool

IsUncheckedType returns true when a type check of a Node was not performed.

func (*MethodDecl) Position

func (n *MethodDecl) Position() (r token.Position)

Position implements Node.

func (*MethodDecl) Source

func (n *MethodDecl) Source(full bool) []byte

Source implements Node.

func (*MethodDecl) Tokens

func (n *MethodDecl) Tokens() []Token

Tokens returns the tokens n consist of.

func (MethodDecl) Type

func (t MethodDecl) Type() Type

Type returns the type of a node or Invalid if the type is unknown/undetermined.

type MethodElem

type MethodElem struct {
	MethodName Token
	Signature  *Signature
	Semicolon  Token
}

MethodElem describes a method element.

MethodElem = MethodName Signature .

func (*MethodElem) Position

func (n *MethodElem) Position() (r token.Position)

Position implements Node.

func (*MethodElem) Source

func (n *MethodElem) Source(full bool) []byte

Source implements Node.

func (*MethodElem) Tokens

func (n *MethodElem) Tokens() []Token

Tokens returns the tokens n consist of.

type MethodExpr

type MethodExpr struct {
	Receiver Node
	Dot      Token
	Ident    Token
	// contains filtered or unexported fields
}

MethodExpr describes a method expression.

MethodExpr    = ReceiverType "." MethodName .

func (MethodExpr) IsUncheckedType

func (t MethodExpr) IsUncheckedType() bool

IsUncheckedType returns true when a type check of a Node was not performed.

func (*MethodExpr) Position

func (n *MethodExpr) Position() (r token.Position)

Position implements Node.

func (*MethodExpr) SetValue

func (v *MethodExpr) SetValue(val constant.Value)

SetValue implements Expression

func (*MethodExpr) Source

func (n *MethodExpr) Source(full bool) []byte

Source implements Node.

func (*MethodExpr) Tokens

func (n *MethodExpr) Tokens() []Token

Tokens returns the tokens n consist of.

func (MethodExpr) Type

func (t MethodExpr) Type() Type

Type returns the type of a node or Invalid if the type is unknown/undetermined.

func (MethodExpr) Value

func (v MethodExpr) Value() constant.Value

Value implements Expression

type Node

type Node interface {
	Position() token.Position
	// Source returns the source form of n. Setting full to false will replace
	// every non-empty token separator by a single space character and drop the
	// first token separator entirely, if any.
	Source(full bool) []byte
	// Tokens returns the tokens a node consists of.
	Tokens() []Token
}

Node is an item of the CST tree.

type Package

type Package struct {
	ImportPath  string
	Inits       []*FunctionDecl
	Blanks      []Node
	Name        string
	Scope       *Scope
	SourceFiles []*SourceFile
	// contains filtered or unexported fields
}

Package collects source files.

func NewPackage

func NewPackage(importPath string, files []*SourceFile) (r *Package, err error)

NewPackage returns a newly created Package or an error, if any.

func (*Package) Check

func (n *Package) Check(checker PackageChecker) error

Check type checks n.

func (*Package) Position

func (n *Package) Position() (r token.Position)

Position implements Node. Position return a zero value.

func (*Package) Source

func (n *Package) Source(full bool) []byte

Source implements Node. Source returns a zero value.

func (*Package) Tokens

func (n *Package) Tokens() []Token

Tokens returns the tokens n consist of. Tokens returns nil.

type PackageChecker

type PackageChecker interface {
	// PackageLoader returns a package by its import path or an error, if any. The
	// type checker never calls PackageLoader for  certain packages.
	PackageLoader(pkg *Package, src *SourceFile, importPath string) (*Package, error)
	// SymbolResolver returns the node bound to 'ident' within package 'pkg', using
	// currentScope and fileScope or an error, if any. The type checker never calls
	// SymbolResolver for certain identifiers of some packages.
	SymbolResolver(currentScope, fileScope *Scope, pkg *Package, ident Token) (Node, error)
	// CheckFunctions reports whether Check should type check function/method
	// bodies.
	CheckFunctions() bool
	// GOARCH reports the target architecture, it returns the same values as runtime.GOARCH.
	GOARCH() string
}

PackageChecker provides the resolution API for (*Package).Check.

type PackageClause

type PackageClause struct {
	Package     Token
	PackageName Token
	Semicolon   Token
}

PackageClause describes the package clause.

PackageClause = "package" PackageName .

func (*PackageClause) Position

func (n *PackageClause) Position() (r token.Position)

Position implements Node.

func (*PackageClause) Source

func (n *PackageClause) Source(full bool) []byte

Source implements Node.

func (*PackageClause) Tokens

func (n *PackageClause) Tokens() []Token

Tokens returns the tokens n consist of.

type Parameter

type Parameter struct {
	Name string
	// contains filtered or unexported fields
}

Parameter represents a function input/output paramater.

func (Parameter) IsUncheckedType

func (t Parameter) IsUncheckedType() bool

IsUncheckedType returns true when a type check of a Node was not performed.

func (Parameter) Type

func (t Parameter) Type() Type

Type returns the type of a node or Invalid if the type is unknown/undetermined.

type ParameterDecl

type ParameterDecl struct {
	IdentifierList []*IdentListItem
	Ellipsis       Token
	Type           Node
	Comma          Token
}

ParameterDecl describes a parameter declaration.

ParameterDecl = [ IdentifierList ] [ "..." ] Type .

func (*ParameterDecl) Position

func (n *ParameterDecl) Position() (r token.Position)

Position implements Node.

func (*ParameterDecl) Source

func (n *ParameterDecl) Source(full bool) []byte

Source implements Node.

func (*ParameterDecl) Tokens

func (n *ParameterDecl) Tokens() []Token

Tokens returns the tokens n consist of.

type Parameters

type Parameters struct {
	LParen        Token
	ParameterList []*ParameterDecl
	Comma         Token
	RParen        Token
}

Parameters describes function parameters or a function result.

Parameters = "(" [ ParameterList [ "," ] ] ")" .
ParameterList = ParameterDecl { "," ParameterDecl } .

func (*Parameters) Position

func (n *Parameters) Position() (r token.Position)

Position implements Node.

func (*Parameters) Source

func (n *Parameters) Source(full bool) []byte

Source implements Node.

func (*Parameters) Tokens

func (n *Parameters) Tokens() []Token

Tokens returns the tokens n consist of.

type ParenExpr

type ParenExpr struct {
	LParen Token
	Expr   Expression
	RParen Token
	// contains filtered or unexported fields
}

ParenExpr describes a parenthesized expression.

ParenExpr = "(" Expression ")" .

func (ParenExpr) IsUncheckedType

func (t ParenExpr) IsUncheckedType() bool

IsUncheckedType returns true when a type check of a Node was not performed.

func (*ParenExpr) Position

func (n *ParenExpr) Position() (r token.Position)

Position implements Node.

func (*ParenExpr) SetValue

func (v *ParenExpr) SetValue(val constant.Value)

SetValue implements Expression

func (*ParenExpr) Source

func (n *ParenExpr) Source(full bool) []byte

Source implements Node.

func (*ParenExpr) Tokens

func (n *ParenExpr) Tokens() []Token

Tokens returns the tokens n consist of.

func (ParenExpr) Type

func (t ParenExpr) Type() Type

Type returns the type of a node or Invalid if the type is unknown/undetermined.

func (ParenExpr) Value

func (v ParenExpr) Value() constant.Value

Value implements Expression

type ParenType

type ParenType struct {
	LParen   Token
	TypeNode Node
	RParen   Token
	// contains filtered or unexported fields
}

ParenType describes a parenthesized type.

ParenType = "(" Type ")" .

func (ParenType) IsUncheckedType

func (t ParenType) IsUncheckedType() bool

IsUncheckedType returns true when a type check of a Node was not performed.

func (*ParenType) Position

func (n *ParenType) Position() (r token.Position)

Position implements Node.

func (*ParenType) Source

func (n *ParenType) Source(full bool) []byte

Source implements Node.

func (*ParenType) Tokens

func (n *ParenType) Tokens() []Token

Tokens returns the tokens n consist of.

func (ParenType) Type

func (t ParenType) Type() Type

Type returns the type of a node or Invalid if the type is unknown/undetermined.

type ParseSourceFileConfig

type ParseSourceFileConfig struct {
	// Accept, if non nil, is called once the package clause and imports are
	// parsed. If Accept return a non-nil error the parsing stops and the error is
	// returned.  Passing nil Accept is the same as passing a function that always
	// returns nil
	Accept func(*SourceFile) error

	AllErrors bool
	// contains filtered or unexported fields
}

ParseSourceFileConfig configures ParseSourceFile.

type PointerType

type PointerType struct {
	Elem Type
	// contains filtered or unexported fields
}

PointerType represents a pointer type.

func (*PointerType) Kind

func (t *PointerType) Kind() Kind

Kind implements Type.

func (*PointerType) Position

func (t *PointerType) Position() (r token.Position)

Position implements Node.

func (PointerType) Source

func (PointerType) Source(bool) []byte

Source implements Node. It returns nil.

func (*PointerType) String

func (t *PointerType) String() string

func (PointerType) Tokens

func (PointerType) Tokens() []Token

Tokens implements Node. It returns nil.

type PointerTypeNode

type PointerTypeNode struct {
	Star     Token
	BaseType Node
	// contains filtered or unexported fields
}

PointerTypeNode describes a pointer type.

PointerTypeNode = "*" BaseType .

func (PointerTypeNode) IsUncheckedType

func (t PointerTypeNode) IsUncheckedType() bool

IsUncheckedType returns true when a type check of a Node was not performed.

func (*PointerTypeNode) Position

func (n *PointerTypeNode) Position() (r token.Position)

Position implements Node.

func (*PointerTypeNode) Source

func (n *PointerTypeNode) Source(full bool) []byte

Source implements Node.

func (*PointerTypeNode) Tokens

func (n *PointerTypeNode) Tokens() []Token

Tokens returns the tokens n consist of.

func (PointerTypeNode) Type

func (t PointerTypeNode) Type() Type

Type returns the type of a node or Invalid if the type is unknown/undetermined.

type PredefinedType

type PredefinedType Kind

PredefinedType represents a predefined type.

func (PredefinedType) Kind

func (t PredefinedType) Kind() Kind

Kind implements Type.

func (PredefinedType) Position

func (t PredefinedType) Position() (r token.Position)

Position implements Node. Position returns a zero value.

func (PredefinedType) Source

func (t PredefinedType) Source(full bool) []byte

Source implements Node. It returns nil.

func (PredefinedType) String

func (t PredefinedType) String() string

func (PredefinedType) Tokens

func (t PredefinedType) Tokens() []Token

Tokens implements Node. It returns nil.

type QualifiedIdent

type QualifiedIdent struct {
	PackageName Token
	Dot         Token
	Ident       Token
	// contains filtered or unexported fields
}

QualifiedIdent describes an optionally qualified identifier.

QualifiedIdent = PackageName "." identifier .

func (QualifiedIdent) IsUncheckedType

func (t QualifiedIdent) IsUncheckedType() bool

IsUncheckedType returns true when a type check of a Node was not performed.

func (QualifiedIdent) LexicalScope

func (n QualifiedIdent) LexicalScope() *Scope

LexicalScope returns the lexical scope n appears in.

func (*QualifiedIdent) Position

func (n *QualifiedIdent) Position() (r token.Position)

Position implements Node.

func (*QualifiedIdent) ResolvedIn

func (n *QualifiedIdent) ResolvedIn() *Package

ResolvedIn returns the package n refers to. Valid after type checking.

func (*QualifiedIdent) ResolvedTo

func (n *QualifiedIdent) ResolvedTo() Node

ResolvedTo returns the node n refers to. Valid after type checking.

func (*QualifiedIdent) SetValue

func (v *QualifiedIdent) SetValue(val constant.Value)

SetValue implements Expression

func (*QualifiedIdent) Source

func (n *QualifiedIdent) Source(full bool) []byte

Source implements Node.

func (*QualifiedIdent) Tokens

func (n *QualifiedIdent) Tokens() []Token

Tokens returns the tokens n consist of.

func (QualifiedIdent) Type

func (t QualifiedIdent) Type() Type

Type returns the type of a node or Invalid if the type is unknown/undetermined.

func (QualifiedIdent) Value

func (v QualifiedIdent) Value() constant.Value

Value implements Expression

type RangeClause

type RangeClause struct {
	ExprList []*ExprListItem
	Assign   Token
	Range    Token
	Expr     Expression
}

RangeClause describes a range clause.

RangeClause = [ ExpressionList "=" | IdentifierList ":=" ] "range" Expression .

func (*RangeClause) Position

func (n *RangeClause) Position() (r token.Position)

Position implements Node.

func (*RangeClause) Source

func (n *RangeClause) Source(full bool) []byte

Source implements Node.

func (*RangeClause) Tokens

func (n *RangeClause) Tokens() []Token

Tokens returns the tokens n consist of.

type ReturnStmt

type ReturnStmt struct {
	Return    Token
	ExprList  []*ExprListItem
	Semicolon Token
	// contains filtered or unexported fields
}

ReturnStmt describes a return statement.

ReturnStmt = "return" [ ExpressionList ] .

func (*ReturnStmt) Position

func (n *ReturnStmt) Position() (r token.Position)

Position implements Node.

func (*ReturnStmt) Source

func (n *ReturnStmt) Source(full bool) []byte

Source implements Node.

func (*ReturnStmt) Tokens

func (n *ReturnStmt) Tokens() []Token

Tokens returns the tokens n consist of.

type Scanner

type Scanner struct {

	// Tok is the current token. It is valid after first call to Scan. The value is
	// read only.
	Tok Token

	// CommentHandler, if not nil, is invoked on line and general comments, passing
	// the offset and content of the comment. The content must not be modified.
	CommentHandler func(off int32, s []byte)
	// contains filtered or unexported fields
}

Scanner provides lexical analysis of its buffer.

func NewScanner

func NewScanner(name string, buf []byte) (*Scanner, error)

NewScanner returns a newly created scanner that will tokenize buf. Positions are reported as if buf is coming from a file named name. The buffer becomes owned by the scanner and must not be modified after calling NewScanner.

func (*Scanner) Err

func (s *Scanner) Err() error

Err reports any errors the scanner encountered during .Scan() invocations. For typical use please see the .Scan() documentation.

func (*Scanner) Scan

func (s *Scanner) Scan() (r bool)

Scan moves to the next token and returns true if not at end of file. Usage example:

s, _ = NewScanner(buf, name, false)
for s.Scan() {
	...
}
if err := s.Err() {
	...
}

type Scope

type Scope struct {
	Nodes  map[string]Scoped
	Parent *Scope
}

Scope binds names to nodes.

func (*Scope) IsPackage

func (s *Scope) IsPackage() bool

IsPackage reports whether s is a package scope.

type Scoped

type Scoped struct {
	Node        Node
	VisibleFrom int
}

Scoped represents a node bound to a name and the offset where the visibility starts. Declarations outside of a function/method reports their visibility starts at zero.

type SelectStmt

type SelectStmt struct {
	Select      Token
	LBrace      Token
	CommClauses []*CommClause
	RBrace      Token
	Semicolon   Token
}

SelectStmt describes a select statement.

SelectStmt = "select" "{" { CommClause } "}" .

func (*SelectStmt) Position

func (n *SelectStmt) Position() (r token.Position)

Position implements Node.

func (*SelectStmt) Source

func (n *SelectStmt) Source(full bool) []byte

Source implements Node.

func (*SelectStmt) Tokens

func (n *SelectStmt) Tokens() []Token

Tokens returns the tokens n consist of.

type Selector

type Selector struct {
	PrimaryExpr Expression
	Dot         Token
	Ident       Token
	// contains filtered or unexported fields
}

Selector describes a selector.

Selector = PrimaryExpr "." identifier .

func (Selector) IsUncheckedType

func (t Selector) IsUncheckedType() bool

IsUncheckedType returns true when a type check of a Node was not performed.

func (*Selector) Position

func (n *Selector) Position() (r token.Position)

Position implements Node.

func (*Selector) SetValue

func (v *Selector) SetValue(val constant.Value)

SetValue implements Expression

func (*Selector) Source

func (n *Selector) Source(full bool) []byte

Source implements Node.

func (*Selector) Tokens

func (n *Selector) Tokens() []Token

Tokens returns the tokens n consist of.

func (Selector) Type

func (t Selector) Type() Type

Type returns the type of a node or Invalid if the type is unknown/undetermined.

func (Selector) Value

func (v Selector) Value() constant.Value

Value implements Expression

type SendStmt

type SendStmt struct {
	Channel   Node
	Arrow     Token
	Expr      Expression
	Semicolon Token
	// contains filtered or unexported fields
}

SendStmt describes a send statement.

SendStmt = Channel "<-" Expression .

func (*SendStmt) Position

func (n *SendStmt) Position() (r token.Position)

Position implements Node.

func (*SendStmt) Source

func (n *SendStmt) Source(full bool) []byte

Source implements Node.

func (*SendStmt) Tokens

func (n *SendStmt) Tokens() []Token

Tokens returns the tokens n consist of.

type ShortVarDecl

type ShortVarDecl struct {
	IdentifierList []*IdentListItem
	Define         Token
	ExprList       []*ExprListItem
	Semicolon      Token
	// contains filtered or unexported fields
}

ShortVarDecl describes a short variable declaration.

ShortVarDecl = IdentifierList ":=" ExpressionList .

func (ShortVarDecl) LexicalScope

func (n ShortVarDecl) LexicalScope() *Scope

LexicalScope returns the lexical scope n appears in.

func (*ShortVarDecl) Position

func (n *ShortVarDecl) Position() (r token.Position)

Position implements Node.

func (*ShortVarDecl) Source

func (n *ShortVarDecl) Source(full bool) []byte

Source implements Node.

func (*ShortVarDecl) Tokens

func (n *ShortVarDecl) Tokens() []Token

Tokens returns the tokens n consist of.

type Signature

type Signature struct {
	Parameters *Parameters
	Result     Node
	// contains filtered or unexported fields
}

Signature describes a function signature.

Signature = Parameters [ Result ] .

func (Signature) IsUncheckedType

func (t Signature) IsUncheckedType() bool

IsUncheckedType returns true when a type check of a Node was not performed.

func (*Signature) Position

func (n *Signature) Position() (r token.Position)

Position implements Node.

func (*Signature) Source

func (n *Signature) Source(full bool) []byte

Source implements Node.

func (*Signature) Tokens

func (n *Signature) Tokens() []Token

Tokens returns the tokens n consist of.

func (Signature) Type

func (t Signature) Type() Type

Type returns the type of a node or Invalid if the type is unknown/undetermined.

type SliceExpr

type SliceExpr struct {
	PrimaryExpr Expression
	LBracket    Token
	Expr        Expression
	Colon       Token
	Expr2       Expression
	Colon2      Token
	Expr3       Expression
	RBracket    Token
	// contains filtered or unexported fields
}

SliceExpr describes a slice expression.

SliceExpr = "[" [ Expression ] ":" [ Expression ] "]" | "[" [ Expression ] ":" Expression ":" Expression "]" .

func (SliceExpr) IsUncheckedType

func (t SliceExpr) IsUncheckedType() bool

IsUncheckedType returns true when a type check of a Node was not performed.

func (*SliceExpr) Position

func (n *SliceExpr) Position() (r token.Position)

Position implements Node.

func (*SliceExpr) SetValue

func (v *SliceExpr) SetValue(val constant.Value)

SetValue implements Expression

func (*SliceExpr) Source

func (n *SliceExpr) Source(full bool) []byte

Source implements Node.

func (*SliceExpr) Tokens

func (n *SliceExpr) Tokens() []Token

Tokens returns the tokens n consist of.

func (SliceExpr) Type

func (t SliceExpr) Type() Type

Type returns the type of a node or Invalid if the type is unknown/undetermined.

func (SliceExpr) Value

func (v SliceExpr) Value() constant.Value

Value implements Expression

type SliceType

type SliceType struct {
	Elem Type
	// contains filtered or unexported fields
}

SliceType represents a slice type.

func (*SliceType) Kind

func (t *SliceType) Kind() Kind

Kind implements Type.

func (*SliceType) Position

func (t *SliceType) Position() (r token.Position)

Position implements Node.

func (SliceType) Source

func (SliceType) Source(bool) []byte

Source implements Node. It returns nil.

func (*SliceType) String

func (t *SliceType) String() string

func (SliceType) Tokens

func (SliceType) Tokens() []Token

Tokens implements Node. It returns nil.

type SliceTypeNode

type SliceTypeNode struct {
	LBracket    Token
	RBracket    Token
	ElementType Node
	// contains filtered or unexported fields
}

SliceTypeNode describes a slice type.

SliceTypeNode = "[" "]" ElementType .

func (*SliceTypeNode) Position

func (n *SliceTypeNode) Position() (r token.Position)

Position implements Node.

func (*SliceTypeNode) Source

func (n *SliceTypeNode) Source(full bool) []byte

Source implements Node.

func (*SliceTypeNode) Tokens

func (n *SliceTypeNode) Tokens() []Token

Tokens returns the tokens n consist of.

type SourceFile

type SourceFile struct {
	PackageClause *PackageClause
	ImportDecls   []*ImportDecl
	TopLevelDecls []Node
	EOF           Token
	Scope         *Scope
	// contains filtered or unexported fields
}

SourceFile describes a source file.

SourceFile = PackageClause ";" { ImportDecl ";" } { TopLevelDecl ";" } .

func ParseSourceFile

func ParseSourceFile(cfg *ParseSourceFileConfig, name string, buf []byte) (r *SourceFile, err error)

ParseSourceFile parses buf and returns a *SourceFile or an error, if any. Positions are reported as if buf is coming from a file named name. The buffer becomes owned by the *SourceFile and must not be modified after calling ParseSourceFile. The same cfg argument must be used for all source files within a package. Distinct, new instances of the cfg arguments must be used for distinct packages.

func (*SourceFile) Position

func (n *SourceFile) Position() (r token.Position)

Position implements Node.

func (*SourceFile) Source

func (n *SourceFile) Source(full bool) []byte

Source implements Node.

func (*SourceFile) Tokens

func (n *SourceFile) Tokens() []Token

Tokens returns the tokens n consist of.

type StructType

type StructType struct {
	Fields []*Field
	// contains filtered or unexported fields
}

StructType represents a struct type.

func (*StructType) FieldByName

func (t *StructType) FieldByName(nm string) *Field

FieldByName returns the field named nm or nil, if no such field exists.

func (*StructType) Kind

func (t *StructType) Kind() Kind

Kind implements Type.

func (*StructType) Position

func (t *StructType) Position() (r token.Position)

Position implements Node.

func (StructType) Source

func (StructType) Source(bool) []byte

Source implements Node. It returns nil.

func (*StructType) String

func (t *StructType) String() string

func (StructType) Tokens

func (StructType) Tokens() []Token

Tokens implements Node. It returns nil.

type StructTypeNode

type StructTypeNode struct {
	Struct     Token
	LBrace     Token
	FieldDecls []Node
	RBrace     Token
	// contains filtered or unexported fields
}

StructTypeNode describes a struct type.

StructTyp = "struct" "{" { FieldDecl ";" } "}" .

func (StructTypeNode) IsUncheckedType

func (t StructTypeNode) IsUncheckedType() bool

IsUncheckedType returns true when a type check of a Node was not performed.

func (*StructTypeNode) Position

func (n *StructTypeNode) Position() (r token.Position)

Position implements Node.

func (*StructTypeNode) Source

func (n *StructTypeNode) Source(full bool) []byte

Source implements Node.

func (*StructTypeNode) Tokens

func (n *StructTypeNode) Tokens() []Token

Tokens returns the tokens n consist of.

func (StructTypeNode) Type

func (t StructTypeNode) Type() Type

Type returns the type of a node or Invalid if the type is unknown/undetermined.

type Token

type Token struct {
	Ch
	// contains filtered or unexported fields
}

Token is the product of Scanner.Scan and a terminal node of the complete syntax tree.

func (Token) IsValid

func (n Token) IsValid() bool

IsValid reports the validity of n. Tokens not present in some nodes will report false.

func (*Token) Offset

func (n *Token) Offset() int

Offset reports n's offset, in bytes, within its source file.

func (Token) Position

func (n Token) Position() (r token.Position)

Position implements Node.

func (Token) Sep

func (n Token) Sep() string

Sep returns the whitespace preceding n, if any.

func (*Token) Set

func (n *Token) Set(sep, src string)

Set sets the result of n.Sep to be sep and n.Src() to be src. Set will allocate at least len(sep+src) bytes of additional memory.

func (*Token) SetSep

func (n *Token) SetSep(sep string)

SetSep sets the result of n.Sep to be sep. SetSep will allocate at least len(sep+n.Src()) bytes of additional memory.

func (*Token) SetSrc

func (n *Token) SetSrc(src string)

SetSrc sets the result of n.Src to be src. SetSrc will allocate at least len(n.Sep()+src()) bytes of additional memory.

func (Token) Source

func (n Token) Source(full bool) []byte

Source implements Node.

func (Token) Src

func (n Token) Src() string

Src returns the textual form of n.

func (Token) String

func (n Token) String() string

String pretty formats n.

func (Token) Tokens

func (n Token) Tokens() []Token

Tokens returns the tokens n consist of.

type TupleType

type TupleType struct {
	Types []Type
}

TupleType represents an ordered list of types.

func (*TupleType) Kind

func (t *TupleType) Kind() Kind

Kind implements Type.

func (*TupleType) Position

func (t *TupleType) Position() (r token.Position)

Position implements Node.

func (*TupleType) Source

func (t *TupleType) Source(bool) []byte

Source implements Node. It returns nil.

func (*TupleType) String

func (t *TupleType) String() string

func (*TupleType) Tokens

func (t *TupleType) Tokens() []Token

Tokens implements Node. It returns nil.

type Type

type Type interface {
	fmt.Stringer
	Node
	// Kind returns the specific kind of a type.
	Kind() Kind
}

Type is the representation of a Go type.

The dynamic type of a Type is one of

*AliasType
*ArrayType
*ChannelType
*FunctionType
*InterfaceType
*InvalidType
*InvalidType
*MapType
*PointerType
*SliceType
*StructType
*TupleType
*TypeName
PredefinedType
var (
	Invalid            Type = &InvalidType{}
	UntypedBoolType    Type = PredefinedType(UntypedBool)
	UntypedComplexType Type = PredefinedType(UntypedComplex)
	UntypedFloatType   Type = PredefinedType(UntypedFloat)
	UntypedIntType     Type = PredefinedType(UntypedInt)
	UntypedNilType     Type = PredefinedType(UntypedNil)
	UntypedStringType  Type = PredefinedType(UntypedString)
)

Singleton instances of some compile-time only pseudo types.

type TypeArgs

type TypeArgs struct {
	LBracket Token
	TypeList []*TypeListItem
	RBracket Token
	Comma    Token
}

TypeArgs describes a type name.

TypeArgs = "[" TypeList [ "," ] "]" .

func (*TypeArgs) Position

func (n *TypeArgs) Position() (r token.Position)

Position implements Node.

func (*TypeArgs) Source

func (n *TypeArgs) Source(full bool) []byte

Source implements Node.

func (*TypeArgs) Tokens

func (n *TypeArgs) Tokens() []Token

Tokens returns the tokens n consist of.

type TypeAssertion

type TypeAssertion struct {
	PrimaryExpr Expression
	Dot         Token
	LParen      Token
	AssertType  Node
	RParen      Token
	// contains filtered or unexported fields
}

TypeAssertion describes a type assertion.

TypeAssertion = PrimaryExpr "." "(" Type ")" .

func (TypeAssertion) IsUncheckedType

func (t TypeAssertion) IsUncheckedType() bool

IsUncheckedType returns true when a type check of a Node was not performed.

func (*TypeAssertion) Position

func (n *TypeAssertion) Position() (r token.Position)

Position implements Node.

func (*TypeAssertion) SetValue

func (v *TypeAssertion) SetValue(val constant.Value)

SetValue implements Expression

func (*TypeAssertion) Source

func (n *TypeAssertion) Source(full bool) []byte

Source implements Node.

func (*TypeAssertion) Tokens

func (n *TypeAssertion) Tokens() []Token

Tokens returns the tokens n consist of.

func (TypeAssertion) Type

func (t TypeAssertion) Type() Type

Type returns the type of a node or Invalid if the type is unknown/undetermined.

func (TypeAssertion) Value

func (v TypeAssertion) Value() constant.Value

Value implements Expression

type TypeCaseClause

type TypeCaseClause struct {
	TypeSwitchCase *TypeSwitchCase
	Colon          Token
	StatementList  []Node
}

TypeCaseClause describes a type switch case clause.

TypeCaseClause  = TypeSwitchCase ":" StatementList .

func (*TypeCaseClause) Position

func (n *TypeCaseClause) Position() (r token.Position)

Position implements Node.

func (*TypeCaseClause) Source

func (n *TypeCaseClause) Source(full bool) []byte

Source implements Node.

func (*TypeCaseClause) Tokens

func (n *TypeCaseClause) Tokens() []Token

Tokens returns the tokens n consist of.

type TypeDecl

type TypeDecl struct {
	TypeTok   Token
	LParen    Token
	TypeSpecs []Node
	RParen    Token
	Semicolon Token
}

TypeDecl describes a type declaration.

TypeDecl = "type" ( TypeSpec | "(" { TypeSpec ";" } ")" ) .

func (*TypeDecl) Position

func (n *TypeDecl) Position() (r token.Position)

Position implements Node.

func (*TypeDecl) Source

func (n *TypeDecl) Source(full bool) []byte

Source implements Node.

func (*TypeDecl) Tokens

func (n *TypeDecl) Tokens() []Token

Tokens returns the tokens n consist of.

type TypeDef

type TypeDef struct {
	Ident          Token
	TypeParameters *TypeParameters
	TypeNode       Node
	Semicolon      Token
	// contains filtered or unexported fields
}

TypeDef describes a type definition.

TypeDef = identifier [ TypeParameters ] Type .

func (TypeDef) IsUncheckedType

func (t TypeDef) IsUncheckedType() bool

IsUncheckedType returns true when a type check of a Node was not performed.

func (*TypeDef) Kind

func (t *TypeDef) Kind() Kind

Kind implements Type.

func (TypeDef) LexicalScope

func (n TypeDef) LexicalScope() *Scope

LexicalScope returns the lexical scope n appears in.

func (*TypeDef) Position

func (n *TypeDef) Position() (r token.Position)

Position implements Node.

func (*TypeDef) Source

func (n *TypeDef) Source(full bool) []byte

Source implements Node.

func (*TypeDef) String

func (t *TypeDef) String() string

func (*TypeDef) Tokens

func (n *TypeDef) Tokens() []Token

Tokens returns the tokens n consist of.

func (TypeDef) Type

func (t TypeDef) Type() Type

Type returns the type of a node or Invalid if the type is unknown/undetermined.

type TypeElem

type TypeElem struct {
	TypeTerms []*TypeTerm
	Semicolon Token
}

TypeElem describes a type element.

TypeElem = TypeTerm { "|" TypeTerm } .

func (*TypeElem) Position

func (n *TypeElem) Position() (r token.Position)

Position implements Node.

func (*TypeElem) Source

func (n *TypeElem) Source(full bool) []byte

Source implements Node.

func (*TypeElem) Tokens

func (n *TypeElem) Tokens() []Token

Tokens returns the tokens n consist of.

type TypeListItem

type TypeListItem struct {
	Type  Node
	Comma Token
}

TypeListItem describes an item of a type list.

func (*TypeListItem) Position

func (n *TypeListItem) Position() (r token.Position)

Position implements Node.

func (*TypeListItem) Source

func (n *TypeListItem) Source(full bool) []byte

Source implements Node.

func (*TypeListItem) Tokens

func (n *TypeListItem) Tokens() []Token

Tokens returns the tokens n consist of.

type TypeNameNode

type TypeNameNode struct {
	Name     *QualifiedIdent
	TypeArgs *TypeArgs
	// contains filtered or unexported fields
}

TypeNameNode describes a type name.

TypeNameNode = QualifiedIdent [ TypeArgs ]
	| identifier [ TypeArgs ] .

func (TypeNameNode) IsUncheckedType

func (t TypeNameNode) IsUncheckedType() bool

IsUncheckedType returns true when a type check of a Node was not performed.

func (*TypeNameNode) Position

func (n *TypeNameNode) Position() (r token.Position)

Position implements Node.

func (*TypeNameNode) Source

func (n *TypeNameNode) Source(full bool) []byte

Source implements Node.

func (*TypeNameNode) Tokens

func (n *TypeNameNode) Tokens() []Token

Tokens returns the tokens n consist of.

func (TypeNameNode) Type

func (t TypeNameNode) Type() Type

Type returns the type of a node or Invalid if the type is unknown/undetermined.

type TypeParamDecl

type TypeParamDecl struct {
	IdentifierList []*IdentListItem
	TypeConstraint *TypeElem
	Comma          Token
}

TypeParamDecl describes an item of a type parameter list.

TypeParamDecl = IdentifierList TypeConstraint .

func (*TypeParamDecl) Position

func (n *TypeParamDecl) Position() (r token.Position)

Position implements Node.

func (*TypeParamDecl) Source

func (n *TypeParamDecl) Source(full bool) []byte

Source implements Node.

func (*TypeParamDecl) Tokens

func (n *TypeParamDecl) Tokens() []Token

Tokens returns the tokens n consist of.

type TypeParameters

type TypeParameters struct {
	LBracket      Token
	TypeParamList []*TypeParamDecl
	RBracket      Token
}

TypeParameters describes type parameters.

TypeParameters = "[" TypeParamList [ "," ] "]" .

func (*TypeParameters) Position

func (n *TypeParameters) Position() (r token.Position)

Position implements Node.

func (*TypeParameters) Source

func (n *TypeParameters) Source(full bool) []byte

Source implements Node.

func (*TypeParameters) Tokens

func (n *TypeParameters) Tokens() []Token

Tokens returns the tokens n consist of.

type TypeSwitchCase

type TypeSwitchCase struct {
	CaseOrDefault Token
	TypeList      []*TypeListItem
}

TypeSwitchCase describes an expression switch case.

TypeSwitchCase  = "case" TypeList | "default" .

func (*TypeSwitchCase) Position

func (n *TypeSwitchCase) Position() (r token.Position)

Position implements Node.

func (*TypeSwitchCase) Source

func (n *TypeSwitchCase) Source(full bool) []byte

Source implements Node.

func (*TypeSwitchCase) Tokens

func (n *TypeSwitchCase) Tokens() []Token

Tokens returns the tokens n consist of.

type TypeSwitchGuard

type TypeSwitchGuard struct {
	Ident       Token
	Define      Token
	PrimaryExpr Expression
	Dot         Token
	LParen      Token
	TypeToken   Token
	RParen      Token
	// contains filtered or unexported fields
}

TypeSwitchGuard describes a type switch guard.

TypeSwitchGuard = [ identifier ":=" ] PrimaryExpr "." "(" "type" ")" .

func (TypeSwitchGuard) IsUncheckedType

func (t TypeSwitchGuard) IsUncheckedType() bool

IsUncheckedType returns true when a type check of a Node was not performed.

func (*TypeSwitchGuard) Position

func (n *TypeSwitchGuard) Position() (r token.Position)

Position implements Node.

func (*TypeSwitchGuard) SetValue

func (v *TypeSwitchGuard) SetValue(val constant.Value)

SetValue implements Expression

func (*TypeSwitchGuard) Source

func (n *TypeSwitchGuard) Source(full bool) []byte

Source implements Node.

func (*TypeSwitchGuard) Tokens

func (n *TypeSwitchGuard) Tokens() []Token

Tokens returns the tokens n consist of.

func (TypeSwitchGuard) Type

func (t TypeSwitchGuard) Type() Type

Type returns the type of a node or Invalid if the type is unknown/undetermined.

func (TypeSwitchGuard) Value

func (v TypeSwitchGuard) Value() constant.Value

Value implements Expression

type TypeSwitchStmt

type TypeSwitchStmt struct {
	Switch          Token
	SimpleStmt      Node
	Semicolon       Token
	TypeSwitchGuard *TypeSwitchGuard
	LBrace          Token
	TypeCaseClauses []*TypeCaseClause
	RBrace          Token
	Semicolon2      Token
	Scope           *Scope // Implicit scope of the switch statement
}

TypeSwitchStmt describes a type switch statement.

TypeSwitchStmt  = "switch" [ SimpleStmt ";" ] TypeSwitchGuard "{" { TypeCaseClause } "}" .

func (*TypeSwitchStmt) Position

func (n *TypeSwitchStmt) Position() (r token.Position)

Position implements Node.

func (*TypeSwitchStmt) Source

func (n *TypeSwitchStmt) Source(full bool) []byte

Source implements Node.

func (*TypeSwitchStmt) Tokens

func (n *TypeSwitchStmt) Tokens() []Token

Tokens returns the tokens n consist of.

type TypeTerm

type TypeTerm struct {
	Tilde Token
	Type  Node
	Pipe  Token
}

TypeTerm describes a type term.

TypeTerm = Type | UnderlyingType .
UnderlyingType = "~" Type .

func (*TypeTerm) Position

func (n *TypeTerm) Position() (r token.Position)

Position implements Node.

func (*TypeTerm) Source

func (n *TypeTerm) Source(full bool) []byte

Source implements Node.

func (*TypeTerm) Tokens

func (n *TypeTerm) Tokens() []Token

Tokens returns the tokens n consist of.

type UnaryExpr

type UnaryExpr struct {
	Op   Token
	Expr Expression
	// contains filtered or unexported fields
}

UnaryExpr describes an unary expression.

UnaryExpr = PrimaryExpr | unary_op UnaryExpr .

func (UnaryExpr) IsUncheckedType

func (t UnaryExpr) IsUncheckedType() bool

IsUncheckedType returns true when a type check of a Node was not performed.

func (*UnaryExpr) Position

func (n *UnaryExpr) Position() (r token.Position)

Position implements Node.

func (*UnaryExpr) SetValue

func (v *UnaryExpr) SetValue(val constant.Value)

SetValue implements Expression

func (*UnaryExpr) Source

func (n *UnaryExpr) Source(full bool) []byte

Source implements Node.

func (*UnaryExpr) Tokens

func (n *UnaryExpr) Tokens() []Token

Tokens returns the tokens n consist of.

func (UnaryExpr) Type

func (t UnaryExpr) Type() Type

Type returns the type of a node or Invalid if the type is unknown/undetermined.

func (UnaryExpr) Value

func (v UnaryExpr) Value() constant.Value

Value implements Expression

type VarDecl

type VarDecl struct {
	Var       Token
	LParen    Token
	VarSpecs  []*VarSpec
	RParen    Token
	Semicolon Token
	// contains filtered or unexported fields
}

VarDecl describes a variable declaration.

VarDecl = "var" ( VarSpec | "(" { VarSpec ";" } ")" ) .

func (VarDecl) LexicalScope

func (n VarDecl) LexicalScope() *Scope

LexicalScope returns the lexical scope n appears in.

func (*VarDecl) Position

func (n *VarDecl) Position() (r token.Position)

Position implements Node.

func (*VarDecl) Source

func (n *VarDecl) Source(full bool) []byte

Source implements Node.

func (*VarDecl) Tokens

func (n *VarDecl) Tokens() []Token

Tokens returns the tokens n consist of.

type VarSpec

type VarSpec struct {
	IdentifierList []*IdentListItem
	Type           Node
	Eq             Token
	ExprList       []*ExprListItem
	Semicolon      Token
}

VarSpec describes a variable specification.

VarSpec = IdentifierList ( Type [ "=" ExpressionList ] | "=" ExpressionList ) .

func (*VarSpec) Position

func (n *VarSpec) Position() (r token.Position)

Position implements Node.

func (*VarSpec) Source

func (n *VarSpec) Source(full bool) []byte

Source implements Node.

func (*VarSpec) Tokens

func (n *VarSpec) Tokens() []Token

Tokens returns the tokens n consist of.

type Variable

type Variable struct {
	Expr     Expression
	Ident    Token
	TypeNode Node
	// contains filtered or unexported fields
}

Variable represents a Go variable.

func (*Variable) IsParameter

func (n *Variable) IsParameter() bool

IsParameter reports whether n is a function/method parameter, result variable or receiver.

func (Variable) IsUncheckedType

func (t Variable) IsUncheckedType() bool

IsUncheckedType returns true when a type check of a Node was not performed.

func (Variable) LexicalScope

func (n Variable) LexicalScope() *Scope

LexicalScope returns the lexical scope n appears in.

func (*Variable) Position

func (n *Variable) Position() (r token.Position)

Position implements Node.

func (*Variable) SetValue

func (v *Variable) SetValue(val constant.Value)

SetValue implements Expression

func (*Variable) Source

func (n *Variable) Source(full bool) []byte

Source implements Node.

func (*Variable) Tokens

func (n *Variable) Tokens() []Token

Tokens returns the tokens n consist of.

func (Variable) Type

func (t Variable) Type() Type

Type returns the type of a node or Invalid if the type is unknown/undetermined.

func (Variable) Value

func (v Variable) Value() constant.Value

Value implements Expression

Directories

Path Synopsis
internal
ebnf command

Jump to

Keyboard shortcuts

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