ast

package
v0.0.0-...-05ae0ce Latest Latest
Warning

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

Go to latest
Published: Aug 23, 2021 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package ast declares the types used to represent syntax trees for Go packages.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsExported

func IsExported(name string) bool

IsExported reports whether name starts with an upper-case letter.

Types

type ArrayType

type ArrayType struct {
	Lbrack token.Pos // position of "["
	Len    Expr      // Ellipsis node for [...]T array types, nil for slice types
	Elt    Expr      // element type
}

An ArrayType node represents an array or slice type.

func (*ArrayType) End

func (x *ArrayType) End() token.Pos

func (*ArrayType) Pos

func (x *ArrayType) Pos() token.Pos

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

type BadDecl struct {
	From, To token.Pos // position range of bad declaration
}

A BadDecl node is a placeholder for a declaration containing syntax errors for which a correct declaration node cannot be created.

func (*BadDecl) End

func (d *BadDecl) End() token.Pos

func (*BadDecl) Pos

func (d *BadDecl) Pos() token.Pos

type BadExpr

type BadExpr struct {
	From, To token.Pos // position range of bad expression
}

A BadExpr node is a placeholder for an expression containing syntax errors for which a correct expression node cannot be created.

func (*BadExpr) End

func (x *BadExpr) End() token.Pos

func (*BadExpr) Pos

func (x *BadExpr) Pos() token.Pos

type BadStmt

type BadStmt struct {
	From, To token.Pos // position range of bad statement
}

A BadStmt node is a placeholder for statements containing syntax errors for which no correct statement nodes can be created.

func (*BadStmt) End

func (s *BadStmt) End() token.Pos

func (*BadStmt) Pos

func (s *BadStmt) Pos() token.Pos

type BasicLit

