scanner

package
v1.0.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 22, 2020 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// EOF represents the end of input
	EOF rune = -1
)

Variables

View Source
var (
	ErrEOF       = errors.New("reach at EOF")
	ErrRuneError = errors.New("utf8 rune decode error")
)

Functions

This section is empty.

Types

type Scanner

type Scanner struct {
	// contains filtered or unexported fields
}

Scanner provides a convenient interface for reading unicode data using regexp match

func New

func New(input string) *Scanner

New creates a new Scanner

func (*Scanner) Eof

func (s *Scanner) Eof() bool

Eof returns whether scan to end of input

func (*Scanner) Errorf

func (s *Scanner) Errorf(format string, args ...interface{}) error

Errorf reports an error with position

func (*Scanner) Peek

func (s *Scanner) Peek() rune

Peek returns a rune, result may be EOF, utf8.RuneError

func (*Scanner) PeekN

func (s *Scanner) PeekN(n int) []rune

PeekN returns some runes, if no enough runes, return all

func (*Scanner) Pos

func (s *Scanner) Pos() int

Pos returns current pos of scan

func (*Scanner) Scan

func (s *Scanner) Scan(re *regexp.Regexp) (string, bool)

Scan returns next matched string

func (*Scanner) ScanChar

func (s *Scanner) ScanChar() (rune, bool)

ScanChar returns next rune

func (*Scanner) ScanFloat64

func (s *Scanner) ScanFloat64() (float64, bool)

ScanFloat64 returns an float64

func (*Scanner) ScanIdentifier

func (s *Scanner) ScanIdentifier() (string, bool)

ScanIdentifier returns an identifier

func (*Scanner) ScanInt64

func (s *Scanner) ScanInt64() (int64, bool)

ScanInt64 returns an int64

func (*Scanner) ScanQuoteString

func (s *Scanner) ScanQuoteString() (string, bool)

ScanQuoteString returns an quote string

func (*Scanner) ScanString

func (s *Scanner) ScanString() (string, bool)

ScanString returns a string, the string can be quoted by '"', '\”, '`'

func (*Scanner) ScanToEnd

func (s *Scanner) ScanToEnd() string

ScanToEnd returns remaining text

func (*Scanner) ScanUntil

func (s *Scanner) ScanUntil(delim rune, included bool) (string, bool)

ScanUntil returns text before delim

func (*Scanner) SkipWhitespaces

func (s *Scanner) SkipWhitespaces() bool

SkipWhitespaces skips whitespaces, and returns true if skipped > 0

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL