Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Mode ¶
type Mode uint
Mode is an enum type to control recognition of tokens.
const ( ScanIdent Mode = 1 << iota ScanNumberLit ScanStrLit ScanBoolLit ScanKeyword ScanComment ScanLit = ScanNumberLit | ScanStrLit | ScanBoolLit )
Predefined mode bits to control recognition of tokens.
type Option ¶
type Option func(*Scanner)
Option is an option for scanner.NewScanner.
func WithFilename ¶
WithFilename is an option to set filename to the pos.
type Position ¶
type Position struct { // Filename is a name of file, if any Filename string // Offset is a byte offset, starting at 0 Offset int // Line is a line number, starting at 1 Line int // Column is a column number, starting at 1 (character count per line) Column int // contains filtered or unexported fields }
Position represents a source position.
type Scanner ¶
type Scanner struct { // The Mode field controls which tokens are recognized. Mode Mode // contains filtered or unexported fields }
Scanner represents a lexical scanner.
func NewScanner ¶
NewScanner returns a new instance of Scanner.
func (*Scanner) LastScanRaw ¶
LastScanRaw returns the deep-copied lastScanRaw.
func (*Scanner) SetLastScanRaw ¶
SetLastScanRaw sets lastScanRaw to the given raw.
type Token ¶
type Token int
Token represents a lexical token.
const ( // Special tokens TILLEGAL Token = iota TEOF // Identifiers TIDENT // Literals TINTLIT TFLOATLIT TBOOLLIT TSTRLIT // Comment TCOMMENT // Misc characters TSEMICOLON // ; TCOLON // : TEQUALS // = TQUOTE // " or ' TLEFTPAREN // ( TRIGHTPAREN // ) TLEFTCURLY // { TRIGHTCURLY // } TLEFTSQUARE // [ TRIGHTSQUARE // ] TLESS // < TGREATER // > TCOMMA // , TDOT // . // Keywords TSYNTAX TSERVICE TRPC TRETURNS TMESSAGE TEXTEND TIMPORT TPACKAGE TOPTION TREPEATED TREQUIRED TOPTIONAL TWEAK TPUBLIC TONEOF TMAP TRESERVED TEXTENSIONS TENUM TSTREAM TGROUP )
The result of Scan is one of these tokens.
Click to show internal directories.
Click to hide internal directories.