type BasicLit struct {
	ValuePos token.Pos   // literal position
	Kind     token.Token // token.INT, token.FLOAT, token.IMAG, token.CHAR, or token.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.

Note that for the CHAR and STRING kinds, the literal is stored with its quotes. For example, for a double-quoted STRING, the first and the last rune in the Value field will be ". The Unquote and UnquoteChar functions in the strconv package can be used to unquote STRING and CHAR values, respectively.

func (*BasicLit) End

func (x *BasicLit) End() token.Pos

func (*BasicLit) Pos

func (x *BasicLit) Pos() token.Pos

type BinaryExpr

type BinaryExpr struct {
	X     Expr        // left operand
	OpPos token.Pos   // position of Op
	Op    token.Token // operator
	Y     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 BlockStmt

type BlockStmt struct {
	Lbrace token.Pos // position of "{"
	List   []Stmt
	Rbrace token.Pos // position of "}", if any (may be absent due to syntax error)
}

A BlockStmt node represents a braced statement list.

func (*BlockStmt) End

func (s *BlockStmt) End() token.Pos

func (*BlockStmt) Pos

func (s *BlockStmt) Pos() token.Pos

type BranchStmt

type BranchStmt struct {
	TokPos token.Pos   // position of Tok
	Tok    token.Token // keyword token (BREAK, CONTINUE, GOTO, FALLTHROUGH)
	Label  *Ident      // label name; or nil
}

A BranchStmt node represents a break, continue, goto, or fallthrough statement.

func (*BranchStmt) End

func (s *BranchStmt) End() token.Pos

func (*BranchStmt) Pos

func (s *BranchStmt) Pos() token.Pos

type CallExpr

type CallExpr struct {
	Fun      Expr      // function expression
	Lparen   token.Pos // position of "("
	Args     []Expr    // function arguments; or nil
	Ellipsis token.Pos // position of "..." (token.NoPos if there is no "...")
	Rparen   token.Pos // position of ")"
}

A CallExpr node represents an expression followed by an argument list.

func (*CallExpr) End

func (x *CallExpr) End() token.Pos

func (*CallExpr) Pos

func (x *CallExpr) Pos() token.Pos

type CaseClause

type CaseClause struct {
	Case  token.Pos // position of "case" or "default" keyword
	List  []Expr    // list of expressions or types; nil means default case
	Colon token.Pos // position of ":"
	Body  []Stmt    // statement list; or nil
}

A CaseClause represents a case of an expression or type switch statement.

func (*CaseClause) End

func (s *CaseClause) End() token.Pos

func (*CaseClause) Pos

func (s *CaseClause) Pos() token.Pos

type ChanDir

type ChanDir int

The direction of a channel type is indicated by a bit mask including one or both of the following constants.

const (
	SEND ChanDir = 1 << iota
	RECV
)

type ChanType

type ChanType struct {
	Begin token.Pos // position of "chan" keyword or "<-" (whichever comes first)
	Arrow token.Pos // position of "<-" (token.NoPos if there is no "<-")
	Dir   ChanDir   // channel direction
	Value Expr      // value type
}

A ChanType node represents a channel type.

func (*ChanType) End

func (x *ChanType) End() token.Pos

func (*ChanType) Pos

func (x *ChanType) Pos() token.Pos

type CommClause

type CommClause struct {
	Case  token.Pos // position of "case" or "default" keyword
	Comm  Stmt      // send or receive statement; nil means default case
	Colon token.Pos // position of ":"
	Body  []Stmt    // statement list; or nil
}

A CommClause node represents a case of a select statement.

func (*CommClause) End

func (s *CommClause) End() token.Pos

func (*CommClause) Pos

func (s *CommClause) Pos() token.Pos

type Comment

type Comment struct {
	Slash token.Pos // position of "/" starting the comment
	Text  string    // comment text (excluding '\n' for //-style comments)
}

A Comment node represents a single //-style or /*-style comment.

The Text field contains the comment text without carriage returns (\r) that may have been present in the source. Because a comment's end position is computed using len(Text), the position reported by End() does not match the true source end position for comments containing carriage returns.

func (*Comment) End

func (c *Comment) End() token.Pos

func (*Comment) Pos

func (c *Comment) Pos() token.Pos

type CommentGroup

type CommentGroup struct {
	List []*Comment // len(List) > 0
}

A CommentGroup represents a sequence of comments with no other tokens and no empty lines between.

func (*CommentGroup) End

func (g *CommentGroup) End() token.Pos

func (*CommentGroup) Pos

func (g *CommentGroup) Pos() token.Pos

func (*CommentGroup) Text

func (g *CommentGroup) Text() string

Text returns the text of the comment. Comment markers (//, /*, and */), the first space of a line comment, and leading and trailing empty lines are removed. Comment directives like "//line" and "//go:noinline" are also removed. Multiple empty lines are reduced to one, and trailing space on lines is trimmed. Unless the result is empty, it is newline-terminated.

type CompositeLit

type CompositeLit struct {
	Type       Expr      // literal type; or nil
	Lbrace     token.Pos // position of "{"
	Elts       []Expr    // list of composite elements; or nil
	Rbrace     token.Pos // position of "}"
	Incomplete bool      // true if (source) expressions are missing in the Elts list
}

A CompositeLit node represents a composite literal.

func (*CompositeLit) End

func (x *CompositeLit) End() token.Pos

func (*CompositeLit) Pos

func (x *CompositeLit) 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.

func (*DeclStmt) End

func (s *DeclStmt) End() token.Pos

func (*DeclStmt) Pos

func (s *DeclStmt) Pos() token.Pos

type Ellipsis

type Ellipsis struct {
	Ellipsis token.Pos // position of "..."
	Elt      Expr      // ellipsis element type (parameter lists only); or nil
}

An Ellipsis node stands for the "..." type in a parameter list or the "..." length in an array type.

func (*Ellipsis) End

func (x *Ellipsis) End() token.Pos

func (*Ellipsis) Pos

func (x *Ellipsis) Pos() token.Pos

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.

func (*EmptyStmt) End

func (s *EmptyStmt) End() token.Pos

func (*EmptyStmt) Pos

func (s *EmptyStmt) Pos() token.Pos

type Expr

type Expr interface {
	Node
	// contains filtered or unexported methods
}

All expression nodes implement the Expr interface.

type ExprStmt

type ExprStmt struct {
	X Expr // expression
}

An ExprStmt node represents a (stand-alone) expression in a statement list.

func (*ExprStmt) End

func (s *ExprStmt) End() token.Pos

func (*ExprStmt) Pos

func (s *ExprStmt) Pos() token.Pos

type Field

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
}

A Field represents a Field declaration list in a struct type, a method list in an interface type, or a parameter/result declaration in a signature. Field.Names is nil for unnamed parameters (parameter lists which only contain types) and embedded struct fields. In the latter case, the field name is the type name.

func (*Field) End

func (f *Field) End() token.Pos

func (*Field) Pos

func (f *Field) Pos() token.Pos

type FieldList

type FieldList struct {
	Opening token.Pos // position of opening parenthesis/brace, if any
	List    []*Field  // field list; or nil
	Closing token.Pos // position of closing parenthesis/brace, if any
}

A FieldList represents a list of Fields, enclosed by parentheses or braces.

func (*FieldList) End

func (f *FieldList) End() token.Pos

func (*FieldList) NumFields

func (f *FieldList) NumFields() int

NumFields returns the number of parameters or struct fields represented by a FieldList.

func (*FieldList) Pos

func (f *FieldList) Pos() token.Pos

type File

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
}

A File node represents a Go source file.

The Comments list contains all comments in the source file in order of appearance, including the comments that are pointed to from other nodes via Doc and Comment fields.

For correct printing of source code containing comments (using packages go/format and go/printer), special care must be taken to update comments when a File's syntax tree is modified: For printing, comments are interspersed between tokens based on their position. If syntax tree nodes are removed or moved, relevant comments in their vicinity must also be removed (from the File.Comments list) or moved accordingly (by updating their positions). A CommentMap may be used to facilitate some of these operations.

Whether and how a comment is associated with a node depends on the interpretation of the syntax tree by the manipulating program: Except for Doc and Comment comments directly associated with nodes, the remaining comments are "free-floating" (see also issues #18593, #20744).

func (*File) End

func (f *File) End() token.Pos

func (*File) Pos

func (f *File) Pos() token.Pos

type ForStmt

type ForStmt struct {
	For  token.Pos // position of "for" keyword
	Init Stmt      // initialization statement; or nil
	Cond Expr      // condition; or nil
	Post Stmt      // post iteration statement; or nil
	Body *BlockStmt
}

A ForStmt represents a for statement.

func (*ForStmt) End

func (s *ForStmt) End() token.Pos

func (*ForStmt) Pos

func (s *ForStmt) Pos() token.Pos

type FuncDecl

type 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
}

A FuncDecl node represents a function declaration.

func (*FuncDecl) End

func (d *FuncDecl) End() token.Pos

func (*FuncDecl) Pos

func (d *FuncDecl) Pos() token.Pos

type FuncLit

type FuncLit struct {
	Type *FuncType  // function type
	Body *BlockStmt // function body
}

A FuncLit node represents a function literal.

func (*FuncLit) End

func (x *FuncLit) End() token.Pos

func (*FuncLit) Pos

func (x *FuncLit) Pos() token.Pos

type FuncType

type FuncType struct {
	Func    token.Pos  // position of "func" keyword (token.NoPos if there is no "func")
	Params  *FieldList // (incoming) parameters; non-nil
	Results *FieldList // (outgoing) results; or nil
}

A FuncType node represents a function type.

func (*FuncType) End

func (x *FuncType) End() token.Pos

func (*FuncType) Pos

func (x *FuncType) Pos() token.Pos

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

func (*GenDecl) End

func (d *GenDecl) End() token.Pos

func (*GenDecl) Pos

func (d *GenDecl) Pos() token.Pos

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 NewIdent

func NewIdent(name string) *Ident

NewIdent creates a new Ident without position. Useful for ASTs generated by code other than the Go parser.

func (*Ident) End

func (x *Ident) End() token.Pos

func (*Ident) IsExported

func (id *Ident) IsExported() bool

IsExported reports whether id starts with an upper-case letter.

func (*Ident) Pos

func (x *Ident) Pos() token.Pos

func (*Ident) String

func (id *Ident) String() string

type IfStmt

type IfStmt struct {
	If   token.Pos // position of "if" keyword
	Init Stmt      // initialization statement; or nil
	Cond Expr      // condition
	Body *BlockStmt
	Else Stmt // else branch; or nil
}

An IfStmt node represents an if statement.

func (*IfStmt) End

func (s *IfStmt) End() token.Pos

func (*IfStmt) Pos

func (s *IfStmt) Pos() token.Pos

type ImportSpec

type 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)
}

