Documentation ¶
Index ¶
- Variables
- func AbsFilenameToUrl(filename string) (string, error)
- func AddEscapes(str string, escape rune, escapeRunes string) string
- func CleanMultiplePathSeps(str string, sep rune) string
- func CtxErrorStr(rd iorw.ReaderAt, filename string, pos int, msg string, contextSize int) string
- func CtxString(rd iorw.ReaderAt, pos int, contextSize int) (string, error)
- func DetectEnvVar(str, name string) bool
- func EscapeFilename(str string) string
- func ExpandIndexEscape(r iorw.ReaderAt, i int, truth bool, fn func(rune) bool, escape rune) int
- func ExpandIndexesEscape(rd iorw.ReaderAt, index int, truth bool, fn func(rune) bool, escape rune) (int, int)
- func ExpandLastIndexEscape(r iorw.ReaderAt, i int, truth bool, fn func(rune) bool, escape rune) int
- func ImproveExpandIndexEscape(r iorw.ReaderAt, i int, escape rune) int
- func IndexLineColumn(rd iorw.ReaderAt, index int) (int, int, error)
- func LineColumnIndex(rd iorw.ReaderAt, line, column int) (int, error)
- func ParseFields(s string, fieldSep rune) ([]string, error)
- func RemoveEscapes(str string, escape rune) string
- func RemoveEscapesEscapable(str string, escape rune, escapable string) string
- func RemoveFilenameEscapes(f string, escape, pathSep rune) string
- func RunesExcept(runes, except string) string
- func TrimLineSpaces(str string) string
- func TrimLineSpaces2(str string, pre string) string
- func UrlToAbsFilename(url2 string) (string, error)
- func VersionLessThan(a, b string) bool
- func VersionOrdinal(version string) string
- type ByteFunc
- type FilePos
- type Node
- type PosFunc
- type ResParser2
- type Resource
- type RuneFunc
- type ScanFunc
- type ScanFuncPtr
- type Scanner
- func (sc *Scanner) And(fns ...ScanFunc) bool
- func (sc *Scanner) AndF(fns ...ScanFunc) ScanFunc
- func (sc *Scanner) Any(valid string) bool
- func (sc *Scanner) AnyF(valid string) ScanFunc
- func (sc *Scanner) BuildNode(fn, trueFn ScanFunc) bool
- func (sc *Scanner) BuildNodeF(fn, trueFn ScanFunc) ScanFunc
- func (sc *Scanner) BuildPosNode(fn ScanFunc, trueFn PosFunc) bool
- func (sc *Scanner) BuildPosNodeF(fn ScanFunc, trueFn PosFunc) ScanFunc
- func (sc *Scanner) Byte(b byte) bool
- func (sc *Scanner) ByteF(b byte) ScanFunc
- func (sc *Scanner) ByteFn(fn ByteFunc) bool
- func (sc *Scanner) ByteFnF(fn ByteFunc) ScanFunc
- func (sc *Scanner) ByteRange(b1, b2 byte) bool
- func (sc *Scanner) ByteRangeF(b1, b2 byte) ScanFunc
- func (sc *Scanner) BytesNode(fn ScanFunc) bool
- func (sc *Scanner) BytesNodeF(fn ScanFunc) ScanFunc
- func (sc *Scanner) BytesValue(fn ScanFunc) ([]byte, bool)
- func (sc *Scanner) CtxString() string
- func (sc *Scanner) Digits() bool
- func (sc *Scanner) DoubleQuotedString(escape byte) bool
- func (sc *Scanner) DoubleQuotedStringF(escape byte) ScanFunc
- func (sc *Scanner) End() bool
- func (sc *Scanner) EscapedRune(escape byte) bool
- func (sc *Scanner) EscapedRuneF(escape byte) ScanFunc
- func (sc *Scanner) EscapedRuneFn(escape byte, fn RuneFunc) bool
- func (sc *Scanner) EscapedRuneFnF(escape byte, fn RuneFunc) ScanFunc
- func (sc *Scanner) Except(invalid string) bool
- func (sc *Scanner) ExceptF(invalid string) ScanFunc
- func (sc *Scanner) ExpandReverse(fn ScanFunc) bool
- func (sc *Scanner) ExpandReverseF(fn ScanFunc) ScanFunc
- func (sc *Scanner) Float() bool
- func (sc *Scanner) Float64Node(fn ScanFunc) bool
- func (sc *Scanner) Float64NodeF(fn ScanFunc) ScanFunc
- func (sc *Scanner) Float64Value(fn ScanFunc) (float64, bool)
- func (sc *Scanner) FnOnTrue(fn, trueFn ScanFunc) bool
- func (sc *Scanner) FnOnTrueF(fn, trueFn ScanFunc) ScanFunc
- func (sc *Scanner) GoQuotes(escape byte, maxLen, maxLenSingleQuote int) bool
- func (sc *Scanner) GoQuotesF(escape byte, maxLen, maxLenSingleQuote int) ScanFunc
- func (sc *Scanner) Hexadecimal() bool
- func (sc *Scanner) Id1() bool
- func (sc *Scanner) IntNode(fn ScanFunc) bool
- func (sc *Scanner) IntNodeF(fn ScanFunc) ScanFunc
- func (sc *Scanner) IntValue(fn ScanFunc) (int, bool)
- func (sc *Scanner) Integer() bool
- func (sc *Scanner) LineComment() bool
- func (sc *Scanner) Loop(fn ScanFunc) bool
- func (sc *Scanner) LoopAnyExceptSpaces(escape byte) bool
- func (sc *Scanner) LoopAnyExceptSpacesF(escape byte) ScanFunc
- func (sc *Scanner) LoopAnyToNewlineExcludeOrEnd() bool
- func (sc *Scanner) LoopAnyToNewlineIncludeOrEnd() bool
- func (sc *Scanner) LoopAnyToNewlineIncludeOrEndWithEscapes(escape byte) bool
- func (sc *Scanner) LoopF(fn ScanFunc) ScanFunc
- func (sc *Scanner) LoopRuneFn(fn RuneFunc) bool
- func (sc *Scanner) LoopRuneFnF(fn RuneFunc) ScanFunc
- func (sc *Scanner) LoopSep(fn, sepFn ScanFunc) bool
- func (sc *Scanner) LoopSepF(fn, sepFn ScanFunc) ScanFunc
- func (sc *Scanner) LoopUntil(maxN int, fn, untilFn ScanFunc) bool
- func (sc *Scanner) LoopUntilF(maxN int, fn, untilFn ScanFunc) ScanFunc
- func (sc *Scanner) MultiLineComment() bool
- func (sc *Scanner) NRunes(n int) bool
- func (sc *Scanner) NRunesF(n int) ScanFunc
- func (sc *Scanner) NodeQLen() int
- func (sc *Scanner) Optional(fn ScanFunc) bool
- func (sc *Scanner) OptionalF(fn ScanFunc) ScanFunc
- func (sc *Scanner) Or(fns ...ScanFunc) bool
- func (sc *Scanner) OrF(fns ...ScanFunc) ScanFunc
- func (sc *Scanner) PeekRune() (rune, error)
- func (sc *Scanner) Pointer() ScanFuncPtr
- func (sc *Scanner) PopFrontNode() Node
- func (sc *Scanner) PosFnOnTrue(fn ScanFunc, trueFn PosFunc) bool
- func (sc *Scanner) PosFnOnTrueF(fn ScanFunc, trueFn PosFunc) ScanFunc
- func (sc *Scanner) PrintPosF(fn ScanFunc) ScanFunc
- func (sc *Scanner) PrintlnF(v bool, s string) ScanFunc
- func (sc *Scanner) PushBackNode(node Node)
- func (sc *Scanner) QuotedString(quote rune, escape byte, failOnNewline bool, maxLen int) bool
- func (sc *Scanner) QuotedString2(validQuotes string, escape byte, failOnNewline bool, maxLen int) bool
- func (sc *Scanner) QuotedString2F(validQuotes string, escape byte, failOnNewline bool, maxLen int) ScanFunc
- func (sc *Scanner) QuotedStringF(quote rune, escape byte, failOnNewline bool, maxLen int) ScanFunc
- func (sc *Scanner) ReadByte() (byte, error)
- func (sc *Scanner) ReadRune() (rune, error)
- func (sc *Scanner) Reset()
- func (sc *Scanner) ResetErrors()
- func (sc *Scanner) ResetNodeQ()
- func (sc *Scanner) ResetPos()
- func (sc *Scanner) Result(mainFn ScanFunc) (Node, error)
- func (sc *Scanner) Rewind(fn ScanFunc) bool
- func (sc *Scanner) RewindF(fn ScanFunc) ScanFunc
- func (sc *Scanner) RewindOnFalse(fn ScanFunc) bool
- func (sc *Scanner) RewindOnFalseF(fn ScanFunc) ScanFunc
- func (sc *Scanner) Rune(ru rune) bool
- func (sc *Scanner) RuneF(ru rune) ScanFunc
- func (sc *Scanner) RuneFn(fn RuneFunc) bool
- func (sc *Scanner) RuneFnF(fn RuneFunc) ScanFunc
- func (sc *Scanner) RuneNotFn(fn RuneFunc) bool
- func (sc *Scanner) RuneNotFnF(fn RuneFunc) ScanFunc
- func (sc *Scanner) RunePeek(ru rune) bool
- func (sc *Scanner) RunePeekF(ru rune) ScanFunc
- func (sc *Scanner) RuneRange(ru1, ru2 rune) bool
- func (sc *Scanner) RuneRangeF(ru1, ru2 rune) ScanFunc
- func (sc *Scanner) Section(open, close string, escape byte, failOnNewline bool, maxLen int, eofClose bool) bool
- func (sc *Scanner) SectionF(open, close string, escape byte, failOnNewline bool, maxLen int, eofClose bool) ScanFunc
- func (sc *Scanner) Sequence(s string) bool
- func (sc *Scanner) SequenceExpand(s string) bool
- func (sc *Scanner) SequenceExpandF(seq string) ScanFunc
- func (sc *Scanner) SequenceF(seq string) ScanFunc
- func (sc *Scanner) SetBytes(b []byte)
- func (sc *Scanner) SetReader(rd iorw.ReaderAt)
- func (sc *Scanner) SetScanErrorf(f string, args ...interface{})
- func (sc *Scanner) SetStopErrorf(f string, args ...interface{})
- func (sc *Scanner) SingleNode(fn ScanFunc) bool
- func (sc *Scanner) SingleNodeF(fn ScanFunc) ScanFunc
- func (sc *Scanner) SingleQuotedString(escape byte) bool
- func (sc *Scanner) Spaces() bool
- func (sc *Scanner) SpacesExceptNewline() bool
- func (sc *Scanner) SpacesExceptNewline2(escape byte) bool
- func (sc *Scanner) SpacesExceptNewline2F(escape byte) ScanFunc
- func (sc *Scanner) StringNode(fn ScanFunc) bool
- func (sc *Scanner) StringNodeF(fn ScanFunc) ScanFunc
- func (sc *Scanner) StringUnquoteNode(fn ScanFunc) bool
- func (sc *Scanner) StringUnquoteNodeF(fn ScanFunc) ScanFunc
- func (sc *Scanner) StringUnquoteValue(fn ScanFunc) (string, bool)
- func (sc *Scanner) StringValue(fn ScanFunc) (string, bool)
- func (sc *Scanner) StringValueFn(fn ScanFunc, trueFn func(string) bool) bool
- func (sc *Scanner) StringValueFnF(fn ScanFunc, trueFn func(string) bool) ScanFunc
- func (sc *Scanner) UseReverse(reverse bool, fn ScanFunc) bool
- func (sc *Scanner) UseReverseF(reverse bool, fn ScanFunc) ScanFunc
- type ScannerReader
- type StopError
Constants ¶
This section is empty.
Variables ¶
View Source
var Escape rune = rune(osutil.EscapeRune)
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 CleanMultiplePathSeps ¶
func CtxErrorStr ¶ added in v1.3.3
func DetectEnvVar ¶
func EscapeFilename ¶
func ExpandIndexEscape ¶
func ExpandIndexesEscape ¶
func ExpandLastIndexEscape ¶
func IndexLineColumn ¶
Returned line/col values are one-based.
func LineColumnIndex ¶
Line/col args are one-based.
func RemoveEscapes ¶
func RemoveEscapesEscapable ¶
removes the escape only if escapable
func RemoveFilenameEscapes ¶
func RunesExcept ¶
func TrimLineSpaces2 ¶ added in v1.3.1
func UrlToAbsFilename ¶
func VersionLessThan ¶ added in v1.3.1
func VersionOrdinal ¶ added in v1.3.1
constructs a byte array (returned as a string) with the count of sequential digits to be able to compare "1.9"<"1.10"
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 ParseFilePos ¶
Parse fmt: <filename:line?:col?>. Accepts escapes but doesn't unescape.
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 "/"
type ScanFuncPtr ¶ added in v1.3.3
type ScanFuncPtr struct {
// contains filtered or unexported fields
}
func (*ScanFuncPtr) Ptr ¶ added in v1.3.3
func (ptr *ScanFuncPtr) Ptr() bool
func (*ScanFuncPtr) SetPtr ¶ added in v1.3.3
func (ptr *ScanFuncPtr) SetPtr(fn ScanFunc)
type Scanner ¶ added in v1.3.3
type Scanner struct { Pos int Reverse bool // read direction ErrPadSize int DebugRead bool // contains filtered or unexported fields }
WARNING: user functions are responsible for rewinding on fail; check sc.Or(...), sc.Optional(...), etc.
func NewScanner ¶ added in v1.3.3
func NewScanner() *Scanner
func NewScannerFromBytes ¶ added in v1.3.3
func NewScannerFromReader ¶ added in v1.3.3
func NewScannerFromString ¶ added in v1.3.3
func (*Scanner) BuildNodeF ¶ added in v1.3.3
func (*Scanner) BuildPosNode ¶ added in v1.3.3
func (*Scanner) BuildPosNodeF ¶ added in v1.3.3
func (*Scanner) ByteRangeF ¶ added in v1.3.3
func (*Scanner) BytesNodeF ¶ added in v1.3.3
func (*Scanner) BytesValue ¶ added in v1.3.3
func (*Scanner) DoubleQuotedString ¶ added in v1.3.3
func (*Scanner) DoubleQuotedStringF ¶ added in v1.3.3
func (*Scanner) EscapedRune ¶ added in v1.3.3
func (*Scanner) EscapedRuneF ¶ added in v1.3.3
func (*Scanner) EscapedRuneFn ¶ added in v1.3.3
func (*Scanner) EscapedRuneFnF ¶ added in v1.3.3
func (*Scanner) ExpandReverse ¶ added in v1.3.3
func (*Scanner) ExpandReverseF ¶ added in v1.3.3
func (*Scanner) Float64Node ¶ added in v1.3.3
func (*Scanner) Float64NodeF ¶ added in v1.3.3
func (*Scanner) Float64Value ¶ added in v1.3.3
func (*Scanner) Hexadecimal ¶ added in v1.3.3
func (*Scanner) LineComment ¶ added in v1.3.3
func (*Scanner) Loop ¶ added in v1.3.3
Usage example when building slices
func() bool { res:=[]int{} return sc.FnOnTrue( sc.LoopF(func() bool{ res=append(res, ...) ...}), func()bool{ sc.PushBackNode(res) // only on true }, ) }
func (*Scanner) LoopAnyExceptSpaces ¶ added in v1.3.3
func (*Scanner) LoopAnyExceptSpacesF ¶ added in v1.3.3
func (*Scanner) LoopAnyToNewlineExcludeOrEnd ¶ added in v1.3.3
func (*Scanner) LoopAnyToNewlineIncludeOrEnd ¶ added in v1.3.3
func (*Scanner) LoopAnyToNewlineIncludeOrEndWithEscapes ¶ added in v1.3.3
func (*Scanner) LoopRuneFn ¶ added in v1.3.3
func (*Scanner) LoopRuneFnF ¶ added in v1.3.3
func (*Scanner) LoopUntilF ¶ added in v1.3.3
func (*Scanner) MultiLineComment ¶ added in v1.3.3
func (*Scanner) Pointer ¶ added in v1.3.3
func (sc *Scanner) Pointer() ScanFuncPtr
usage: a := sc.Pointer(); sc.And(a.Ptr); ... ; a.SetPtr(...)
func (*Scanner) PopFrontNode ¶ added in v1.3.3
func (*Scanner) PosFnOnTrue ¶ added in v1.3.3
func (*Scanner) PosFnOnTrueF ¶ added in v1.3.3
func (*Scanner) PushBackNode ¶ added in v1.3.3
func (*Scanner) QuotedString ¶ added in v1.3.3
func (*Scanner) QuotedString2 ¶ added in v1.3.3
func (*Scanner) QuotedString2F ¶ added in v1.3.3
func (*Scanner) QuotedStringF ¶ added in v1.3.3
func (*Scanner) ResetErrors ¶ added in v1.3.3
func (sc *Scanner) ResetErrors()
func (*Scanner) ResetNodeQ ¶ added in v1.3.3
func (sc *Scanner) ResetNodeQ()
func (*Scanner) RewindOnFalse ¶ added in v1.3.3
func (*Scanner) RewindOnFalseF ¶ added in v1.3.3
func (*Scanner) RuneNotFnF ¶ added in v1.3.3
func (*Scanner) RuneRangeF ¶ added in v1.3.3
func (*Scanner) SequenceExpand ¶ added in v1.3.3
func (*Scanner) SequenceExpandF ¶ added in v1.3.3
func (*Scanner) SetScanErrorf ¶ added in v1.3.3
func (*Scanner) SetStopErrorf ¶ added in v1.3.3
func (*Scanner) SingleNode ¶ added in v1.3.3
Ensures single node on true
func (*Scanner) SingleNodeF ¶ added in v1.3.3
func (*Scanner) SingleQuotedString ¶ added in v1.3.3
func (*Scanner) SpacesExceptNewline ¶ added in v1.3.3
func (*Scanner) SpacesExceptNewline2 ¶ added in v1.3.3
func (*Scanner) SpacesExceptNewline2F ¶ added in v1.3.3
func (*Scanner) StringNode ¶ added in v1.3.3
func (*Scanner) StringNodeF ¶ added in v1.3.3
func (*Scanner) StringUnquoteNode ¶ added in v1.3.3
func (*Scanner) StringUnquoteNodeF ¶ added in v1.3.3
func (*Scanner) StringUnquoteValue ¶ added in v1.3.3
func (*Scanner) StringValue ¶ added in v1.3.3
func (*Scanner) StringValueFn ¶ added in v1.3.3
func (*Scanner) StringValueFnF ¶ added in v1.3.3
func (*Scanner) UseReverse ¶ added in v1.3.3
type ScannerReader ¶ added in v1.3.3
Click to show internal directories.
Click to hide internal directories.