parseutil

package
v2.0.0-...-7f6935a Latest Latest
Warning

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

Go to latest
Published: May 5, 2020 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

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

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

Functions

func AbsFilenameToUrl

func AbsFilenameToUrl(filename string) (string, error)

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

func EscapeFilename

func EscapeFilename(str string) string

func ExpandIndexEscape

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

func ExpandIndexesEscape

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

func ExpandLastIndexEscape

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

func ImproveExpandIndexEscape

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

func IndexLineColumn

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

Returned line/col values are one-based.

func LineColumnIndex

func LineColumnIndex(rd iorw.ReaderAt, 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

func TrimLineSpaces

func TrimLineSpaces(str string) string

Useful to compare src code lines.

func UrlToAbsFilename

func UrlToAbsFilename(uri string) (string, error)

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 ResParser2

type ResParser2 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
	ParseVolume              bool
}

parsed formats:

<filename:line?:col?>
<filename:#offset> # TODO
file://<filename:line?:col?> # filename should be absolute starting with "/"

func ParseResource

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

func ParseResource2

func ParseResource2(rd iorw.ReaderAt, index int, sep, esc rune, parseVolume bool) (*Resource, error)

Jump to

Keyboard shortcuts

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