Documentation
¶
Index ¶
- Variables
- type ABI
- type AbiType
- type AliasDecl
- type AliasType
- type Arguments
- type ArrayType
- type ArrayTypeNode
- type Assignment
- type BasicLit
- type BinaryExpr
- func (t BinaryExpr) IsUncheckedType() bool
- func (n *BinaryExpr) Position() (r token.Position)
- func (v *BinaryExpr) SetValue(val constant.Value)
- func (n *BinaryExpr) Source(full bool) []byte
- func (n *BinaryExpr) Tokens() []Token
- func (t BinaryExpr) Type() Type
- func (v BinaryExpr) Value() constant.Value
- type Block
- type BreakStmt
- type Ch
- type ChanDir
- type ChannelType
- type ChannelTypeNode
- type CommCase
- type CommClause
- type CompositeLit
- func (t CompositeLit) IsUncheckedType() bool
- func (n *CompositeLit) Position() (r token.Position)
- func (v *CompositeLit) SetValue(val constant.Value)
- func (n *CompositeLit) Source(full bool) []byte
- func (n *CompositeLit) Tokens() []Token
- func (t CompositeLit) Type() Type
- func (v CompositeLit) Value() constant.Value
- type ConstDecl
- type ConstSpec
- type Constant
- type ContinueStmt
- type Conversion
- func (t Conversion) IsUncheckedType() bool
- func (n *Conversion) Position() (r token.Position)
- func (v *Conversion) SetValue(val constant.Value)
- func (n *Conversion) Source(full bool) []byte
- func (n *Conversion) Tokens() []Token
- func (t Conversion) Type() Type
- func (v Conversion) Value() constant.Value
- 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
- func (t FunctionLit) IsUncheckedType() bool
- func (n *FunctionLit) Position() (r token.Position)
- func (v *FunctionLit) SetValue(val constant.Value)
- func (n *FunctionLit) Source(full bool) []byte
- func (n *FunctionLit) Tokens() []Token
- func (t FunctionLit) Type() Type
- func (v FunctionLit) Value() constant.Value
- type FunctionType
- type FunctionTypeNode
- type GenericOperand
- func (t GenericOperand) IsUncheckedType() bool
- func (n *GenericOperand) Position() (r token.Position)
- func (v *GenericOperand) SetValue(val constant.Value)
- func (n *GenericOperand) Source(full bool) []byte
- func (n *GenericOperand) Tokens() []Token
- func (t GenericOperand) Type() Type
- func (v GenericOperand) Value() constant.Value
- type GoStmt
- type GotoStmt
- type Ident
- func (t Ident) IsUncheckedType() bool
- 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
- func (t MethodExpr) IsUncheckedType() bool
- func (n *MethodExpr) Position() (r token.Position)
- func (v *MethodExpr) SetValue(val constant.Value)
- func (n *MethodExpr) Source(full bool) []byte
- func (n *MethodExpr) Tokens() []Token
- func (t MethodExpr) Type() Type
- func (v MethodExpr) Value() constant.Value
- 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 (t QualifiedIdent) IsUncheckedType() bool
- 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
- func (t TypeAssertion) IsUncheckedType() bool
- func (n *TypeAssertion) Position() (r token.Position)
- func (v *TypeAssertion) SetValue(val constant.Value)
- func (n *TypeAssertion) Source(full bool) []byte
- func (n *TypeAssertion) Tokens() []Token
- func (t TypeAssertion) Type() Type
- func (v TypeAssertion) Value() constant.Value
- type TypeCaseClause
- type TypeDecl
- type TypeDef
- type TypeElem
- type TypeListItem
- type TypeNameNode
- type TypeParamDecl
- type TypeParameters
- type TypeSwitchCase
- type TypeSwitchGuard
- func (t TypeSwitchGuard) IsUncheckedType() bool
- func (n *TypeSwitchGuard) Position() (r token.Position)
- func (v *TypeSwitchGuard) SetValue(val constant.Value)
- func (n *TypeSwitchGuard) Source(full bool) []byte
- func (n *TypeSwitchGuard) Tokens() []Token
- func (t TypeSwitchGuard) Type() Type
- func (v TypeSwitchGuard) Value() constant.Value
- type TypeSwitchStmt
- type TypeTerm
- type UnaryExpr
- type VarDecl
- type VarSpec
- type Variable
- func (n *Variable) IsParameter() bool
- func (t Variable) IsUncheckedType() bool
- func (n Variable) LexicalScope() *Scope
- func (n *Variable) Position() (r token.Position)
- func (v *Variable) SetValue(val constant.Value)
- func (n *Variable) Source(full bool) []byte
- func (n *Variable) Tokens() []Token
- func (t Variable) Type() Type
- func (v Variable) Value() constant.Value
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 ¶
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 ¶
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.
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.
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.
type ArrayType ¶
ArrayType represents an array type.
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.
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) 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.
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) Tokens ¶
func (n *BinaryExpr) Tokens() []Token
Tokens returns the tokens n consist of.
type BreakStmt ¶
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 ¶
ChannelType represents a channel type.
func (*ChannelType) Position ¶
func (t *ChannelType) Position() (r token.Position)
Position implements Node.
func (*ChannelType) String ¶
func (t *ChannelType) String() string
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 ¶
CommCase describes an communication clause case.
CommCase = "case" ( SendStmt | RecvStmt ) | "default" .
type CommClause ¶
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) 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) 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.
type ConstDecl ¶
type ConstDecl struct {
Const Token
LParen Token
ConstSpecs []*ConstSpec
RParen Token
Semicolon Token
}
ConstDecl describes a constant declaration.
ConstDecl = "const" ( ConstSpec | "(" { ConstSpec ";" } ")" ) .
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 ] .
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.
type ContinueStmt ¶
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) Tokens ¶
func (n *Conversion) Tokens() []Token
Tokens returns the tokens n consist of.
type DeferStmt ¶
type DeferStmt struct {
Defer Token
Expr Expression
Semicolon Token
}
DeferStmt describes a defer statement.
DeferStmt = "defer" Expression .
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 = .
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 ¶
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 (Field) IsUncheckedType ¶
func (t Field) IsUncheckedType() bool
IsUncheckedType returns true when a type check of a Node was not performed.
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 ] .
type ForClause ¶
type ForClause struct {
InitStmt Node
Semicolon Token
Condition Expression
Semicolon2 Token
PostStmt Node
}
ForClause describes a for clause.
ForClause = [ InitStmt ] ";" [ Condition ] ";" [ PostStmt ] .
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 .
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.
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) Tokens ¶
func (n *FunctionLit) Tokens() []Token
Tokens returns the tokens n consist of.
type FunctionType ¶
type FunctionType struct {
Parameters *TupleType
Result *TupleType
IsVariadic bool
// contains filtered or unexported fields
}
FunctionType represents a channel type.
func (*FunctionType) Position ¶
func (t *FunctionType) Position() (r token.Position)
Position implements Node.
func (*FunctionType) String ¶
func (t *FunctionType) String() string
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.
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) 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.
type GoStmt ¶
type GoStmt struct {
Go Token
Expr Expression
Semicolon Token
}
GoStmt describes a go statement.
GoStmt = "go" Expression .
type GotoStmt ¶
GotoStmt describes a goto statement.
GotoStmt = "goto" Label .
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) ResolvedTo ¶
ResolvedTo returns the node n refers to. Valid after type checking.
type IdentListItem ¶
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 ) ] .
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) Tokens ¶
func (n *ImportDecl) Tokens() []Token
Tokens returns the tokens n consist of.
type ImportSpec ¶
ImportSpec describes an import specification.
ImportSpec = [ "." | PackageName ] ImportPath .
func (*ImportSpec) Position ¶
func (n *ImportSpec) Position() (r token.Position)
Position 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) 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.
type InterfaceType ¶
type InterfaceType struct {
Elems []Node //TODO
// contains filtered or unexported fields
}
InterfaceType represents an interface type.
func (*InterfaceType) Position ¶
func (t *InterfaceType) Position() (r token.Position)
Position implements Node.
func (*InterfaceType) String ¶
func (t *InterfaceType) String() string
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.
type InvalidType ¶
type InvalidType struct {
// contains filtered or unexported fields
}
InvalidType represents an invalid type.
func (*InvalidType) Position ¶
func (t *InvalidType) Position() (r token.Position)
Position implements Node. Position returns a zero value.
func (*InvalidType) String ¶
func (t *InvalidType) String() string
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.
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
type LabeledStmt ¶
LabeledStmt describes a labeled statement.
LabeledStmt = Label ":" Statement .
func (*LabeledStmt) Position ¶
func (n *LabeledStmt) Position() (r token.Position)
Position 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 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) 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) Tokens ¶
func (n *MethodDecl) Tokens() []Token
Tokens returns the tokens n consist of.
type MethodElem ¶
MethodElem describes a method element.
MethodElem = MethodName Signature .
func (*MethodElem) Position ¶
func (n *MethodElem) Position() (r token.Position)
Position 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) Tokens ¶
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 ¶
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.
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 ¶
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.
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) 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.
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.
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) Position ¶
func (t *PointerType) Position() (r token.Position)
Position implements Node.
func (*PointerType) String ¶
func (t *PointerType) String() string
type PointerTypeNode ¶
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.
type PredefinedType ¶
type PredefinedType Kind
PredefinedType represents a predefined 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) 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.
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) 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) 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 ¶
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 ¶
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) 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.
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 .
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.
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.
type SliceType ¶
type SliceType struct {
Elem Type
// contains filtered or unexported fields
}
SliceType represents a slice type.
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) 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) Position ¶
func (t *StructType) Position() (r token.Position)
Position implements Node.
func (*StructType) String ¶
func (t *StructType) String() string
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.
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 ¶
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 ¶
SetSep sets the result of n.Sep to be sep. SetSep will allocate at least len(sep+n.Src()) bytes of additional memory.
type TupleType ¶
type TupleType struct {
Types []Type
}
TupleType represents an ordered list of types.
type Type ¶
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 [ "," ] "]" .
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) 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.
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 ¶
TypeDecl describes a type declaration.
TypeDecl = "type" ( TypeSpec | "(" { TypeSpec ";" } ")" ) .
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) LexicalScope ¶
func (n TypeDef) LexicalScope() *Scope
LexicalScope returns the lexical scope n appears in.
type TypeElem ¶
TypeElem describes a type element.
TypeElem = TypeTerm { "|" TypeTerm } .
type TypeListItem ¶
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.
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) 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.
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 ¶
TypeTerm describes a type term.
TypeTerm = Type | UnderlyingType . UnderlyingType = "~" Type .
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.
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.
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 ) .
type Variable ¶
type Variable struct {
Expr Expression
Ident Token
TypeNode Node
// contains filtered or unexported fields
}
Variable represents a Go variable.
func (*Variable) IsParameter ¶
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.