package token

Import Path
	go/token (on golang.org and go.dev)

Dependency Relation
	imports 6 packages, and imported by 14 packages

Involved Source Files
	    position.go
	    serialize.go
	d-> token.go

Exported Type Names

type File (struct) A File is a handle for a file belonging to a FileSet. A File has a name, size, and line offset table. (*T) AddLine(offset int) (*T) AddLineColumnInfo(offset int, filename string, line, column int) (*T) AddLineInfo(offset int, filename string, line int) (*T) Base() int (*T) Line(p Pos) int (*T) LineCount() int (*T) LineStart(line int) Pos (*T) MergeLine(line int) (*T) Name() string (*T) Offset(p Pos) int (*T) Pos(offset int) Pos (*T) Position(p Pos) (pos Position) (*T) PositionFor(p Pos, adjusted bool) (pos Position) (*T) SetLines(lines []int) bool (*T) SetLinesForContent(content []byte) (*T) Size() int func (*FileSet).AddFile(filename string, base, size int) *File func (*FileSet).File(p Pos) (f *File) func go/scanner.(*Scanner).Init(file *File, src []byte, err scanner.ErrorHandler, mode scanner.Mode)
type FileSet (struct) A FileSet represents a set of source files. Methods of file sets are synchronized; multiple goroutines may invoke them concurrently. The byte offsets for each file in a file set are mapped into distinct (integer) intervals, one interval [base, base+size] per file. Base represents the first byte in the file, and size is the corresponding file size. A Pos value is a value in such an interval. By determining the interval a Pos value belongs to, the file, its file base, and thus the byte offset (position) the Pos value is representing can be computed. When adding a new file, a file base must be provided. That can be any integer value that is past the end of any interval of any file already in the file set. For convenience, FileSet.Base provides such a value, which is simply the end of the Pos interval of the most recently added file, plus one. Unless there is a need to extend an interval later, using the FileSet.Base should be used as argument for FileSet.AddFile. (*T) AddFile(filename string, base, size int) *File (*T) Base() int (*T) File(p Pos) (f *File) (*T) Iterate(f func(*File) bool) (*T) Position(p Pos) (pos Position) (*T) PositionFor(p Pos, adjusted bool) (pos Position) (*T) Read(decode func(interface{}) error) error (*T) Write(encode func(interface{}) error) error func NewFileSet() *FileSet func go/ast.Fprint(w io.Writer, fset *FileSet, x interface{}, f ast.FieldFilter) error func go/ast.NewCommentMap(fset *FileSet, node ast.Node, comments []*ast.CommentGroup) ast.CommentMap func go/ast.NewPackage(fset *FileSet, files map[string]*ast.File, importer ast.Importer, universe *ast.Scope) (*ast.Package, error) func go/ast.Print(fset *FileSet, x interface{}) error func go/ast.SortImports(fset *FileSet, f *ast.File) func go/doc.NewFromFiles(fset *FileSet, files []*ast.File, importPath string, opts ...interface{}) (*doc.Package, error) func go/format.Node(dst io.Writer, fset *FileSet, node interface{}) error func go/importer.ForCompiler(fset *FileSet, compiler string, lookup importer.Lookup) types.Importer func go/internal/gcimporter.Import(fset *FileSet, packages map[string]*types.Package, path, srcDir string, lookup func(path string) (io.ReadCloser, error)) (pkg *types.Package, err error) func go/internal/srcimporter.New(ctxt *build.Context, fset *FileSet, packages map[string]*types.Package) *srcimporter.Importer func go/parser.ParseDir(fset *FileSet, path string, filter func(os.FileInfo) bool, mode parser.Mode) (pkgs map[string]*ast.Package, first error) func go/parser.ParseExprFrom(fset *FileSet, filename string, src interface{}, mode parser.Mode) (expr ast.Expr, err error) func go/parser.ParseFile(fset *FileSet, filename string, src interface{}, mode parser.Mode) (f *ast.File, err error) func go/printer.Fprint(output io.Writer, fset *FileSet, node interface{}) error func go/printer.(*Config).Fprint(output io.Writer, fset *FileSet, node interface{}) error func go/types.CheckExpr(fset *FileSet, pkg *types.Package, pos Pos, expr ast.Expr, info *types.Info) (err error) func go/types.Eval(fset *FileSet, pkg *types.Package, pos Pos, expr string) (_ types.TypeAndValue, err error) func go/types.NewChecker(conf *types.Config, fset *FileSet, pkg *types.Package, info *types.Info) *types.Checker func go/types.(*Config).Check(path string, fset *FileSet, files []*ast.File, info *types.Info) (*types.Package, error)
type Pos int Pos is a compact encoding of a source position within a file set. It can be converted into a Position for a more convenient, but much larger, representation. The Pos value for a given file is a number in the range [base, base+size], where base and size are specified when a file is added to the file set. The difference between a Pos value and the corresponding file base corresponds to the byte offset of that position (represented by the Pos value) from the beginning of the file. Thus, the file base offset is the Pos value representing the first byte in the file. To create the Pos value for a specific source offset (measured in bytes), first add the respective file to the current file set using FileSet.AddFile and then call File.Pos(offset) for that file. Given a Pos value p for a specific file set fset, the corresponding Position value is obtained by calling fset.Position(p). Pos values can be compared directly with the usual comparison operators: If two Pos values p and q are in the same file, comparing p and q is equivalent to comparing the respective source file offsets. If p and q are in different files, p < q is true if the file implied by p was added to the respective file set before the file implied by q. (T) IsValid() bool T : database/sql/driver.Validator func (*File).LineStart(line int) Pos func (*File).Pos(offset int) Pos func go/ast.(*ArrayType).End() Pos func go/ast.(*ArrayType).Pos() Pos func go/ast.(*AssignStmt).End() Pos func go/ast.(*AssignStmt).Pos() Pos func go/ast.(*BadDecl).End() Pos func go/ast.(*BadDecl).Pos() Pos func go/ast.(*BadExpr).End() Pos func go/ast.(*BadExpr).Pos() Pos func go/ast.(*BadStmt).End() Pos func go/ast.(*BadStmt).Pos() Pos func go/ast.(*BasicLit).End() Pos func go/ast.(*BasicLit).Pos() Pos func go/ast.(*BinaryExpr).End() Pos func go/ast.(*BinaryExpr).Pos() Pos func go/ast.(*BlockStmt).End() Pos func go/ast.(*BlockStmt).Pos() Pos func go/ast.(*BranchStmt).End() Pos func go/ast.(*BranchStmt).Pos() Pos func go/ast.(*CallExpr).End() Pos func go/ast.(*CallExpr).Pos() Pos func go/ast.(*CaseClause).End() Pos func go/ast.(*CaseClause).Pos() Pos func go/ast.(*ChanType).End() Pos func go/ast.(*ChanType).Pos() Pos func go/ast.(*CommClause).End() Pos func go/ast.(*CommClause).Pos() Pos func go/ast.(*Comment).End() Pos func go/ast.(*Comment).Pos() Pos func go/ast.(*CommentGroup).End() Pos func go/ast.(*CommentGroup).Pos() Pos func go/ast.(*CompositeLit).End() Pos func go/ast.(*CompositeLit).Pos() Pos func go/ast.Decl.End() Pos func go/ast.Decl.Pos() Pos func go/ast.(*DeclStmt).End() Pos func go/ast.(*DeclStmt).Pos() Pos func go/ast.(*DeferStmt).End() Pos func go/ast.(*DeferStmt).Pos() Pos func go/ast.(*Ellipsis).End() Pos func go/ast.(*Ellipsis).Pos() Pos func go/ast.(*EmptyStmt).End() Pos func go/ast.(*EmptyStmt).Pos() Pos func go/ast.Expr.End() Pos func go/ast.Expr.Pos() Pos func go/ast.(*ExprStmt).End() Pos func go/ast.(*ExprStmt).Pos() Pos func go/ast.(*Field).End() Pos func go/ast.(*Field).Pos() Pos func go/ast.(*FieldList).End() Pos func go/ast.(*FieldList).Pos() Pos func go/ast.(*File).End() Pos func go/ast.(*File).Pos() Pos func go/ast.(*ForStmt).End() Pos func go/ast.(*ForStmt).Pos() Pos func go/ast.(*FuncDecl).End() Pos func go/ast.(*FuncDecl).Pos() Pos func go/ast.(*FuncLit).End() Pos func go/ast.(*FuncLit).Pos() Pos func go/ast.(*FuncType).End() Pos func go/ast.(*FuncType).Pos() Pos func go/ast.(*GenDecl).End() Pos func go/ast.(*GenDecl).Pos() Pos func go/ast.(*GoStmt).End() Pos func go/ast.(*GoStmt).Pos() Pos func go/ast.(*Ident).End() Pos func go/ast.(*Ident).Pos() Pos func go/ast.(*IfStmt).End() Pos func go/ast.(*IfStmt).Pos() Pos func go/ast.(*ImportSpec).End() Pos func go/ast.(*ImportSpec).Pos() Pos func go/ast.(*IncDecStmt).End() Pos func go/ast.(*IncDecStmt).Pos() Pos func go/ast.(*IndexExpr).End() Pos func go/ast.(*IndexExpr).Pos() Pos func go/ast.(*InterfaceType).End() Pos func go/ast.(*InterfaceType).Pos() Pos func go/ast.(*KeyValueExpr).End() Pos func go/ast.(*KeyValueExpr).Pos() Pos func go/ast.(*LabeledStmt).End() Pos func go/ast.(*LabeledStmt).Pos() Pos func go/ast.(*MapType).End() Pos func go/ast.(*MapType).Pos() Pos func go/ast.Node.End() Pos func go/ast.Node.Pos() Pos func go/ast.(*Object).Pos() Pos func go/ast.(*Package).End() Pos func go/ast.(*Package).Pos() Pos func go/ast.(*ParenExpr).End() Pos func go/ast.(*ParenExpr).Pos() Pos func go/ast.(*RangeStmt).End() Pos func go/ast.(*RangeStmt).Pos() Pos func go/ast.(*ReturnStmt).End() Pos func go/ast.(*ReturnStmt).Pos() Pos func go/ast.(*SelectorExpr).End() Pos func go/ast.(*SelectorExpr).Pos() Pos func go/ast.(*SelectStmt).End() Pos func go/ast.(*SelectStmt).Pos() Pos func go/ast.(*SendStmt).End() Pos func go/ast.(*SendStmt).Pos() Pos func go/ast.(*SliceExpr).End() Pos func go/ast.(*SliceExpr).Pos() Pos func go/ast.Spec.End() Pos func go/ast.Spec.Pos() Pos func go/ast.(*StarExpr).End() Pos func go/ast.(*StarExpr).Pos() Pos func go/ast.Stmt.End() Pos func go/ast.Stmt.Pos() Pos func go/ast.(*StructType).End() Pos func go/ast.(*StructType).Pos() Pos func go/ast.(*SwitchStmt).End() Pos func go/ast.(*SwitchStmt).Pos() Pos func go/ast.(*TypeAssertExpr).End() Pos func go/ast.(*TypeAssertExpr).Pos() Pos func go/ast.(*TypeSpec).End() Pos func go/ast.(*TypeSpec).Pos() Pos func go/ast.(*TypeSwitchStmt).End() Pos func go/ast.(*TypeSwitchStmt).Pos() Pos func go/ast.(*UnaryExpr).End() Pos func go/ast.(*UnaryExpr).Pos() Pos func go/ast.(*ValueSpec).End() Pos func go/ast.(*ValueSpec).Pos() Pos func go/scanner.(*Scanner).Scan() (pos Pos, tok Token, lit string) func go/types.Object.Pos() Pos func go/types.(*Scope).End() Pos func go/types.(*Scope).Pos() Pos func (*File).Line(p Pos) int func (*File).Offset(p Pos) int func (*File).Position(p Pos) (pos Position) func (*File).PositionFor(p Pos, adjusted bool) (pos Position) func (*FileSet).File(p Pos) (f *File) func (*FileSet).Position(p Pos) (pos Position) func (*FileSet).PositionFor(p Pos, adjusted bool) (pos Position) func go/types.CheckExpr(fset *FileSet, pkg *types.Package, pos Pos, expr ast.Expr, info *types.Info) (err error) func go/types.Eval(fset *FileSet, pkg *types.Package, pos Pos, expr string) (_ types.TypeAndValue, err error) func go/types.NewConst(pos Pos, pkg *types.Package, name string, typ types.Type, val constant.Value) *types.Const func go/types.NewField(pos Pos, pkg *types.Package, name string, typ types.Type, embedded bool) *types.Var func go/types.NewFunc(pos Pos, pkg *types.Package, name string, sig *types.Signature) *types.Func func go/types.NewLabel(pos Pos, pkg *types.Package, name string) *types.Label func go/types.NewParam(pos Pos, pkg *types.Package, name string, typ types.Type) *types.Var func go/types.NewPkgName(pos Pos, pkg *types.Package, name string, imported *types.Package) *types.PkgName func go/types.NewScope(parent *types.Scope, pos, end Pos, comment string) *types.Scope func go/types.NewTypeName(pos Pos, pkg *types.Package, name string, typ types.Type) *types.TypeName func go/types.NewVar(pos Pos, pkg *types.Package, name string, typ types.Type) *types.Var func go/types.(*Scope).Contains(pos Pos) bool func go/types.(*Scope).Innermost(pos Pos) *types.Scope func go/types.(*Scope).LookupParent(name string, pos Pos) (*types.Scope, types.Object) const NoPos
type Position (struct) Position describes an arbitrary source position including the file, line, and column location. A Position is valid if the line number is > 0. Column int Filename string Line int Offset int (*T) IsValid() bool (T) String() string *T : database/sql/driver.Validator T : expvar.Var T : fmt.Stringer func (*File).Position(p Pos) (pos Position) func (*File).PositionFor(p Pos, adjusted bool) (pos Position) func (*FileSet).Position(p Pos) (pos Position) func (*FileSet).PositionFor(p Pos, adjusted bool) (pos Position) func go/scanner.(*ErrorList).Add(pos Position, msg string)
type Token int Token is the set of lexical tokens of the Go programming language. (T) IsKeyword() bool (T) IsLiteral() bool (T) IsOperator() bool (T) Precedence() int (T) String() string T : expvar.Var T : fmt.Stringer func Lookup(ident string) Token func go/scanner.(*Scanner).Scan() (pos Pos, tok Token, lit string) func go/constant.BinaryOp(x_ constant.Value, op Token, y_ constant.Value) constant.Value func go/constant.Compare(x_ constant.Value, op Token, y_ constant.Value) bool func go/constant.MakeFromLiteral(lit string, tok Token, zero uint) constant.Value func go/constant.Shift(x constant.Value, op Token, s uint) constant.Value func go/constant.UnaryOp(op Token, y constant.Value, prec uint) constant.Value const ADD const ADD_ASSIGN const AND const AND_ASSIGN const AND_NOT const AND_NOT_ASSIGN const ARROW const ASSIGN const BREAK const CASE const CHAN const CHAR const COLON const COMMA const COMMENT const CONST const CONTINUE const DEC const DEFAULT const DEFER const DEFINE const ELLIPSIS const ELSE const EOF const EQL const FALLTHROUGH const FLOAT const FOR const FUNC const GEQ const GO const GOTO const GTR const IDENT const IF const ILLEGAL const IMAG const IMPORT const INC const INT const INTERFACE const LAND const LBRACE const LBRACK const LEQ const LOR const LPAREN const LSS const MAP const MUL const MUL_ASSIGN const NEQ const NOT const OR const OR_ASSIGN const PACKAGE const PERIOD const QUO const QUO_ASSIGN const RANGE const RBRACE const RBRACK const REM const REM_ASSIGN const RETURN const RPAREN const SELECT const SEMICOLON const SHL const SHL_ASSIGN const SHR const SHR_ASSIGN const STRING const STRUCT const SUB const SUB_ASSIGN const SWITCH const TYPE const VAR const XOR const XOR_ASSIGN
Exported Values
const ADD Token = 12 // + Operators and delimiters
const ADD_ASSIGN Token = 23 // += The list of tokens.
const AND Token = 17 // & The list of tokens.
const AND_ASSIGN Token = 28 // &= The list of tokens.
const AND_NOT Token = 22 // &^ The list of tokens.
const AND_NOT_ASSIGN Token = 33 // &^= The list of tokens.
const ARROW Token = 36 // <- The list of tokens.
const ASSIGN Token = 42 // = The list of tokens.
const BREAK Token = 61 Keywords
const CASE Token = 62 The list of tokens.
const CHAN Token = 63 The list of tokens.
const CHAR Token = 8 // 'a' The list of tokens.
const COLON Token = 58 // : The list of tokens.
const COMMA Token = 52 // , The list of tokens.
const COMMENT Token = 2 The list of tokens.
const CONST Token = 64 The list of tokens.
const CONTINUE Token = 65 The list of tokens.
const DEC Token = 38 // -- The list of tokens.
const DEFAULT Token = 66 The list of tokens.
const DEFER Token = 67 The list of tokens.
const DEFINE Token = 47 // := The list of tokens.
const ELLIPSIS Token = 48 // ... The list of tokens.
const ELSE Token = 68 The list of tokens.
const EOF Token = 1 The list of tokens.
const EQL Token = 39 // == The list of tokens.
const FALLTHROUGH Token = 69 The list of tokens.
const FLOAT Token = 6 // 123.45 The list of tokens.
const FOR Token = 70 The list of tokens.
const FUNC Token = 71 The list of tokens.
const GEQ Token = 46 // >= The list of tokens.
const GO Token = 72 The list of tokens.
const GOTO Token = 73 The list of tokens.
const GTR Token = 41 // > The list of tokens.
const HighestPrec = 7 A set of constants for precedence-based expression parsing. Non-operators have lowest precedence, followed by operators starting with precedence 1 up to unary operators. The highest precedence serves as "catch-all" precedence for selector, indexing, and other operator and delimiter tokens.
const IDENT Token = 4 // main Identifiers and basic type literals (these tokens stand for classes of literals)
const IF Token = 74 The list of tokens.
const ILLEGAL Token = 0 Special tokens
const IMAG Token = 7 // 123.45i The list of tokens.
const IMPORT Token = 75 The list of tokens.
const INC Token = 37 // ++ The list of tokens.
const INT Token = 5 // 12345 The list of tokens.
const INTERFACE Token = 76 The list of tokens.
func IsExported(name string) bool IsExported reports whether name starts with an upper-case letter.
func IsIdentifier(name string) bool IsIdentifier reports whether name is a Go identifier, that is, a non-empty string made up of letters, digits, and underscores, where the first character is not a digit. Keywords are not identifiers.
func IsKeyword(name string) bool IsKeyword reports whether name is a Go keyword, such as "func" or "return".
const LAND Token = 34 // && The list of tokens.
const LBRACE Token = 51 // { The list of tokens.
const LBRACK Token = 50 // [ The list of tokens.
const LEQ Token = 45 // <= The list of tokens.
func Lookup(ident string) Token Lookup maps an identifier to its keyword token or IDENT (if not a keyword).
const LOR Token = 35 // || The list of tokens.
const LowestPrec = 0 // non-operators A set of constants for precedence-based expression parsing. Non-operators have lowest precedence, followed by operators starting with precedence 1 up to unary operators. The highest precedence serves as "catch-all" precedence for selector, indexing, and other operator and delimiter tokens.
const LPAREN Token = 49 // ( The list of tokens.
const LSS Token = 40 // < The list of tokens.
const MAP Token = 77 The list of tokens.
const MUL Token = 14 // * The list of tokens.
const MUL_ASSIGN Token = 25 // *= The list of tokens.
const NEQ Token = 44 // != The list of tokens.
func NewFileSet() *FileSet NewFileSet creates a new file set.
const NoPos Pos = 0 The zero value for Pos is NoPos; there is no file and line information associated with it, and NoPos.IsValid() is false. NoPos is always smaller than any other Pos value. The corresponding Position value for NoPos is the zero value for Position.
const NOT Token = 43 // ! The list of tokens.
const OR Token = 18 // | The list of tokens.
const OR_ASSIGN Token = 29 // |= The list of tokens.
const PACKAGE Token = 78 The list of tokens.
const PERIOD Token = 53 // . The list of tokens.
const QUO Token = 15 // / The list of tokens.
const QUO_ASSIGN Token = 26 // /= The list of tokens.
const RANGE Token = 79 The list of tokens.
const RBRACE Token = 56 // } The list of tokens.
const RBRACK Token = 55 // ] The list of tokens.
const REM Token = 16 // % The list of tokens.
const REM_ASSIGN Token = 27 // %= The list of tokens.
const RETURN Token = 80 The list of tokens.
const RPAREN Token = 54 // ) The list of tokens.
const SELECT Token = 81 The list of tokens.
const SEMICOLON Token = 57 // ; The list of tokens.
const SHL Token = 20 // << The list of tokens.
const SHL_ASSIGN Token = 31 // <<= The list of tokens.
const SHR Token = 21 // >> The list of tokens.
const SHR_ASSIGN Token = 32 // >>= The list of tokens.
const STRING Token = 9 // "abc" The list of tokens.
const STRUCT Token = 82 The list of tokens.
const SUB Token = 13 // - The list of tokens.
const SUB_ASSIGN Token = 24 // -= The list of tokens.
const SWITCH Token = 83 The list of tokens.
const TYPE Token = 84 The list of tokens.
const UnaryPrec = 6 A set of constants for precedence-based expression parsing. Non-operators have lowest precedence, followed by operators starting with precedence 1 up to unary operators. The highest precedence serves as "catch-all" precedence for selector, indexing, and other operator and delimiter tokens.
const VAR Token = 85 The list of tokens.
const XOR Token = 19 // ^ The list of tokens.
const XOR_ASSIGN Token = 30 // ^= The list of tokens.