scanner

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Sep 12, 2024 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const EOF = rune(-1)

EOF is a rune representing the end of a file

Variables

This section is empty.

Functions

This section is empty.

Types

type Range

type Range = directives.Range

type Scanner

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

Scanner is a scanner.

func New

func New(text, path string) *Scanner

New creates a new Scanner.

func (*Scanner) Advance

func (s *Scanner) Advance() error

Advance reads a rune.

func (*Scanner) Annotate

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

func (*Scanner) Backtrack

func (s *Scanner) Backtrack()

func (*Scanner) Current

func (s *Scanner) Current() rune

Current returns the current rune.

func (*Scanner) Offset

func (s *Scanner) Offset() int

Offset returns the current offset.

func (*Scanner) Range

func (s *Scanner) Range() Range

func (*Scanner) RangeContinue

func (s *Scanner) RangeContinue(desc string)

func (*Scanner) RangeEnd

func (s *Scanner) RangeEnd()

func (*Scanner) RangeStart

func (s *Scanner) RangeStart(desc string)

func (*Scanner) ReadAlternative

func (s *Scanner) ReadAlternative(ss []string) (Range, error)

func (*Scanner) ReadCharacter

func (s *Scanner) ReadCharacter(r rune) (Range, error)

ReadCharacter consumes the given rune.

func (*Scanner) ReadCharacterWith

func (s *Scanner) ReadCharacterWith(desc string, pred func(rune) bool) (Range, error)

ReadCharacter consume a rune satisfying the predicate.

func (*Scanner) ReadN

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

ReadN reads a string with n runes.

func (*Scanner) ReadString

func (s *Scanner) ReadString(str string) (Range, error)

ReadString parses the given string.

func (*Scanner) ReadUntil

func (s *Scanner) ReadUntil(desc string, pred func(r rune) bool) (Range, error)

ReadUntil advances the scanner until the predicate holds.

func (*Scanner) ReadWhile

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

ReadWhile reads a string while the predicate holds.

func (*Scanner) ReadWhile1

func (s *Scanner) ReadWhile1(desc string, pred func(r rune) bool) (Range, error)

ReadWhile reads a string while the predicate holds. The predicate must be satisfied at least once.

Jump to

Keyboard shortcuts

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