Documentation
¶
Index ¶
- func IsExported(name string) bool
- type AssignStmt
- type BadDecl
- type BadExpr
- type BadStmt
- type BasicLit
- type BinaryExpr
- type Decl
- type DeclStmt
- type EmptyStmt
- type Expr
- type ExprStmt
- type File
- type GenDecl
- type Ident
- type IncDecStmt
- type Node
- type ObjKind
- type Object
- type ParenExpr
- type Scope
- type Spec
- type Stmt
- type UnaryExpr
- type ValueSpec
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func IsExported ¶
IsExported reports whether name starts with an upper-case letter.
Types ¶
type AssignStmt ¶
type AssignStmt struct {
Lhs []Expr
TokPos token.Pos // position of Tok
Tok token.Token // assignment token, DEFINE
Rhs []Expr
}
An AssignStmt node represents an assignment or a short variable declaration.
func (*AssignStmt) End ¶
func (s *AssignStmt) End() token.Pos
func (*AssignStmt) Pos ¶
func (s *AssignStmt) Pos() token.Pos
type BadDecl ¶
A BadDecl node is a placeholder for declarations containing syntax errors for which no correct declaration nodes can be created.
type BadExpr ¶
A BadExpr node is a placeholder for expressions containing syntax errors for which no correct expression nodes can be created.
type BadStmt ¶
A BadStmt node is a placeholder for statements containing syntax errors for which no correct statement nodes can be created.
type BasicLit ¶
type BasicLit struct {
ValuePos token.Pos // literal position
Kind token.Token // token.INT, token.FLOAT, token.CHAR, token.STRING, or token.RAW_STRING
Value string // literal string; e.g. 42, 0x7f, 3.14, 1e-9, 2.4i, 'a', '\x7f', "foo" or `\m\n\o`
}
A BasicLit node represents a literal of basic type.
type BinaryExpr ¶
type BinaryExpr struct {
Lhs Expr // left operand
OpPos token.Pos // position of Op
Op token.Token // operator
Rhs Expr // right operand
}
A BinaryExpr node represents a binary expression.
func (*BinaryExpr) End ¶
func (x *BinaryExpr) End() token.Pos
func (*BinaryExpr) Pos ¶
func (x *BinaryExpr) Pos() token.Pos
type Decl ¶
type Decl interface {
Node
// contains filtered or unexported methods
}
All declaration nodes implement the Decl interface.
type DeclStmt ¶
type DeclStmt struct {
Decl Decl // *GenDecl with CONST, TYPE, or VAR token
}
A DeclStmt node represents a declaration in a statement list.
type EmptyStmt ¶
type EmptyStmt struct {
Semicolon token.Pos // position of following ";"
Implicit bool // if set, ";" was omitted in the source
}
An EmptyStmt node represents an empty statement. The "position" of the empty statement is the position of the immediately following (explicit or implicit) semicolon.
type Expr ¶
type Expr interface {
Node
// contains filtered or unexported methods
}
All expression nodes implement the Expr interface.
type ExprStmt ¶
type ExprStmt struct {
Expr Expr // expression
}
An ExprStmt node represents a (stand-alone) expression in a statement list.
type File ¶
type File struct {
Package token.Pos // position of "package" keyword
Name *Ident // package name
Stmts []Stmt // top-level statements; or nil
Scope *Scope // package scope (this file only)
//Imports []*ImportSpec // imports in this file
Unresolved []*Ident // unresolved identifiers in this file
}
A File node represents a Go source file.
type GenDecl ¶
type GenDecl struct {
//Doc *CommentGroup // associated documentation; or nil
TokPos token.Pos // position of Tok
Tok token.Token // IMPORT, CONST, TYPE, VAR
Lparen token.Pos // position of '(', if any
Specs []Spec
Rparen token.Pos // position of ')', if any
}
A GenDecl node (generic declaration node) represents an import, constant, type or variable declaration. A valid Lparen position (Lparen.IsValid()) indicates a parenthesized declaration.
Relationship between Tok value and Specs element type:
token.IMPORT *ImportSpec token.CONST *ValueSpec token.TYPE *TypeSpec token.VAR *ValueSpec
type Ident ¶
type Ident struct {
NamePos token.Pos // identifier position
Name string // identifier name
Obj *Object // denoted object; or nil
}
An Ident node represents an identifier.
func (*Ident) IsExported ¶
IsExported reports whether id starts with an upper-case letter.
type IncDecStmt ¶
type IncDecStmt struct {
Expr Expr
TokPos token.Pos // position of Tok
Tok token.Token // INC or DEC
}
An IncDecStmt node represents an increment or decrement statement.
func (*IncDecStmt) End ¶
func (s *IncDecStmt) End() token.Pos
func (*IncDecStmt) Pos ¶
func (s *IncDecStmt) Pos() token.Pos
type Node ¶
type Node interface {
Pos() token.Pos // position of first character belonging to the node
End() token.Pos // position of first character immediately after the node
}
All node types implement the Node interface.
type ObjKind ¶
type ObjKind int
ObjKind describes what an object represents.
type Object ¶
type Object struct {
Kind ObjKind
Name string // declared name
Decl interface{} // corresponding Field, XxxSpec, FuncDecl, LabeledStmt, AssignStmt, Scope; or nil
Data interface{} // object-specific data; or nil
Type interface{} // placeholder for type information; may be nil
}
An Object describes a named language entity such as a package, constant, type, variable, function (incl. methods), or label.
The Data fields contains object-specific data:
Kind Data type Data value Pkg *Scope package scope Con int iota for the respective declaration
TODO: (capnspacehook) remove interface{} fields?
type ParenExpr ¶
type ParenExpr struct {
Lparen token.Pos // position of "("
Expr Expr // parenthesized expression
Rparen token.Pos // position of ")"
}
A ParenExpr node represents a parenthesized expression.
type Scope ¶
A Scope maintains the set of named language entities declared in the scope and a link to the immediately surrounding (outer) scope.
func (*Scope) Insert ¶
Insert attempts to insert a named object obj into the scope s. If the scope already contains an object alt with the same name, Insert leaves the scope unchanged and returns alt. Otherwise it inserts obj and returns nil.
type Spec ¶
type Spec interface {
Node
// contains filtered or unexported methods
}
The Spec type stands for any of *ImportSpec, *ValueSpec, and *TypeSpec.
type Stmt ¶
type Stmt interface {
Node
// contains filtered or unexported methods
}
All statement nodes implement the Stmt interface.
type UnaryExpr ¶
type UnaryExpr struct {
OpPos token.Pos // position of Op
Op token.Token // operator
Expr Expr // operand
}
A UnaryExpr node represents a unary expression.
type ValueSpec ¶
type ValueSpec struct {
//Doc *CommentGroup // associated documentation; or nil
Names []*Ident // value names (len(Names) > 0)
Type Expr // value type; or nil
Values []Expr // initial values; or nil
}
A ValueSpec node represents a constant or variable declaration (ConstSpec or VarSpec production).