Source File
ast.go
Belonging Package
go/ast
package ast
import (
)
type CommentGroup struct {
List []*Comment // len(List) > 0
}
func ( *CommentGroup) () token.Pos { return .List[0].Pos() }
func ( *CommentGroup) () token.Pos { return .List[len(.List)-1].End() }
func ( byte) bool { return == ' ' || == '\t' || == '\n' || == '\r' }
func ( string) string {
:= len()
for > 0 && isWhitespace([-1]) {
--
}
return [0:]
}
switch [1] {
= [2:]
break
}
= [1:]
break
}
continue
}
= [2 : len()-2]
}
for , := range {
= append(, stripTrailingWhitespace())
}
}
:= 0
for , := range {
if != "" || > 0 && [-1] != "" {
[] =
++
}
}
= [0:]
type Field struct {
Doc *CommentGroup // associated documentation; or nil
Names []*Ident // field/method/parameter names; or nil
Type Expr // field/method/parameter type
Tag *BasicLit // field tag; or nil
Comment *CommentGroup // line comments; or nil
}
func ( *Field) () token.Pos {
if len(.Names) > 0 {
return .Names[0].Pos()
}
return .Type.Pos()
}
func ( *Field) () token.Pos {
if .Tag != nil {
return .Tag.End()
}
return .Type.End()
}
SelectorExpr struct {
X Expr // expression
Sel *Ident // field selector
}
StructType struct {
Struct token.Pos // position of "struct" keyword
Fields *FieldList // list of field declarations
Incomplete bool // true if (source) fields are missing in the Fields list
}
InterfaceType struct {
Interface token.Pos // position of "interface" keyword
Methods *FieldList // list of methods
Incomplete bool // true if (source) methods are missing in the Methods list
}
func ( *BadExpr) () token.Pos { return .From }
func ( *Ident) () token.Pos { return .NamePos }
func ( *Ellipsis) () token.Pos { return .Ellipsis }
func ( *BasicLit) () token.Pos { return .ValuePos }
func ( *FuncLit) () token.Pos { return .Type.Pos() }
func ( *CompositeLit) () token.Pos {
if .Type != nil {
return .Type.Pos()
}
return .Lbrace
}
func ( *ParenExpr) () token.Pos { return .Lparen }
func ( *SelectorExpr) () token.Pos { return .X.Pos() }
func ( *IndexExpr) () token.Pos { return .X.Pos() }
func ( *SliceExpr) () token.Pos { return .X.Pos() }
func ( *TypeAssertExpr) () token.Pos { return .X.Pos() }
func ( *CallExpr) () token.Pos { return .Fun.Pos() }
func ( *StarExpr) () token.Pos { return .Star }
func ( *UnaryExpr) () token.Pos { return .OpPos }
func ( *BinaryExpr) () token.Pos { return .X.Pos() }
func ( *KeyValueExpr) () token.Pos { return .Key.Pos() }
func ( *ArrayType) () token.Pos { return .Lbrack }
func ( *StructType) () token.Pos { return .Struct }
func ( *FuncType) () token.Pos {
if .Func.IsValid() || .Params == nil { // see issue 3870
return .Func
}
return .Params.Pos() // interface method declarations have no "func" keyword
}
func ( *InterfaceType) () token.Pos { return .Interface }
func ( *MapType) () token.Pos { return .Map }
func ( *ChanType) () token.Pos { return .Begin }
func ( *BadExpr) () token.Pos { return .To }
func ( *Ident) () token.Pos { return token.Pos(int(.NamePos) + len(.Name)) }
func ( *Ellipsis) () token.Pos {
if .Elt != nil {
return .Elt.End()
}
return .Ellipsis + 3 // len("...")
}
func ( *BasicLit) () token.Pos { return token.Pos(int(.ValuePos) + len(.Value)) }
func ( *FuncLit) () token.Pos { return .Body.End() }
func ( *CompositeLit) () token.Pos { return .Rbrace + 1 }
func ( *ParenExpr) () token.Pos { return .Rparen + 1 }
func ( *SelectorExpr) () token.Pos { return .Sel.End() }
func ( *IndexExpr) () token.Pos { return .Rbrack + 1 }
func ( *SliceExpr) () token.Pos { return .Rbrack + 1 }
func ( *TypeAssertExpr) () token.Pos { return .Rparen + 1 }
func ( *CallExpr) () token.Pos { return .Rparen + 1 }
func ( *StarExpr) () token.Pos { return .X.End() }
func ( *UnaryExpr) () token.Pos { return .X.End() }
func ( *BinaryExpr) () token.Pos { return .Y.End() }
func ( *KeyValueExpr) () token.Pos { return .Value.End() }
func ( *ArrayType) () token.Pos { return .Elt.End() }
func ( *StructType) () token.Pos { return .Fields.End() }
func ( *FuncType) () token.Pos {
if .Results != nil {
return .Results.End()
}
return .Params.End()
}
func ( *InterfaceType) () token.Pos { return .Methods.End() }
func ( *MapType) () token.Pos { return .Value.End() }
func ( *ChanType) () token.Pos { return .Value.End() }
func (*BadExpr) () {}
func (*Ident) () {}
func (*Ellipsis) () {}
func (*BasicLit) () {}
func (*FuncLit) () {}
func (*CompositeLit) () {}
func (*ParenExpr) () {}
func (*SelectorExpr) () {}
func (*IndexExpr) () {}
func (*SliceExpr) () {}
func (*TypeAssertExpr) () {}
func (*CallExpr) () {}
func (*StarExpr) () {}
func (*UnaryExpr) () {}
func (*BinaryExpr) () {}
func (*KeyValueExpr) () {}
func (*ArrayType) () {}
func (*StructType) () {}
func (*FuncType) () {}
func (*InterfaceType) () {}
func (*MapType) () {}
func (*ChanType) () {}
func ( string) bool { return token.IsExported() }
func ( *BadStmt) () token.Pos { return .From }
func ( *DeclStmt) () token.Pos { return .Decl.Pos() }
func ( *EmptyStmt) () token.Pos { return .Semicolon }
func ( *LabeledStmt) () token.Pos { return .Label.Pos() }
func ( *ExprStmt) () token.Pos { return .X.Pos() }
func ( *SendStmt) () token.Pos { return .Chan.Pos() }
func ( *IncDecStmt) () token.Pos { return .X.Pos() }
func ( *AssignStmt) () token.Pos { return .Lhs[0].Pos() }
func ( *GoStmt) () token.Pos { return .Go }
func ( *DeferStmt) () token.Pos { return .Defer }
func ( *ReturnStmt) () token.Pos { return .Return }
func ( *BranchStmt) () token.Pos { return .TokPos }
func ( *BlockStmt) () token.Pos { return .Lbrace }
func ( *IfStmt) () token.Pos { return .If }
func ( *CaseClause) () token.Pos { return .Case }
func ( *SwitchStmt) () token.Pos { return .Switch }
func ( *TypeSwitchStmt) () token.Pos { return .Switch }
func ( *CommClause) () token.Pos { return .Case }
func ( *SelectStmt) () token.Pos { return .Select }
func ( *ForStmt) () token.Pos { return .For }
func ( *RangeStmt) () token.Pos { return .For }
func ( *BadStmt) () token.Pos { return .To }
func ( *DeclStmt) () token.Pos { return .Decl.End() }
func ( *EmptyStmt) () token.Pos {
if .Implicit {
return .Semicolon
}
return .Semicolon + 1 /* len(";") */
}
func ( *LabeledStmt) () token.Pos { return .Stmt.End() }
func ( *ExprStmt) () token.Pos { return .X.End() }
func ( *SendStmt) () token.Pos { return .Value.End() }
func ( *IncDecStmt) () token.Pos {
return .TokPos + 2 /* len("++") */
}
func ( *AssignStmt) () token.Pos { return .Rhs[len(.Rhs)-1].End() }
func ( *GoStmt) () token.Pos { return .Call.End() }
func ( *DeferStmt) () token.Pos { return .Call.End() }
func ( *ReturnStmt) () token.Pos {
if := len(.Results); > 0 {
return .Results[-1].End()
}
return .Return + 6 // len("return")
}
func ( *BranchStmt) () token.Pos {
if .Label != nil {
return .Label.End()
}
return token.Pos(int(.TokPos) + len(.Tok.String()))
}
func ( *BlockStmt) () token.Pos {
if .Rbrace.IsValid() {
return .Rbrace + 1
}
if := len(.List); > 0 {
return .List[-1].End()
}
return .Lbrace + 1
}
func ( *IfStmt) () token.Pos {
if .Else != nil {
return .Else.End()
}
return .Body.End()
}
func ( *CaseClause) () token.Pos {
if := len(.Body); > 0 {
return .Body[-1].End()
}
return .Colon + 1
}
func ( *SwitchStmt) () token.Pos { return .Body.End() }
func ( *TypeSwitchStmt) () token.Pos { return .Body.End() }
func ( *CommClause) () token.Pos {
if := len(.Body); > 0 {
return .Body[-1].End()
}
return .Colon + 1
}
func ( *SelectStmt) () token.Pos { return .Body.End() }
func ( *ForStmt) () token.Pos { return .Body.End() }
func ( *RangeStmt) () token.Pos { return .Body.End() }
func (*BadStmt) () {}
func (*DeclStmt) () {}
func (*EmptyStmt) () {}
func (*LabeledStmt) () {}
func (*ExprStmt) () {}
func (*SendStmt) () {}
func (*IncDecStmt) () {}
func (*AssignStmt) () {}
func (*GoStmt) () {}
func (*DeferStmt) () {}
func (*ReturnStmt) () {}
func (*BranchStmt) () {}
func (*BlockStmt) () {}
func (*IfStmt) () {}
func (*CaseClause) () {}
func (*SwitchStmt) () {}
func (*TypeSwitchStmt) () {}
func (*CommClause) () {}
func (*SelectStmt) () {}
func (*ForStmt) () {}
func (*RangeStmt) () {}
ImportSpec struct {
Doc *CommentGroup // associated documentation; or nil
Name *Ident // local package name (including "."); or nil
Path *BasicLit // import path
Comment *CommentGroup // line comments; or nil
EndPos token.Pos // end of spec (overrides Path.Pos if nonzero)
}
func ( *ImportSpec) () token.Pos {
if .Name != nil {
return .Name.Pos()
}
return .Path.Pos()
}
func ( *ValueSpec) () token.Pos { return .Names[0].Pos() }
func ( *TypeSpec) () token.Pos { return .Name.Pos() }
func ( *ImportSpec) () token.Pos {
if .EndPos != 0 {
return .EndPos
}
return .Path.End()
}
func ( *ValueSpec) () token.Pos {
if := len(.Values); > 0 {
return .Values[-1].End()
}
if .Type != nil {
return .Type.End()
}
return .Names[len(.Names)-1].End()
}
func ( *TypeSpec) () token.Pos { return .Type.End() }
func (*ImportSpec) () {}
func (*ValueSpec) () {}
func (*TypeSpec) () {}
FuncDecl struct {
Doc *CommentGroup // associated documentation; or nil
Recv *FieldList // receiver (methods); or nil (functions)
Name *Ident // function/method name
Type *FuncType // function signature: parameters, results, and position of "func" keyword
Body *BlockStmt // function body; or nil for external (non-Go) function
}
)
func ( *BadDecl) () token.Pos { return .From }
func ( *GenDecl) () token.Pos { return .TokPos }
func ( *FuncDecl) () token.Pos { return .Type.Pos() }
func ( *BadDecl) () token.Pos { return .To }
func ( *GenDecl) () token.Pos {
if .Rparen.IsValid() {
return .Rparen + 1
}
return .Specs[0].End()
}
func ( *FuncDecl) () token.Pos {
if .Body != nil {
return .Body.End()
}
return .Type.End()
}
type File struct {
Doc *CommentGroup // associated documentation; or nil
Package token.Pos // position of "package" keyword
Name *Ident // package name
Decls []Decl // top-level declarations; or nil
Scope *Scope // package scope (this file only)
Imports []*ImportSpec // imports in this file
Unresolved []*Ident // unresolved identifiers in this file
Comments []*CommentGroup // list of all comments in the source file
}
func ( *File) () token.Pos { return .Package }
func ( *File) () token.Pos {
if := len(.Decls); > 0 {
return .Decls[-1].End()
}
return .Name.End()
}
![]() |
The pages are generated with Golds v0.3.2-preview. (GOOS=darwin GOARCH=amd64) Golds is a Go 101 project developed by Tapir Liu. PR and bug reports are welcome and can be submitted to the issue list. Please follow @Go100and1 (reachable from the left QR code) to get the latest news of Golds. |