An ImportSpec node represents a single package import.

func (*ImportSpec) End

func (s *ImportSpec) End() token.Pos

func (*ImportSpec) Pos

func (s *ImportSpec) Pos() token.Pos

type IncDecStmt

type IncDecStmt struct {
	X      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 IndexExpr

type IndexExpr struct {
	X      Expr      // expression
	Lbrack token.Pos // position of "["
	Index  Expr      // index expression
	Rbrack token.Pos // position of "]"
}

An IndexExpr node represents an expression followed by an index.

func (*IndexExpr) End

func (x *IndexExpr) End() token.Pos

func (*IndexExpr) Pos

func (x *IndexExpr) Pos() token.Pos

type InterfaceType

type 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
}

An InterfaceType node represents an interface type.

func (*InterfaceType) End

func (x *InterfaceType) End() token.Pos

func (*InterfaceType) Pos

func (x *InterfaceType) Pos() token.Pos

type KeyValueExpr

type KeyValueExpr struct {
	Key   Expr
	Colon token.Pos // position of ":"
	Value Expr
}

A KeyValueExpr node represents (key : value) pairs in composite literals.

func (*KeyValueExpr) End

func (x *KeyValueExpr) End() token.Pos

func (*KeyValueExpr) Pos

func (x *KeyValueExpr) Pos() token.Pos

