parseutil

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Dec 28, 2019 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ExtraRunes = "_-~.%@&?!=#+" + "()[]{}<>" + "\\^" + "/" + " " + ":"
View Source
var PathItemExtraRunes = RunesExcept(ExtraRunes, excludeResourceRunes+

	":") // line/column
View Source
var ResourceExtraRunes = RunesExcept(ExtraRunes, excludeResourceRunes)

Functions

func AddEscapes

func AddEscapes(str string, escape rune, escapeRunes string) string

func CleanMultiplePathSeps

func CleanMultiplePathSeps(str string, sep rune) string

func DetectEnvVar

func DetectEnvVar(str, name string) bool

TODO: review

func EscapeFilename

func EscapeFilename(str string) string

func ExpandIndexEscape

func ExpandIndexEscape(r iorw.Reader, i int, truth bool, fn func(rune) bool, escape rune) int

func ExpandIndexesEscape

func ExpandIndexesEscape(rd iorw.Reader, index int, truth bool, fn func(rune) bool, escape rune) (int, int)

func ExpandLastIndexEscape

func ExpandLastIndexEscape(r iorw.Reader, i int, truth bool, fn func(rune) bool, escape rune) int

func ImproveExpandIndexEscape

func ImproveExpandIndexEscape(r iorw.Reader, i int, escape rune) int

func IndexLineColumn

func IndexLineColumn(rd iorw.Reader, index int) (int, int, error)

Returned line/col values are one-based.

func LineColumnIndex

func LineColumnIndex(rd iorw.Reader, line, column int) (int, error)

Line/col args are one-based.

func RemoveEscapes

func RemoveEscapes(str string, escape rune) string

func RemoveEscapesEscapable

func RemoveEscapesEscapable(str string, escape rune, escapable string) string

removes the escape only if escapable

func RemoveFilenameEscapes

func RemoveFilenameEscapes(f string, escape, pathSep rune) string

func RunesExcept

func RunesExcept(runes, except string) string

Types

type FilePos

type FilePos struct {
	Filename     string
	Offset, Len  int // length after offset for a range
	Line, Column int // bigger than zero to be considered
}

func NewFilePosFromResource

func NewFilePosFromResource(res *Resource) *FilePos

func ParseFilePos

func ParseFilePos(str string) (*FilePos, error)

Parse fmt: <filename:line?:col?>. Accepts escapes but doesn't unescape.

func (*FilePos) HasOffset

func (fp *FilePos) HasOffset() bool

type ResParser

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

type Resource

type Resource struct {
	Path         string
	RawPath      string
	Line, Column int

	ExpandedMin, ExpandedMax int
	PathSep                  rune
	Escape                   rune
}

parsed formats:

<filename:line?:col?>
file://<filename:line?:col?>
// TODO: <filename:#offset>
// TODO: ranges?

func ParseResource

func ParseResource(rd iorw.Reader, index int) (*Resource, error)

Jump to

Keyboard shortcuts

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