Documentation
¶
Overview ¶
Package token defines constants representing the lexical tokens of the Go programming language and basic operations on tokens (printing, predicates).
Index ¶
- Constants
- func IsKeyword(tok base.Token) bool
- func IsLiteral(tok base.Token) bool
- func IsMacroKeyword(tok base.Token) bool
- func IsOperator(tok base.Token) bool
- func Lookup(lit string) base.Token
- func LookupSpecial(lit string) base.Token
- func String(tok base.Token) string
- type File
- type FileSet
- func (s *FileSet) AddFile(filename string, base, size, line int) *File
- func (s *FileSet) File(p token.Pos) (f *File)
- func (s *FileSet) Position(p token.Pos) (pos token.Position)
- func (s *FileSet) PositionFor(p token.Pos, adjusted bool) (pos token.Position)
- func (s *FileSet) Source(p token.Pos) (line string, pos token.Position)
Constants ¶
Variables ¶
This section is empty.
Functions ¶
func IsKeyword ¶
IsKeyword returns true for tokens corresponding to keywords; it returns false otherwise.
func IsLiteral ¶
IsLiteral returns true for tokens corresponding to identifiers and basic type literals; it returns false otherwise.
func IsMacroKeyword ¶
IsMacroKeyword returns true for tokens corresponding to macro-related keywords; it returns false otherwise.
func IsOperator ¶
IsOperator returns true for tokens corresponding to operators and delimiters; it returns false otherwise.
func LookupSpecial ¶
LookupSpecial maps a identifier starting with '~' to its keyword token.
Types ¶
type File ¶
A File is a handle for a file belonging to a FileSet. A File has a name, size, line offset table and optionally source code.
func (*File) Position ¶
Position returns the Position value for the given file position p. Calling f.Position(p) is equivalent to calling f.PositionFor(p, true).
func (*File) PositionFor ¶
PositionFor returns the Position value for the given file position p. If adjusted is set, the position may be adjusted by position-altering //line comments; otherwise those comments are ignored. p must be a Pos value in f or NoPos.
func (*File) SetSourceForContent ¶
SetSourceForContent computes and sets the source code for the given file.
type FileSet ¶
A FileSet represents a set of source files. This is a wrapper for go/token.FileSet that adds a starting line offset to each file in the set
func (*FileSet) File ¶
File returns the file that contains the position p. If no such file is found (for instance for p == NoPos), the result is nil.
func (*FileSet) Position ¶
Position converts a Pos p in the fileset into a Position value. Calling s.Position(p) is equivalent to calling s.PositionFor(p, true).
func (*FileSet) PositionFor ¶
PositionFor converts a Pos p in the fileset into a Position value. If adjusted is set, the position may be adjusted by position-altering //line comments; otherwise those comments are ignored. p must be a Pos value in s or NoPos.