scanner

package
v0.0.12 Latest Latest
Warning

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

Go to latest
Published: Aug 24, 2021 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const EOF = rune(0)

EOF is a rune representing the end of a file

Variables

This section is empty.

Functions

This section is empty.

Types

type Scanner

type Scanner struct {

	// Path is the file path.
	Path string
	// contains filtered or unexported fields
}

Scanner is a backtracking reader.

func New

func New(r io.RuneReader, path string) (*Scanner, error)

New creates a new Scanner.

func (*Scanner) Advance

func (s *Scanner) Advance() error

Advance reads a rune.

func (*Scanner) ConsumeRune

func (s *Scanner) ConsumeRune(r rune) error

ConsumeRune consumes the given rune

func (*Scanner) ConsumeUntil

func (s *Scanner) ConsumeUntil(pred func(r rune) bool) error

ConsumeUntil advances the parser until the predicate holds

func (*Scanner) ConsumeWhile

func (s *Scanner) ConsumeWhile(pred func(r rune) bool) error

ConsumeWhile advances the parser while the predicate holds

func (*Scanner) Current

func (s *Scanner) Current() rune

Current returns the current rune.

func (*Scanner) ParseError added in v0.0.6

func (s *Scanner) ParseError(err error) error

ParseError creates a new parser error with the current position.

func (*Scanner) ParseString

func (s *Scanner) ParseString(str string) error

ParseString parses the given string

func (*Scanner) Position

func (s *Scanner) Position() model.FilePosition

Position returns the current position.

func (*Scanner) ReadN added in v0.0.11

func (s *Scanner) ReadN(n int) (string, error)

ReadN reads a string with n runes

func (*Scanner) ReadRune

func (s *Scanner) ReadRune() (r rune, size int, err error)

ReadRune implements io.RuneReader.

func (*Scanner) ReadWhile

func (s *Scanner) ReadWhile(pred func(r rune) bool) (string, error)

ReadWhile reads runes into the builder while the predicate holds

Jump to

Keyboard shortcuts

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