go/src/text/scanner/scanner.go

type Position

// IsValid reports whether the position is valid.
func (pos *Position) IsValid() bool {}

func (pos Position) String() string {}

const ScanIdents

const ScanInts

const ScanFloats

const ScanChars

const ScanStrings

const ScanRawStrings

const ScanComments

const SkipComments

const GoTokens

const EOF

const Ident

const Int

const Float

const Char

const String

const RawString

const Comment

const skipComment

var tokenString

// TokenString returns a printable string for a token or Unicode character.
func TokenString(tok rune) string {}

const GoWhitespace

const bufLen

type Scanner

// Init initializes a [Scanner] with a new source and returns s.
// [Scanner.Error] is set to nil, [Scanner.ErrorCount] is set to 0, [Scanner.Mode] is set to [GoTokens],
// and [Scanner.Whitespace] is set to [GoWhitespace].
func (s *Scanner) Init(src io.Reader) *Scanner {}

// next reads and returns the next Unicode character. It is designed such
// that only a minimal amount of work needs to be done in the common ASCII
// case (one test to check for both ASCII and end-of-buffer, and one test
// to check for newlines).
func (s *Scanner) next() rune {}

// Next reads and returns the next Unicode character.
// It returns [EOF] at the end of the source. It reports
// a read error by calling s.Error, if not nil; otherwise
// it prints an error message to [os.Stderr]. Next does not
// update the [Scanner.Position] field; use [Scanner.Pos]() to
// get the current position.
func (s *Scanner) Next() rune {}

// Peek returns the next Unicode character in the source without advancing
// the scanner. It returns [EOF] if the scanner's position is at the last
// character of the source.
func (s *Scanner) Peek() rune {}

func (s *Scanner) error(msg string) {}

func (s *Scanner) errorf(format string, args ...any) {}

func (s *Scanner) isIdentRune(ch rune, i int) bool {}

func (s *Scanner) scanIdentifier() rune {}

func lower(ch rune) rune     {}

func isDecimal(ch rune) bool {}

func isHex(ch rune) bool     {}

// digits accepts the sequence { digit | '_' } starting with ch0.
// If base <= 10, digits accepts any decimal digit but records
// the first invalid digit >= base in *invalid if *invalid == 0.
// digits returns the first rune that is not part of the sequence
// anymore, and a bitset describing whether the sequence contained
// digits (bit 0 is set), or separators '_' (bit 1 is set).
func (s *Scanner) digits(ch0 rune, base int, invalid *rune) (ch rune, digsep int) {}

func (s *Scanner) scanNumber(ch rune, seenDot bool) (rune, rune) {}

func litname(prefix rune) string {}

// invalidSep returns the index of the first invalid separator in x, or -1.
func invalidSep(x string) int {}

func digitVal(ch rune) int {}

func (s *Scanner) scanDigits(ch rune, base, n int) rune {}

func (s *Scanner) scanEscape(quote rune) rune {}

func (s *Scanner) scanString(quote rune) (n int) {}

func (s *Scanner) scanRawString() {}

func (s *Scanner) scanChar() {}

func (s *Scanner) scanComment(ch rune) rune {}

// Scan reads the next token or Unicode character from source and returns it.
// It only recognizes tokens t for which the respective [Scanner.Mode] bit (1<<-t) is set.
// It returns [EOF] at the end of the source. It reports scanner errors (read and
// token errors) by calling s.Error, if not nil; otherwise it prints an error
// message to [os.Stderr].
func (s *Scanner) Scan() rune {}

// Pos returns the position of the character immediately after
// the character or token returned by the last call to [Scanner.Next] or [Scanner.Scan].
// Use the [Scanner.Position] field for the start position of the most
// recently scanned token.
func (s *Scanner) Pos() (pos Position) {}

// TokenText returns the string corresponding to the most recently scanned token.
// Valid after calling [Scanner.Scan] and in calls of [Scanner.Error].
func (s *Scanner) TokenText() string {}