type LabeledStmt

type LabeledStmt struct {
	Label *Ident
	Colon token.Pos // position of ":"
	Stmt  Stmt
}

A LabeledStmt node represents a labeled statement.

func (*LabeledStmt) End

func (s *LabeledStmt) End() token.Pos

func (*LabeledStmt) Pos

func (s *LabeledStmt) Pos() token.Pos

type MapType

type MapType struct {
	Map   token.Pos // position of "map" keyword
	Key   Expr
	Value Expr
}

A MapType node represents a map type.

func (*MapType) End

func (x *MapType) End() token.Pos

func (*MapType) Pos

func (x *MapType) 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.

const (
	Bad ObjKind = iota // for error handling
	Pkg                // package
	Con                // constant
	Typ                // type
	Var                // variable
	Fun                // function or method
	Lbl                // label
)

The list of possible Object kinds.

func (ObjKind) String

func (kind ObjKind) String() string

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

func NewObj

func NewObj(kind ObjKind, name string) *Object

NewObj creates a new object of a given kind and name.

func (*Object) Pos

func (obj *Object) Pos() token.Pos

Pos computes the source position of the declaration of an object name. The result may be an invalid position if it cannot be computed (obj.Decl may be nil or not correct).

type Package

type Package struct {
	Name    string             // package name
	Scope   *Scope             // package scope across all files
	Imports map[string]*Object // map of package id -> package object
	Files   map[string]*File   // Go source files by filename
}

A Package node represents a set of source files collectively building a Go package.

func (*Package) End

func (p *Package) End() token.Pos

func (*Package) Pos

func (p *Package) Pos() token.Pos

type ParenExpr

type ParenExpr struct {
	Lparen token.Pos // position of "("
	X      Expr      // parenthesized expression
	Rparen token.Pos // position of ")"
}

A ParenExpr node represents a parenthesized expression.

func (*ParenExpr) End

func (x *ParenExpr) End() token.Pos

func (*ParenExpr) Pos

func (x *ParenExpr) Pos() token.Pos

type RangeStmt

type RangeStmt struct {
	For        token.Pos   // position of "for" keyword
	Key, Value Expr        // Key, Value may be nil
	TokPos     token.Pos   // position of Tok; invalid if Key == nil
	Tok        token.Token // ILLEGAL if Key == nil, ASSIGN, DEFINE
	X          Expr        // value to range over
	Body       *BlockStmt
}

A RangeStmt represents a for statement with a range clause.

func (*RangeStmt) End

func (s *RangeStmt) End() token.Pos

func (*RangeStmt) Pos

func (s *RangeStmt) Pos() token.Pos

type ReturnStmt

type ReturnStmt struct {
	Return  token.Pos // position of "return" keyword
	Results []Expr    // result expressions; or nil
}

A ReturnStmt node represents a return statement.

func (*ReturnStmt) End

func (s *ReturnStmt) End() token.Pos

func (*ReturnStmt) Pos

func (s *ReturnStmt) Pos() token.Pos

type Scope

type Scope struct {
	Outer   *Scope
	Objects map[string]*Object
}

A Scope maintains the set of named language entities declared in the scope and a link to the immediately surrounding (outer) scope.

func NewScope

func NewScope(outer *Scope) *Scope

NewScope creates a new scope nested in the outer scope.

func (*Scope) Insert

func (s *Scope) Insert(obj *Object) (alt *Object)

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.

func (*Scope) Lookup

func (s *Scope) Lookup(name string) *Object

Lookup returns the object with the given name if it is found in scope s, otherwise it returns nil. Outer scopes are ignored.

func (*Scope) String

func (s *Scope) String() string

Debugging support

type SelectStmt

type SelectStmt struct {
	Select token.Pos  // position of "select" keyword
	Body   *BlockStmt // CommClauses only
}

A SelectStmt node represents a select statement.

func (*SelectStmt) End

func (s *SelectStmt) End() token.Pos

func (*SelectStmt) Pos

func (s *SelectStmt) Pos() token.Pos

type SelectorExpr

type SelectorExpr struct {
	X   Expr   // expression
	Sel *Ident // field selector
}

A SelectorExpr node represents an expression followed by a selector.

func (*SelectorExpr) End

func (x *SelectorExpr) End() token.Pos

func (*SelectorExpr) Pos

func (x *SelectorExpr) Pos() token.Pos

type SendStmt

type SendStmt struct {
	Chan  Expr
	Arrow token.Pos // position of "<-"
	Value Expr
}

