runes

package
v1.2.1 Latest Latest
Warning

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

Go to latest
Published: Jul 8, 2022 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package runes provides a simpler rune scanner for lexers.

It reads an io.Reader entirely into memory to accomplish this so should only be used where the data can easily fit into memory.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Rune

type Rune struct {
	Val rune         // actual rune
	Pos buf.Position // position of the rune as relates to the document
}

Rune wraps a rune with with positioning

type Runes

type Runes struct {
	Val []rune       // actual runes
	Pos buf.Position // position of the first rune as relates to the document
}

Runes wraps a slice of rune with positioning

type Scanner

type Scanner struct {
	Pos buf.Position // line, column and offset positioning in document
	// contains filtered or unexported fields
}

Scanner provides methods for working with documents as runes

func NewScanner

func NewScanner(reader io.Reader) *Scanner

NewScanner for scanning documents as runes

func (*Scanner) Peek

func (s *Scanner) Peek(offset ...int) rune

Peek the rune at the given offset, offset must be positive values, 0 being the current rune; don't adjust positioning

func (*Scanner) PeekE added in v1.1.34

func (s *Scanner) PeekE(offset ...int) (r Rune, err error)

PeekE the rune at the given offset, offset must be positive values, 0 being the current rune; don't adjust positioning

func (*Scanner) PeekPrev

func (s *Scanner) PeekPrev(offset ...int) rune

PeekPrev the rune at the given offset, offset must be positive values, 0 being the previous rune, 1 being the one before the previous; don't adjust positioning

func (*Scanner) PeekPrevE added in v1.1.34

func (s *Scanner) PeekPrevE(offset ...int) (r Rune, err error)

PeekPrevE the rune at the given offset, offset must be positive values, 0 being the previous rune, 1 being the one before the previous; don't adjust positioning

func (*Scanner) Read

func (s *Scanner) Read() rune

Read the rune at the current location and adjust positioning

func (*Scanner) ReadE added in v1.1.34

func (s *Scanner) ReadE() (r Rune, err error)

ReadE the rune at the current location and adjust positioning

func (*Scanner) Readline

func (s *Scanner) Readline() (line Runes, err error)

Readline from the rune slice location up to and including the next newline adjusting positioning

func (*Scanner) Size

func (s *Scanner) Size() int

Size simply exposes the len of the rune slice

func (*Scanner) Unread

func (s *Scanner) Unread() rune

Unread the rune at the current location and adjust positioning

func (*Scanner) UnreadE added in v1.1.34

func (s *Scanner) UnreadE() (r Rune, err error)

UnreadE the rune at the current location and adjust positioning

func (*Scanner) Unreadline

func (s *Scanner) Unreadline() (line Runes, err error)

Unreadline from the current location back to the previous newline adjusting positioning

Jump to

Keyboard shortcuts

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