Documentation ¶
Overview ¶
Package token defines constants representing the lexical tokens of the Go programming language and basic operations on tokens (printing, predicates).
Index ¶
- Variables
- func IsKeyword(tok Token) bool
- func IsLiteral(tok Token) bool
- func IsMacroKeyword(tok Token) bool
- func IsOperator(tok Token) bool
- func String(tok 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)
- type Generics
- type Token
Constants ¶
This section is empty.
Variables ¶
var GENERICS = GENERICS_NONE
can be changed at runtime. useful to enable them by in gomacro, without affecting packages that depend on gomacro, as Gophernotes
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.
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.
type Token ¶
const ( QUOTE Token = (token.VAR+127)&^127 + iota QUASIQUOTE UNQUOTE UNQUOTE_SPLICE MACRO FUNCTION LAMBDA TYPECASE TEMPLATE // template HASH // # // the following are never used by go/scanner // they are returned by ast2/Ast.Op() for corresponding AST nodes E_ALIASTYPE E_CALL E_DECLSTMT E_FIELDDECL E_FUNCDECL E_FUNCTYPE E_KEYVALUE E_LABELEDSTMT E_SENDSTMT E_TYPEASSERT E_TYPESWITCH )
func LookupSpecial ¶
LookupSpecial maps a identifier starting with '~' to its keyword token.