A SendStmt node represents a send statement.

func (*SendStmt) End

func (s *SendStmt) End() token.Pos

func (*SendStmt) Pos

func (s *SendStmt) Pos() token.Pos

type SliceExpr

type SliceExpr struct {
	X      Expr      // expression
	Lbrack token.Pos // position of "["
	Low    Expr      // begin of slice range; or nil
	High   Expr      // end of slice range; or nil
	Max    Expr      // maximum capacity of slice; or nil
	Slice3 bool      // true if 3-index slice (2 colons present)
	Rbrack token.Pos // position of "]"
}

A SliceExpr node represents an expression followed by slice indices.

func (*SliceExpr) End

func (x *SliceExpr) End() token.Pos

func (*SliceExpr) Pos

func (x *SliceExpr) Pos() token.Pos

type Spec

type Spec interface {
	Node
	// contains filtered or unexported methods
}

The Spec type stands for any of *ImportSpec, *ValueSpec, and *TypeSpec.

type StarExpr

type StarExpr struct {
	Star token.Pos // position of "*"
	X    Expr      // operand
}

A StarExpr node represents an expression of the form "*" Expression. Semantically it could be a unary "*" expression, or a pointer type.

func (*StarExpr) End

func (x *StarExpr) End() token.Pos

func (*StarExpr) Pos

func (x *StarExpr) Pos() token.Pos

type Stmt

type Stmt interface {
	Node
	// contains filtered or unexported methods
}

All statement nodes implement the Stmt interface.

type StructType

type 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
}

A StructType node represents a struct type.

func (*StructType) End

func (x *StructType) End() token.Pos

func (*StructType) Pos

func (x *StructType) Pos() token.Pos

type SwitchStmt

type SwitchStmt struct {
	Switch token.Pos  // position of "switch" keyword
	Init   Stmt       // initialization statement; or nil
	Tag    Expr       // tag expression; or nil
	Body   *BlockStmt // CaseClauses only
}

A SwitchStmt node represents an expression switch statement.

func (*SwitchStmt) End

func (s *SwitchStmt) End() token.Pos

func (*SwitchStmt) Pos

func (s *SwitchStmt) Pos() token.Pos

type TypeAssertExpr

type TypeAssertExpr struct {
	X      Expr      // expression
	Lparen token.Pos // position of "("
	Type   Expr      // asserted type; nil means type switch X.(type)
	Rparen token.Pos // position of ")"
}

A TypeAssertExpr node represents an expression followed by a type assertion.

func (*TypeAssertExpr) End

func (x *TypeAssertExpr) End() token.Pos

func (*TypeAssertExpr) Pos

func (x *TypeAssertExpr) Pos() token.Pos

type TypeSpec

type TypeSpec struct {
	Doc     *CommentGroup // associated documentation; or nil
	Name    *Ident        // type name
	Assign  token.Pos     // position of '=', if any
	Type    Expr          // *Ident, *ParenExpr, *SelectorExpr, *StarExpr, or any of the *XxxTypes
	Comment *CommentGroup // line comments; or nil
}

A TypeSpec node represents a type declaration (TypeSpec production).

func (*TypeSpec) End

func (s *TypeSpec) End() token.Pos

func (*TypeSpec) Pos

func (s *TypeSpec) Pos() token.Pos

type TypeSwitchStmt

type TypeSwitchStmt struct {
	Switch token.Pos  // position of "switch" keyword
	Init   Stmt       // initialization statement; or nil
	Assign Stmt       // x := y.(type) or y.(type)
	Body   *BlockStmt // CaseClauses only
}

A TypeSwitchStmt node represents a type switch statement.

func (*TypeSwitchStmt) End

func (s *TypeSwitchStmt) End() token.Pos

func (*TypeSwitchStmt) Pos

func (s *TypeSwitchStmt) Pos() token.Pos

type UnaryExpr

type UnaryExpr struct {
	OpPos token.Pos   // position of Op
	Op    token.Token // operator
	X     Expr        // operand
}

A UnaryExpr node represents a unary expression. Unary "*" expressions are represented via StarExpr nodes.

func (*UnaryExpr) End

func (x *UnaryExpr) End() token.Pos

func (*UnaryExpr) Pos

func (x *UnaryExpr) Pos() token.Pos

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
	Comment *CommentGroup // line comments; or nil
}

A ValueSpec node represents a constant or variable declaration (ConstSpec or VarSpec production).

func (*ValueSpec) End

func (s *ValueSpec) End() token.Pos

func (*ValueSpec) Pos

func (s *ValueSpec) Pos() token.Pos

Jump to

Keyboard shortcuts

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