Documentation
¶
Index ¶
- Variables
- type ABI
- type AbiType
- type AliasDecl
- type AliasType
- type Arguments
- type ArrayType
- type ArrayTypeNode
- type Assignment
- type BasicLit
- type BinaryExpr
- type Block
- type BreakStmt
- type Ch
- type ChanDir
- type ChannelType
- type ChannelTypeNode
- type CommCase
- type CommClause
- type CompositeLit
- type ConstDecl
- type ConstSpec
- type Constant
- type ContinueStmt
- type Conversion
- type DeferStmt
- type EmbeddedField
- type EmptyStmt
- type ExprCaseClause
- type ExprListItem
- type ExprSwitchCase
- type Expression
- type ExpressionStmt
- type ExpressionSwitchStmt
- type FallthroughStmt
- type Field
- type FieldDecl
- type ForClause
- type ForStmt
- type FunctionDecl
- type FunctionLit
- type FunctionType
- type FunctionTypeNode
- type GenericOperand
- type GoStmt
- type GotoStmt
- type Ident
- func (n Ident) LexicalScope() *Scope
- func (n *Ident) Position() (r token.Position)
- func (n *Ident) ResolvedTo() Node
- func (v *Ident) SetValue(val constant.Value)
- func (n *Ident) Source(full bool) []byte
- func (n *Ident) Tokens() []Token
- func (t Ident) Type() Type
- func (v Ident) Value() constant.Value
- type IdentListItem
- type IfStmt
- type ImportDecl
- type ImportSpec
- type IncDecStmt
- type Index
- type InterfaceType
- type InterfaceTypeNode
- type InvalidType
- type KeyedElement
- type Kind
- type LabeledStmt
- type LiteralValue
- type MapType
- type MapTypeNode
- type MethodDecl
- type MethodElem
- type MethodExpr
- type Node
- type Package
- type PackageChecker
- type PackageClause
- type Parameter
- type ParameterDecl
- type Parameters
- type ParenExpr
- type ParenType
- type ParseSourceFileConfig
- type PointerType
- type PointerTypeNode
- type PredefinedType
- type QualifiedIdent
- func (n QualifiedIdent) LexicalScope() *Scope
- func (n *QualifiedIdent) Position() (r token.Position)
- func (n *QualifiedIdent) ResolvedIn() *Package
- func (n *QualifiedIdent) ResolvedTo() Node
- func (v *QualifiedIdent) SetValue(val constant.Value)
- func (n *QualifiedIdent) Source(full bool) []byte
- func (n *QualifiedIdent) Tokens() []Token
- func (t QualifiedIdent) Type() Type
- func (v QualifiedIdent) Value() constant.Value
- type RangeClause
- type ReturnStmt
- type Scanner
- type Scope
- type Scoped
- type SelectStmt
- type Selector
- type SendStmt
- type ShortVarDecl
- type Signature
- type SliceExpr
- type SliceType
- type SliceTypeNode
- type SourceFile
- type StructType
- type StructTypeNode
- type Token
- func (n Token) IsValid() bool
- func (n *Token) Offset() int
- func (n Token) Position() (r token.Position)
- func (n Token) Sep() string
- func (n *Token) Set(sep, src string)
- func (n *Token) SetSep(sep string)
- func (n *Token) SetSrc(src string)
- func (n Token) Source(full bool) []byte
- func (n Token) Src() string
- func (n Token) String() string
- func (n Token) Tokens() []Token
- type TupleType
- type Type
- type TypeArgs
- type TypeAssertion
- type TypeCaseClause
- type TypeDecl
- type TypeDef
- type TypeElem
- type TypeListItem
- type TypeNameNode
- type TypeParamDecl
- type TypeParameters
- type TypeSwitchCase
- type TypeSwitchGuard
- type TypeSwitchStmt
- type TypeTerm
- type UnaryExpr
- type VarDecl
- type VarSpec
- type Variable
Constants ¶
This section is empty.
Variables ¶
var ( // ExtendedErrors optionally amends errors with a stack mini trace. Intended // for debugging only. ExtendedErrors bool )
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 ¶ added in v2.1.0
type ABI struct { ByteOrder binary.ByteOrder Types map[Kind]AbiType // contains filtered or unexported fields }
ABI describes selected parts of the Application Binary Interface.
type AliasDecl ¶ added in v2.0.2
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) LexicalScope ¶ added in v2.2.0
func (n AliasDecl) LexicalScope() *Scope
LexicalScope returns the lexical scope n appears in.
type AliasType ¶ added in v2.0.2
type AliasType struct {
// contains filtered or unexported fields
}
AliasType represents an alias type.
type Arguments ¶ added in v2.0.2
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 ] ) [ "..." ] [ "," ] ] ")" .
type ArrayType ¶ added in v2.0.2
ArrayType represents an array type.
type ArrayTypeNode ¶ added in v2.0.2
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) Position ¶ added in v2.0.2
func (n *ArrayTypeNode) Position() (r token.Position)
Position implements Node.
func (*ArrayTypeNode) Source ¶ added in v2.0.2
func (n *ArrayTypeNode) Source(full bool) []byte
Source implements Node.
func (*ArrayTypeNode) Tokens ¶ added in v2.1.0
func (n *ArrayTypeNode) Tokens() []Token
Tokens returns the tokens n consist of.
type Assignment ¶ added in v2.0.2
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 ¶ added in v2.0.2
func (n *Assignment) Position() (r token.Position)
Position implements Node.
func (*Assignment) Source ¶ added in v2.0.2
func (n *Assignment) Source(full bool) []byte
Source implements Node.
func (*Assignment) Tokens ¶ added in v2.1.0
func (n *Assignment) Tokens() []Token
Tokens returns the tokens n consist of.
type BasicLit ¶ added in v2.0.2
type BasicLit struct { Token Token // contains filtered or unexported fields }
BasicLit represents a basic literal.
type BinaryExpr ¶ added in v2.0.2
type BinaryExpr struct { A Expression Op Token B Expression // contains filtered or unexported fields }
BinaryExpr describes a binary expression.
func (*BinaryExpr) Position ¶ added in v2.0.2
func (n *BinaryExpr) Position() (r token.Position)
Position implements Node.
func (*BinaryExpr) Source ¶ added in v2.0.2
func (n *BinaryExpr) Source(full bool) []byte
Source implements Node.
func (*BinaryExpr) Tokens ¶ added in v2.1.0
func (n *BinaryExpr) Tokens() []Token
Tokens returns the tokens n consist of.
type Block ¶ added in v2.0.2
Block describes a compound statement.
Block = "{" StatementList "}" .
type BreakStmt ¶ added in v2.0.2
BreakStmt describes a continue statement.
BreakStmt = "break" [ Label ] .
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.
type ChannelType ¶ added in v2.0.2
ChannelType represents a channel type.
func (*ChannelType) Position ¶ added in v2.0.2
func (t *ChannelType) Position() (r token.Position)
Position implements Node.
func (*ChannelType) String ¶ added in v2.0.2
func (t *ChannelType) String() string
type ChannelTypeNode ¶ added in v2.0.2
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 ¶ added in v2.0.2
func (n *ChannelTypeNode) Position() (r token.Position)
Position implements Node.
func (*ChannelTypeNode) Source ¶ added in v2.0.2
func (n *ChannelTypeNode) Source(full bool) []byte
Source implements Node.
func (*ChannelTypeNode) Tokens ¶ added in v2.1.0
func (n *ChannelTypeNode) Tokens() []Token
Tokens returns the tokens n consist of.
type CommCase ¶ added in v2.0.2
CommCase describes an communication clause case.
CommCase = "case" ( SendStmt | RecvStmt ) | "default" .
type CommClause ¶ added in v2.0.2
CommClause describes an select statement communication clause.
CommClause = CommCase ":" StatementList .
func (*CommClause) Position ¶ added in v2.0.2
func (n *CommClause) Position() (r token.Position)
Position implements Node.
func (*CommClause) Source ¶ added in v2.0.2
func (n *CommClause) Source(full bool) []byte
Source implements Node.
func (*CommClause) Tokens ¶ added in v2.1.0
func (n *CommClause) Tokens() []Token
Tokens returns the tokens n consist of.
type CompositeLit ¶ added in v2.0.2
type CompositeLit struct { LiteralType Node LiteralValue *LiteralValue // contains filtered or unexported fields }
CompositeLit describes a composite literal.
CompositeLit = LiteralType LiteralValue .
func (*CompositeLit) Position ¶ added in v2.0.2
func (n *CompositeLit) Position() (r token.Position)
Position implements Node.
func (*CompositeLit) Source ¶ added in v2.0.2
func (n *CompositeLit) Source(full bool) []byte
Source implements Node.
func (*CompositeLit) Tokens ¶ added in v2.1.0
func (n *CompositeLit) Tokens() []Token
Tokens returns the tokens n consist of.
type ConstDecl ¶ added in v2.0.2
type ConstDecl struct { Const Token LParen Token ConstSpecs []*ConstSpec RParen Token Semicolon Token }
ConstDecl describes a constant declaration.
ConstDecl = "const" ( ConstSpec | "(" { ConstSpec ";" } ")" ) .
type ConstSpec ¶ added in v2.0.2
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 ] .
type Constant ¶ added in v2.0.2
type Constant struct { Expr Expression Ident Token // contains filtered or unexported fields }
Constant represents a Go constant.
type ContinueStmt ¶ added in v2.0.2
ContinueStmt describes a continue statement.
ContinueStmt = "continue" [ Label ] .
func (*ContinueStmt) Position ¶ added in v2.0.2
func (n *ContinueStmt) Position() (r token.Position)
Position implements Node.
func (*ContinueStmt) Source ¶ added in v2.0.2
func (n *ContinueStmt) Source(full bool) []byte
Source implements Node.
func (*ContinueStmt) Tokens ¶ added in v2.1.0
func (n *ContinueStmt) Tokens() []Token
Tokens returns the tokens n consist of.
type Conversion ¶ added in v2.0.2
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) Position ¶ added in v2.0.2
func (n *Conversion) Position() (r token.Position)
Position implements Node.
func (*Conversion) Source ¶ added in v2.0.2
func (n *Conversion) Source(full bool) []byte
Source implements Node.
func (*Conversion) Tokens ¶ added in v2.1.0
func (n *Conversion) Tokens() []Token
Tokens returns the tokens n consist of.
type DeferStmt ¶ added in v2.0.2
type DeferStmt struct { Defer Token Expr Expression Semicolon Token }
DeferStmt describes a defer statement.
DeferStmt = "defer" Expression .
type EmbeddedField ¶ added in v2.0.2
type EmbeddedField struct { Star Token TypeName *TypeNameNode }
EmbeddedField describes an embeded field.
EmbeddedField = [ "*" ] TypeName .
func (*EmbeddedField) Position ¶ added in v2.0.2
func (n *EmbeddedField) Position() (r token.Position)
Position implements Node.
func (*EmbeddedField) Source ¶ added in v2.0.2
func (n *EmbeddedField) Source(full bool) []byte
Source implements Node.
func (*EmbeddedField) Tokens ¶ added in v2.1.0
func (n *EmbeddedField) Tokens() []Token
Tokens returns the tokens n consist of.
type EmptyStmt ¶ added in v2.0.2
type EmptyStmt struct {
Semicolon Token
}
EmptyStmt describes an empty statement.
EmptyStmt = .
type ExprCaseClause ¶ added in v2.0.2
type ExprCaseClause struct { ExprSwitchCase *ExprSwitchCase Colon Token StatementList []Node }
ExprCaseClause describes an expression switch case clause.
ExprCaseClause = ExprSwitchCase ":" StatementList .
func (*ExprCaseClause) Position ¶ added in v2.0.2
func (n *ExprCaseClause) Position() (r token.Position)
Position implements Node.
func (*ExprCaseClause) Source ¶ added in v2.0.2
func (n *ExprCaseClause) Source(full bool) []byte
Source implements Node.
func (*ExprCaseClause) Tokens ¶ added in v2.1.0
func (n *ExprCaseClause) Tokens() []Token
Tokens returns the tokens n consist of.
type ExprListItem ¶ added in v2.0.2
type ExprListItem struct { Expr Expression Comma Token }
ExprListItem describes an item of an expression list.
ExpressionList = Expression { "," Expression } .
func (*ExprListItem) Position ¶ added in v2.0.2
func (n *ExprListItem) Position() (r token.Position)
Position implements Node.
func (*ExprListItem) Source ¶ added in v2.0.2
func (n *ExprListItem) Source(full bool) []byte
Source implements Node.
func (*ExprListItem) Tokens ¶ added in v2.1.0
func (n *ExprListItem) Tokens() []Token
Tokens returns the tokens n consist of.
type ExprSwitchCase ¶ added in v2.0.2
type ExprSwitchCase struct { CaseOrDefault Token ExprList []*ExprListItem }
ExprSwitchCase describes an expression switch case.
ExprSwitchCase = "case" ExpressionList | "default" .
func (*ExprSwitchCase) Position ¶ added in v2.0.2
func (n *ExprSwitchCase) Position() (r token.Position)
Position implements Node.
func (*ExprSwitchCase) Source ¶ added in v2.0.2
func (n *ExprSwitchCase) Source(full bool) []byte
Source implements Node.
func (*ExprSwitchCase) Tokens ¶ added in v2.1.0
func (n *ExprSwitchCase) Tokens() []Token
Tokens returns the tokens n consist of.
type Expression ¶ added in v2.0.2
type Expression interface { Node Type() Type Value() constant.Value SetValue(constant.Value) // contains filtered or unexported methods }
Expression represents a computation.
type ExpressionStmt ¶ added in v2.0.2
type ExpressionStmt struct { Expr Expression Semicolon Token }
ExpressionStmt describes an expression statement.
func (*ExpressionStmt) Position ¶ added in v2.0.2
func (n *ExpressionStmt) Position() (r token.Position)
Position implements Node.
func (*ExpressionStmt) Source ¶ added in v2.0.2
func (n *ExpressionStmt) Source(full bool) []byte
Source implements Node.
func (*ExpressionStmt) Tokens ¶ added in v2.1.0
func (n *ExpressionStmt) Tokens() []Token
Tokens returns the tokens n consist of.
type ExpressionSwitchStmt ¶ added in v2.0.2
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 ¶ added in v2.0.2
func (n *ExpressionSwitchStmt) Position() (r token.Position)
Position implements Node.
func (*ExpressionSwitchStmt) Source ¶ added in v2.0.2
func (n *ExpressionSwitchStmt) Source(full bool) []byte
Source implements Node.
func (*ExpressionSwitchStmt) Tokens ¶ added in v2.1.0
func (n *ExpressionSwitchStmt) Tokens() []Token
Tokens returns the tokens n consist of.
type FallthroughStmt ¶ added in v2.0.2
FallthroughStmt describes a fallthrough statement.
FallthroughStmt = "fallthrough" .
func (*FallthroughStmt) Position ¶ added in v2.0.2
func (n *FallthroughStmt) Position() (r token.Position)
Position implements Node.
func (*FallthroughStmt) Source ¶ added in v2.0.2
func (n *FallthroughStmt) Source(full bool) []byte
Source implements Node.
func (*FallthroughStmt) Tokens ¶ added in v2.1.0
func (n *FallthroughStmt) Tokens() []Token
Tokens returns the tokens n consist of.
type Field ¶ added in v2.0.2
type Field struct { Name string // contains filtered or unexported fields }
Field represents a struct field.
type FieldDecl ¶ added in v2.0.2
type FieldDecl struct { IdentifierList []*IdentListItem Type Node EmbeddedField *EmbeddedField Tag Token Semicolon Token }
FieldDecl describes a field declaration.
FieldDecl = (IdentifierList Type | EmbeddedField) [ Tag ] .
type ForClause ¶ added in v2.0.2
type ForClause struct { InitStmt Node Semicolon Token Condition Expression Semicolon2 Token PostStmt Node }
ForClause describes a for clause.
ForClause = [ InitStmt ] ";" [ Condition ] ";" [ PostStmt ] .
type ForStmt ¶ added in v2.0.2
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 .
type FunctionDecl ¶ added in v2.0.2
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) Position ¶ added in v2.0.2
func (n *FunctionDecl) Position() (r token.Position)
Position implements Node.
func (*FunctionDecl) Source ¶ added in v2.0.2
func (n *FunctionDecl) Source(full bool) []byte
Source implements Node.
func (*FunctionDecl) Tokens ¶ added in v2.1.0
func (n *FunctionDecl) Tokens() []Token
Tokens returns the tokens n consist of.
type FunctionLit ¶ added in v2.0.2
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) Position ¶ added in v2.0.2
func (n *FunctionLit) Position() (r token.Position)
Position implements Node.
func (*FunctionLit) Source ¶ added in v2.0.2
func (n *FunctionLit) Source(full bool) []byte
Source implements Node.
func (*FunctionLit) Tokens ¶ added in v2.1.0
func (n *FunctionLit) Tokens() []Token
Tokens returns the tokens n consist of.
type FunctionType ¶ added in v2.0.2
type FunctionType struct { Parameters *TupleType Result *TupleType IsVariadic bool // contains filtered or unexported fields }
FunctionType represents a channel type.
func (*FunctionType) Kind ¶ added in v2.0.2
func (t *FunctionType) Kind() Kind
Kind implements Type.
func (*FunctionType) Position ¶ added in v2.0.2
func (t *FunctionType) Position() (r token.Position)
Position implements Node.
func (*FunctionType) String ¶ added in v2.0.2
func (t *FunctionType) String() string
type FunctionTypeNode ¶ added in v2.0.2
type FunctionTypeNode struct { Func Token Signature *Signature // contains filtered or unexported fields }
FunctionTypeNode describes a function type.
FunctionTypeNode = "func" Signature .
func (*FunctionTypeNode) Position ¶ added in v2.0.2
func (n *FunctionTypeNode) Position() (r token.Position)
Position implements Node.
func (*FunctionTypeNode) Source ¶ added in v2.0.2
func (n *FunctionTypeNode) Source(full bool) []byte
Source implements Node.
func (*FunctionTypeNode) Tokens ¶ added in v2.1.0
func (n *FunctionTypeNode) Tokens() []Token
Tokens returns the tokens n consist of.
type GenericOperand ¶ added in v2.0.2
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) Position ¶ added in v2.0.2
func (n *GenericOperand) Position() (r token.Position)
Position implements Node.
func (*GenericOperand) Source ¶ added in v2.0.2
func (n *GenericOperand) Source(full bool) []byte
Source implements Node.
func (*GenericOperand) Tokens ¶ added in v2.1.0
func (n *GenericOperand) Tokens() []Token
Tokens returns the tokens n consist of.
type GoStmt ¶ added in v2.0.2
type GoStmt struct { Go Token Expr Expression Semicolon Token }
GoStmt describes a go statement.
GoStmt = "go" Expression .
type GotoStmt ¶ added in v2.0.2
GotoStmt describes a goto statement.
GotoStmt = "goto" Label .
type Ident ¶ added in v2.0.2
type Ident struct { Token Token // contains filtered or unexported fields }
Ident represents an unqualified operand/type name.
func (Ident) LexicalScope ¶ added in v2.0.2
func (n Ident) LexicalScope() *Scope
LexicalScope returns the lexical scope n appears in.
func (*Ident) ResolvedTo ¶ added in v2.0.2
ResolvedTo returns the node n refers to. Valid after type checking.
type IdentListItem ¶ added in v2.0.2
IdentListItem describes an item of an identifier list.
func (*IdentListItem) Position ¶ added in v2.0.2
func (n *IdentListItem) Position() (r token.Position)
Position implements Node.
func (*IdentListItem) Source ¶ added in v2.0.2
func (n *IdentListItem) Source(full bool) []byte
Source implements Node.
func (*IdentListItem) Tokens ¶ added in v2.1.0
func (n *IdentListItem) Tokens() []Token
Tokens returns the tokens n consist of.
type IfStmt ¶ added in v2.0.2
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 ) ] .
type ImportDecl ¶ added in v2.0.1
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 ¶ added in v2.0.1
func (n *ImportDecl) Position() (r token.Position)
Position implements Node.
func (*ImportDecl) Source ¶ added in v2.0.2
func (n *ImportDecl) Source(full bool) []byte
Source implements Node.
func (*ImportDecl) Tokens ¶ added in v2.1.0
func (n *ImportDecl) Tokens() []Token
Tokens returns the tokens n consist of.
type ImportSpec ¶ added in v2.0.2
ImportSpec describes an import specification.
ImportSpec = [ "." | PackageName ] ImportPath .
func (*ImportSpec) Position ¶ added in v2.0.2
func (n *ImportSpec) Position() (r token.Position)
Position implements Node.
func (*ImportSpec) Source ¶ added in v2.0.2
func (n *ImportSpec) Source(full bool) []byte
Source implements Node.
func (*ImportSpec) Tokens ¶ added in v2.1.0
func (n *ImportSpec) Tokens() []Token
Tokens returns the tokens n consist of.
type IncDecStmt ¶ added in v2.0.2
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 ¶ added in v2.0.2
func (n *IncDecStmt) Position() (r token.Position)
Position implements Node.
func (*IncDecStmt) Source ¶ added in v2.0.2
func (n *IncDecStmt) Source(full bool) []byte
Source implements Node.
func (*IncDecStmt) Tokens ¶ added in v2.1.0
func (n *IncDecStmt) Tokens() []Token
Tokens returns the tokens n consist of.
type Index ¶ added in v2.0.2
type Index struct { PrimaryExpr Expression LBracket Token Expr Expression RBracket Token // contains filtered or unexported fields }
Index describes an index.
Index = "[" Expression "]" .
type InterfaceType ¶ added in v2.0.2
type InterfaceType struct { Elems []Node //TODO // contains filtered or unexported fields }
InterfaceType represents an interface type.
func (*InterfaceType) Kind ¶ added in v2.0.2
func (t *InterfaceType) Kind() Kind
Kind implements Type.
func (*InterfaceType) Position ¶ added in v2.0.2
func (t *InterfaceType) Position() (r token.Position)
Position implements Node.
func (*InterfaceType) String ¶ added in v2.0.2
func (t *InterfaceType) String() string
type InterfaceTypeNode ¶ added in v2.0.2
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) Position ¶ added in v2.0.2
func (n *InterfaceTypeNode) Position() (r token.Position)
Position implements Node.
func (*InterfaceTypeNode) Source ¶ added in v2.0.2
func (n *InterfaceTypeNode) Source(full bool) []byte
Source implements Node.
func (*InterfaceTypeNode) Tokens ¶ added in v2.1.0
func (n *InterfaceTypeNode) Tokens() []Token
Tokens returns the tokens n consist of.
type InvalidType ¶ added in v2.0.2
type InvalidType struct {
// contains filtered or unexported fields
}
InvalidType represents an invalid type.
func (*InvalidType) Position ¶ added in v2.0.2
func (t *InvalidType) Position() (r token.Position)
Position implements Node. Position returns a zero value.
func (*InvalidType) String ¶ added in v2.0.2
func (t *InvalidType) String() string
type KeyedElement ¶ added in v2.0.2
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) Position ¶ added in v2.0.2
func (n *KeyedElement) Position() (r token.Position)
Position implements Node.
func (*KeyedElement) Source ¶ added in v2.0.2
func (n *KeyedElement) Source(full bool) []byte
Source implements Node.
func (*KeyedElement) Tokens ¶ added in v2.1.0
func (n *KeyedElement) Tokens() []Token
Tokens returns the tokens n consist of.
type Kind ¶ added in v2.0.2
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
type LabeledStmt ¶ added in v2.0.2
LabeledStmt describes a labeled statement.
LabeledStmt = Label ":" Statement .
func (*LabeledStmt) Position ¶ added in v2.0.2
func (n *LabeledStmt) Position() (r token.Position)
Position implements Node.
func (*LabeledStmt) Source ¶ added in v2.0.2
func (n *LabeledStmt) Source(full bool) []byte
Source implements Node.
func (*LabeledStmt) Tokens ¶ added in v2.1.0
func (n *LabeledStmt) Tokens() []Token
Tokens returns the tokens n consist of.
type LiteralValue ¶ added in v2.0.2
type LiteralValue struct { LBrace Token ElementList []*KeyedElement RBrace Token }
LiteralValue describes a composite literal value.
LiteralValue = "{" [ ElementList [ "," ] ] "}" .
func (*LiteralValue) Position ¶ added in v2.0.2
func (n *LiteralValue) Position() (r token.Position)
Position implements Node.
func (*LiteralValue) Source ¶ added in v2.0.2
func (n *LiteralValue) Source(full bool) []byte
Source implements Node.
func (*LiteralValue) Tokens ¶ added in v2.1.0
func (n *LiteralValue) Tokens() []Token
Tokens returns the tokens n consist of.
type MapType ¶ added in v2.0.2
MapType represents a map type.
type MapTypeNode ¶ added in v2.0.2
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 ¶ added in v2.0.2
func (n *MapTypeNode) Position() (r token.Position)
Position implements Node.
func (*MapTypeNode) Source ¶ added in v2.0.2
func (n *MapTypeNode) Source(full bool) []byte
Source implements Node.
func (*MapTypeNode) Tokens ¶ added in v2.1.0
func (n *MapTypeNode) Tokens() []Token
Tokens returns the tokens n consist of.
type MethodDecl ¶ added in v2.0.2
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) Position ¶ added in v2.0.2
func (n *MethodDecl) Position() (r token.Position)
Position implements Node.
func (*MethodDecl) Source ¶ added in v2.0.2
func (n *MethodDecl) Source(full bool) []byte
Source implements Node.
func (*MethodDecl) Tokens ¶ added in v2.1.0
func (n *MethodDecl) Tokens() []Token
Tokens returns the tokens n consist of.
type MethodElem ¶ added in v2.0.2
MethodElem describes a method element.
MethodElem = MethodName Signature .
func (*MethodElem) Position ¶ added in v2.0.2
func (n *MethodElem) Position() (r token.Position)
Position implements Node.
func (*MethodElem) Source ¶ added in v2.0.2
func (n *MethodElem) Source(full bool) []byte
Source implements Node.
func (*MethodElem) Tokens ¶ added in v2.1.0
func (n *MethodElem) Tokens() []Token
Tokens returns the tokens n consist of.
type MethodExpr ¶ added in v2.0.2
type MethodExpr struct { Receiver Node Dot Token Ident Token // contains filtered or unexported fields }
MethodExpr describes a method expression.
MethodExpr = ReceiverType "." MethodName .
func (*MethodExpr) Position ¶ added in v2.0.2
func (n *MethodExpr) Position() (r token.Position)
Position implements Node.
func (*MethodExpr) Source ¶ added in v2.0.2
func (n *MethodExpr) Source(full bool) []byte
Source implements Node.
func (*MethodExpr) Tokens ¶ added in v2.1.0
func (n *MethodExpr) Tokens() []Token
Tokens returns the tokens n consist of.
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 ¶ added in v2.0.2
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 ¶ added in v2.0.2
func NewPackage(importPath string, files []*SourceFile) (r *Package, err error)
NewPackage returns a newly created Package or an error, if any.
func (*Package) Check ¶ added in v2.0.2
func (n *Package) Check(checker PackageChecker) error
Check type checks n.
type PackageChecker ¶ added in v2.0.2
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 ¶ added in v2.0.1
PackageClause describes the package clause.
PackageClause = "package" PackageName .
func (*PackageClause) Position ¶ added in v2.0.1
func (n *PackageClause) Position() (r token.Position)
Position implements Node.
func (*PackageClause) Source ¶ added in v2.0.2
func (n *PackageClause) Source(full bool) []byte
Source implements Node.
func (*PackageClause) Tokens ¶ added in v2.1.0
func (n *PackageClause) Tokens() []Token
Tokens returns the tokens n consist of.
type Parameter ¶ added in v2.0.2
type Parameter struct { Name string // contains filtered or unexported fields }
Parameter represents a function input/output paramater.
type ParameterDecl ¶ added in v2.0.2
type ParameterDecl struct { IdentifierList []*IdentListItem Ellipsis Token Type Node Comma Token }
ParameterDecl describes a parameter declaration.
ParameterDecl = [ IdentifierList ] [ "..." ] Type .
func (*ParameterDecl) Position ¶ added in v2.0.2
func (n *ParameterDecl) Position() (r token.Position)
Position implements Node.
func (*ParameterDecl) Source ¶ added in v2.0.2
func (n *ParameterDecl) Source(full bool) []byte
Source implements Node.
func (*ParameterDecl) Tokens ¶ added in v2.1.0
func (n *ParameterDecl) Tokens() []Token
Tokens returns the tokens n consist of.
type Parameters ¶ added in v2.0.2
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 ¶ added in v2.0.2
func (n *Parameters) Position() (r token.Position)
Position implements Node.
func (*Parameters) Source ¶ added in v2.0.2
func (n *Parameters) Source(full bool) []byte
Source implements Node.
func (*Parameters) Tokens ¶ added in v2.1.0
func (n *Parameters) Tokens() []Token
Tokens returns the tokens n consist of.
type ParenExpr ¶ added in v2.0.2
type ParenExpr struct { LParen Token Expr Expression RParen Token // contains filtered or unexported fields }
ParenExpr describes a parenthesized expression.
ParenExpr = "(" Expression ")" .
type ParenType ¶ added in v2.0.2
type ParenType struct { LParen Token TypeNode Node RParen Token // contains filtered or unexported fields }
ParenType describes a parenthesized type.
ParenType = "(" Type ")" .
type ParseSourceFileConfig ¶ added in v2.0.1
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 ¶ added in v2.0.2
type PointerType struct { Elem Type // contains filtered or unexported fields }
PointerType represents a pointer type.
func (*PointerType) Position ¶ added in v2.0.2
func (t *PointerType) Position() (r token.Position)
Position implements Node.
func (*PointerType) String ¶ added in v2.0.2
func (t *PointerType) String() string
type PointerTypeNode ¶ added in v2.0.2
PointerTypeNode describes a pointer type.
PointerTypeNode = "*" BaseType .
func (*PointerTypeNode) Position ¶ added in v2.0.2
func (n *PointerTypeNode) Position() (r token.Position)
Position implements Node.
func (*PointerTypeNode) Source ¶ added in v2.0.2
func (n *PointerTypeNode) Source(full bool) []byte
Source implements Node.
func (*PointerTypeNode) Tokens ¶ added in v2.1.0
func (n *PointerTypeNode) Tokens() []Token
Tokens returns the tokens n consist of.
type PredefinedType ¶ added in v2.0.2
type PredefinedType Kind
PredefinedType represents a predefined type.
func (PredefinedType) Kind ¶ added in v2.0.2
func (t PredefinedType) Kind() Kind
Kind implements Type.
func (PredefinedType) Position ¶ added in v2.0.2
func (t PredefinedType) Position() (r token.Position)
Position implements Node. Position returns a zero value.
func (PredefinedType) Source ¶ added in v2.0.2
func (t PredefinedType) Source(full bool) []byte
Source implements Node. It returns nil.
func (PredefinedType) String ¶ added in v2.0.2
func (t PredefinedType) String() string
func (PredefinedType) Tokens ¶ added in v2.1.0
func (t PredefinedType) Tokens() []Token
Tokens implements Node. It returns nil.
type QualifiedIdent ¶ added in v2.0.2
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) LexicalScope ¶ added in v2.0.2
func (n QualifiedIdent) LexicalScope() *Scope
LexicalScope returns the lexical scope n appears in.
func (*QualifiedIdent) Position ¶ added in v2.0.2
func (n *QualifiedIdent) Position() (r token.Position)
Position implements Node.
func (*QualifiedIdent) ResolvedIn ¶ added in v2.0.2
func (n *QualifiedIdent) ResolvedIn() *Package
ResolvedIn returns the package n refers to. Valid after type checking.
func (*QualifiedIdent) ResolvedTo ¶ added in v2.0.2
func (n *QualifiedIdent) ResolvedTo() Node
ResolvedTo returns the node n refers to. Valid after type checking.
func (*QualifiedIdent) Source ¶ added in v2.0.2
func (n *QualifiedIdent) Source(full bool) []byte
Source implements Node.
func (*QualifiedIdent) Tokens ¶ added in v2.1.0
func (n *QualifiedIdent) Tokens() []Token
Tokens returns the tokens n consist of.
type RangeClause ¶ added in v2.0.2
type RangeClause struct { ExprList []*ExprListItem Assign Token Range Token Expr Expression }
RangeClause describes a range clause.
RangeClause = [ ExpressionList "=" | IdentifierList ":=" ] "range" Expression .
func (*RangeClause) Position ¶ added in v2.0.2
func (n *RangeClause) Position() (r token.Position)
Position implements Node.
func (*RangeClause) Source ¶ added in v2.0.2
func (n *RangeClause) Source(full bool) []byte
Source implements Node.
func (*RangeClause) Tokens ¶ added in v2.1.0
func (n *RangeClause) Tokens() []Token
Tokens returns the tokens n consist of.
type ReturnStmt ¶ added in v2.0.2
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 ¶ added in v2.0.2
func (n *ReturnStmt) Position() (r token.Position)
Position implements Node.
func (*ReturnStmt) Source ¶ added in v2.0.2
func (n *ReturnStmt) Source(full bool) []byte
Source implements Node.
func (*ReturnStmt) Tokens ¶ added in v2.1.0
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 ¶
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.
type Scoped ¶ added in v2.0.2
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 ¶ added in v2.0.2
type SelectStmt struct { Select Token LBrace Token CommClauses []*CommClause RBrace Token Semicolon Token }
SelectStmt describes a select statement.
SelectStmt = "select" "{" { CommClause } "}" .
func (*SelectStmt) Position ¶ added in v2.0.2
func (n *SelectStmt) Position() (r token.Position)
Position implements Node.
func (*SelectStmt) Source ¶ added in v2.0.2
func (n *SelectStmt) Source(full bool) []byte
Source implements Node.
func (*SelectStmt) Tokens ¶ added in v2.1.0
func (n *SelectStmt) Tokens() []Token
Tokens returns the tokens n consist of.
type Selector ¶ added in v2.0.2
type Selector struct { PrimaryExpr Expression Dot Token Ident Token // contains filtered or unexported fields }
Selector describes a selector.
Selector = PrimaryExpr "." identifier .
type SendStmt ¶ added in v2.0.2
type SendStmt struct { Channel Node Arrow Token Expr Expression Semicolon Token // contains filtered or unexported fields }
SendStmt describes a send statement.
SendStmt = Channel "<-" Expression .
type ShortVarDecl ¶ added in v2.0.2
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 ¶ added in v2.0.2
func (n ShortVarDecl) LexicalScope() *Scope
LexicalScope returns the lexical scope n appears in.
func (*ShortVarDecl) Position ¶ added in v2.0.2
func (n *ShortVarDecl) Position() (r token.Position)
Position implements Node.
func (*ShortVarDecl) Source ¶ added in v2.0.2
func (n *ShortVarDecl) Source(full bool) []byte
Source implements Node.
func (*ShortVarDecl) Tokens ¶ added in v2.1.0
func (n *ShortVarDecl) Tokens() []Token
Tokens returns the tokens n consist of.
type Signature ¶ added in v2.0.2
type Signature struct { Parameters *Parameters Result Node // contains filtered or unexported fields }
Signature describes a function signature.
Signature = Parameters [ Result ] .
type SliceExpr ¶ added in v2.0.2
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 "]" .
type SliceType ¶ added in v2.0.2
type SliceType struct { Elem Type // contains filtered or unexported fields }
SliceType represents a slice type.
type SliceTypeNode ¶ added in v2.0.2
type SliceTypeNode struct { LBracket Token RBracket Token ElementType Node // contains filtered or unexported fields }
SliceTypeNode describes a slice type.
SliceTypeNode = "[" "]" ElementType .
func (*SliceTypeNode) Position ¶ added in v2.0.2
func (n *SliceTypeNode) Position() (r token.Position)
Position implements Node.
func (*SliceTypeNode) Source ¶ added in v2.0.2
func (n *SliceTypeNode) Source(full bool) []byte
Source implements Node.
func (*SliceTypeNode) Tokens ¶ added in v2.1.0
func (n *SliceTypeNode) Tokens() []Token
Tokens returns the tokens n consist of.
type SourceFile ¶ added in v2.0.1
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 ¶ added in v2.0.1
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 ¶ added in v2.0.1
func (n *SourceFile) Position() (r token.Position)
Position implements Node.
func (*SourceFile) Source ¶ added in v2.0.2
func (n *SourceFile) Source(full bool) []byte
Source implements Node.
func (*SourceFile) Tokens ¶ added in v2.1.0
func (n *SourceFile) Tokens() []Token
Tokens returns the tokens n consist of.
type StructType ¶ added in v2.0.2
type StructType struct { Fields []*Field // contains filtered or unexported fields }
StructType represents a struct type.
func (*StructType) FieldByName ¶ added in v2.0.2
func (t *StructType) FieldByName(nm string) *Field
FieldByName returns the field named nm or nil, if no such field exists.
func (*StructType) Position ¶ added in v2.0.2
func (t *StructType) Position() (r token.Position)
Position implements Node.
func (*StructType) String ¶ added in v2.0.2
func (t *StructType) String() string
type StructTypeNode ¶ added in v2.0.2
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) Position ¶ added in v2.0.2
func (n *StructTypeNode) Position() (r token.Position)
Position implements Node.
func (*StructTypeNode) Source ¶ added in v2.0.2
func (n *StructTypeNode) Source(full bool) []byte
Source implements Node.
func (*StructTypeNode) Tokens ¶ added in v2.1.0
func (n *StructTypeNode) Tokens() []Token
Tokens returns the tokens n consist of.
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 ¶
IsValid reports the validity of n. Tokens not present in some nodes will report false.
func (*Token) Set ¶ added in v2.0.1
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 ¶ added in v2.0.2
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 ¶ added in v2.0.2
SetSrc sets the result of n.Src to be src. SetSrc will allocate at least len(n.Sep()+src()) bytes of additional memory.
type TupleType ¶ added in v2.0.2
type TupleType struct {
Types []Type
}
TupleType represents an ordered list of types.
type Type ¶ added in v2.0.2
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 ¶ added in v2.0.2
type TypeArgs struct { LBracket Token TypeList []*TypeListItem RBracket Token Comma Token }
TypeArgs describes a type name.
TypeArgs = "[" TypeList [ "," ] "]" .
type TypeAssertion ¶ added in v2.0.2
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) Position ¶ added in v2.0.2
func (n *TypeAssertion) Position() (r token.Position)
Position implements Node.
func (*TypeAssertion) Source ¶ added in v2.0.2
func (n *TypeAssertion) Source(full bool) []byte
Source implements Node.
func (*TypeAssertion) Tokens ¶ added in v2.1.0
func (n *TypeAssertion) Tokens() []Token
Tokens returns the tokens n consist of.
type TypeCaseClause ¶ added in v2.0.2
type TypeCaseClause struct { TypeSwitchCase *TypeSwitchCase Colon Token StatementList []Node }
TypeCaseClause describes a type switch case clause.
TypeCaseClause = TypeSwitchCase ":" StatementList .
func (*TypeCaseClause) Position ¶ added in v2.0.2
func (n *TypeCaseClause) Position() (r token.Position)
Position implements Node.
func (*TypeCaseClause) Source ¶ added in v2.0.2
func (n *TypeCaseClause) Source(full bool) []byte
Source implements Node.
func (*TypeCaseClause) Tokens ¶ added in v2.1.0
func (n *TypeCaseClause) Tokens() []Token
Tokens returns the tokens n consist of.
type TypeDecl ¶ added in v2.0.2
TypeDecl describes a type declaration.
TypeDecl = "type" ( TypeSpec | "(" { TypeSpec ";" } ")" ) .
type TypeDef ¶ added in v2.0.2
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) LexicalScope ¶ added in v2.2.0
func (n TypeDef) LexicalScope() *Scope
LexicalScope returns the lexical scope n appears in.
type TypeElem ¶ added in v2.0.2
TypeElem describes a type element.
TypeElem = TypeTerm { "|" TypeTerm } .
type TypeListItem ¶ added in v2.0.2
TypeListItem describes an item of a type list.
func (*TypeListItem) Position ¶ added in v2.0.2
func (n *TypeListItem) Position() (r token.Position)
Position implements Node.
func (*TypeListItem) Source ¶ added in v2.0.2
func (n *TypeListItem) Source(full bool) []byte
Source implements Node.
func (*TypeListItem) Tokens ¶ added in v2.1.0
func (n *TypeListItem) Tokens() []Token
Tokens returns the tokens n consist of.
type TypeNameNode ¶ added in v2.0.2
type TypeNameNode struct { Name *QualifiedIdent TypeArgs *TypeArgs // contains filtered or unexported fields }
TypeNameNode describes a type name.
TypeNameNode = QualifiedIdent [ TypeArgs ] | identifier [ TypeArgs ] .
func (*TypeNameNode) Position ¶ added in v2.0.2
func (n *TypeNameNode) Position() (r token.Position)
Position implements Node.
func (*TypeNameNode) Source ¶ added in v2.0.2
func (n *TypeNameNode) Source(full bool) []byte
Source implements Node.
func (*TypeNameNode) Tokens ¶ added in v2.1.0
func (n *TypeNameNode) Tokens() []Token
Tokens returns the tokens n consist of.
type TypeParamDecl ¶ added in v2.0.2
type TypeParamDecl struct { IdentifierList []*IdentListItem TypeConstraint *TypeElem Comma Token }
TypeParamDecl describes an item of a type parameter list.
TypeParamDecl = IdentifierList TypeConstraint .
func (*TypeParamDecl) Position ¶ added in v2.0.2
func (n *TypeParamDecl) Position() (r token.Position)
Position implements Node.
func (*TypeParamDecl) Source ¶ added in v2.0.2
func (n *TypeParamDecl) Source(full bool) []byte
Source implements Node.
func (*TypeParamDecl) Tokens ¶ added in v2.1.0
func (n *TypeParamDecl) Tokens() []Token
Tokens returns the tokens n consist of.
type TypeParameters ¶ added in v2.0.2
type TypeParameters struct { LBracket Token TypeParamList []*TypeParamDecl RBracket Token }
TypeParameters describes type parameters.
TypeParameters = "[" TypeParamList [ "," ] "]" .
func (*TypeParameters) Position ¶ added in v2.0.2
func (n *TypeParameters) Position() (r token.Position)
Position implements Node.
func (*TypeParameters) Source ¶ added in v2.0.2
func (n *TypeParameters) Source(full bool) []byte
Source implements Node.
func (*TypeParameters) Tokens ¶ added in v2.1.0
func (n *TypeParameters) Tokens() []Token
Tokens returns the tokens n consist of.
type TypeSwitchCase ¶ added in v2.0.2
type TypeSwitchCase struct { CaseOrDefault Token TypeList []*TypeListItem }
TypeSwitchCase describes an expression switch case.
TypeSwitchCase = "case" TypeList | "default" .
func (*TypeSwitchCase) Position ¶ added in v2.0.2
func (n *TypeSwitchCase) Position() (r token.Position)
Position implements Node.
func (*TypeSwitchCase) Source ¶ added in v2.0.2
func (n *TypeSwitchCase) Source(full bool) []byte
Source implements Node.
func (*TypeSwitchCase) Tokens ¶ added in v2.1.0
func (n *TypeSwitchCase) Tokens() []Token
Tokens returns the tokens n consist of.
type TypeSwitchGuard ¶ added in v2.0.2
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) Position ¶ added in v2.0.2
func (n *TypeSwitchGuard) Position() (r token.Position)
Position implements Node.
func (*TypeSwitchGuard) Source ¶ added in v2.0.2
func (n *TypeSwitchGuard) Source(full bool) []byte
Source implements Node.
func (*TypeSwitchGuard) Tokens ¶ added in v2.1.0
func (n *TypeSwitchGuard) Tokens() []Token
Tokens returns the tokens n consist of.
type TypeSwitchStmt ¶ added in v2.0.2
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 ¶ added in v2.0.2
func (n *TypeSwitchStmt) Position() (r token.Position)
Position implements Node.
func (*TypeSwitchStmt) Source ¶ added in v2.0.2
func (n *TypeSwitchStmt) Source(full bool) []byte
Source implements Node.
func (*TypeSwitchStmt) Tokens ¶ added in v2.1.0
func (n *TypeSwitchStmt) Tokens() []Token
Tokens returns the tokens n consist of.
type TypeTerm ¶ added in v2.0.2
TypeTerm describes a type term.
TypeTerm = Type | UnderlyingType . UnderlyingType = "~" Type .
type UnaryExpr ¶ added in v2.0.2
type UnaryExpr struct { Op Token Expr Expression // contains filtered or unexported fields }
UnaryExpr describes an unary expression.
UnaryExpr = PrimaryExpr | unary_op UnaryExpr .
type VarDecl ¶ added in v2.0.2
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 ¶ added in v2.0.2
func (n VarDecl) LexicalScope() *Scope
LexicalScope returns the lexical scope n appears in.
type VarSpec ¶ added in v2.0.2
type VarSpec struct { IdentifierList []*IdentListItem Type Node Eq Token ExprList []*ExprListItem Semicolon Token }
VarSpec describes a variable specification.
VarSpec = IdentifierList ( Type [ "=" ExpressionList ] | "=" ExpressionList ) .
type Variable ¶ added in v2.0.2
type Variable struct { Expr Expression Ident Token TypeNode Node // contains filtered or unexported fields }
Variable represents a Go variable.
func (*Variable) IsParameter ¶ added in v2.0.2
IsParameter reports whether n is a function/method parameter, result variable or receiver.