Documentation
¶
Index ¶
- Variables
- func FatalError(err error) error
- func FindLineColumn(data []byte, pos int) (int, int, bool)
- func IsFatalError(err error) bool
- func Keep[T any](pos int, v *T, fn VFn) (int, error)
- func LoopSepValue[T any](sc *Scanner, pos int, optLastSep bool, fn VFn, sepFn MFn) (any, int, error)
- func LoopValue[T any](m *Match, pos int, min, max int, fn VFn) (any, int, error)
- func OnValueM[T any](pos int, fn VFn, cb func(T) error) (int, error)
- func OnValueV[T any](pos int, fn VFn, cb func(T) (any, error)) (any, int, error)
- func SurroundingString(b []byte, k int, pad int) string
- func TStrValue[T ~string](sc *Scanner, pos int, fn MFn) (any, int, error)
- type AndOpt
- type Error
- type MFn
- type Match
- func (m *Match) And(pos int, fns ...MFn) (int, error)
- func (m *Match) And2(pos int, aopt AndOpt, fns ...MFn) (int, error)
- func (m *Match) AndFlexValue(pos int, fns ...any) (any, int, error)
- func (m *Match) AndNoReverse(pos int, fns ...MFn) (int, error)
- func (m *Match) AndOptSpaces(pos int, sopt SpacesOpt, fns ...MFn) (int, error)
- func (m *Match) AndValue(pos int, fns ...VFn) (any, int, error)
- func (m *Match) Byte(pos int, b byte) (int, error)
- func (m *Match) ByteFn(pos int, fn func(byte) bool) (int, error)
- func (m *Match) ByteFnLoop(pos int, fn func(byte) bool) (int, error)
- func (m *Match) ByteSequence(pos int, seq []byte) (int, error)
- func (m *Match) BytesValue(pos int, fn MFn) (any, int, error)
- func (m *Match) Digit(pos int) (int, error)
- func (m *Match) Digits(pos int) (int, error)
- func (m *Match) DoubleQuotedString(pos int, maxLen int) (int, error)
- func (m *Match) EmptyEof(p int) (int, error)
- func (m *Match) EmptyLine(p int) (int, error)
- func (m *Match) EmptyRestOfLine(p int) (int, error)
- func (m *Match) Eof(pos int) (int, error)
- func (m *Match) EscapeAny(pos int, escape rune) (int, error)
- func (m *Match) FailForOr(pos int, fn MFn) (int, error)
- func (m *Match) FatalOnError(pos int, s string, fn MFn) (int, error)
- func (m *Match) Float(pos int) (int, error)
- func (m *Match) Float32Value(pos int) (any, int, error)
- func (m *Match) Float64Value(pos int) (any, int, error)
- func (m *Match) FloatOrInteger(pos int) (int, error)
- func (m *Match) HexBytes(pos int) (int, error)
- func (m *Match) Identifier(pos int) (int, error)
- func (m *Match) Int64Value(pos int) (any, int, error)
- func (m *Match) IntFnValue(pos int, fn MFn) (any, int, error)
- func (m *Match) IntValue(pos int) (any, int, error)
- func (m *Match) Integer(pos int) (int, error)
- func (m *Match) Letter(pos int) (int, error)
- func (m *Match) LettersAndDigits(pos int) (int, error)
- func (m *Match) Loop(pos int, min, max int, fn MFn) (int, error)
- func (m *Match) LoopN(pos int, n int, fn MFn) (int, error)
- func (m *Match) LoopOneOrMore(pos int, fn MFn) (int, error)
- func (m *Match) LoopSep(pos int, optLastSep bool, fn, sepFn MFn) (int, error)
- func (m *Match) LoopSepValue(pos int, optLastSep bool, fn VFn, sepFn MFn) (any, int, error)
- func (m *Match) LoopStartEnd(pos int, min, max int, startFn, consumeFn, endFn MFn) (int, error)
- func (m *Match) LoopUntilNLOrEof(pos int, max int, includeNL bool, esc rune) (int, error)
- func (m *Match) LoopValue(pos int, min, max int, fn VFn) (any, int, error)
- func (m *Match) LoopZeroOrMore(pos int, fn MFn) (int, error)
- func (m *Match) MustErr(pos int, fn MFn) (int, error)
- func (m *Match) NBytes(pos int, n int) (int, error)
- func (m *Match) NBytesFn(pos int, n int, fn func(byte) bool) (int, error)
- func (m *Match) NRunes(pos int, n int) (int, error)
- func (m *Match) NRunesFn(pos int, n int, fn func(rune) bool) (int, error)
- func (m *Match) Newline(pos int) (int, error)
- func (m *Match) NilValue(pos int, fn MFn) (any, int, error)
- func (m *Match) NotEof(p int) (int, error)
- func (m *Match) OneByte(pos int) (int, error)
- func (m *Match) OneRune(pos int) (int, error)
- func (m *Match) Optional(pos int, fn MFn) (int, error)
- func (m *Match) OptionalValue(pos int, fn VFn) (any, int, error)
- func (m *Match) Or(pos int, fns ...MFn) (int, error)
- func (m *Match) OrValue(pos int, fns ...VFn) (any, int, error)
- func (m *Match) Peek(pos int, fn MFn) (int, error)
- func (m *Match) PrintLineColAndSrc(pos int) (int, error)
- func (m *Match) PrintLineColAndSrcForOr(pos int) (int, error)
- func (m *Match) PrintPosAndSrc(pos int) (int, error)
- func (m *Match) PrintPosAndSrcForOr(pos int) (int, error)
- func (m *Match) Printf(pos int, f string, args ...any) (int, error)
- func (m *Match) PrintfForOr(pos int, f string, args ...any) (int, error)
- func (m *Match) PtrFalse(pos int, v *bool) (int, error)
- func (m *Match) PtrFn(pos int, fn *MFn) (int, error)
- func (m *Match) PtrTrue(pos int, v *bool) (int, error)
- func (m *Match) QuotedString(pos int) (int, error)
- func (m *Match) QuotedString2(pos int, esc rune, maxLen1, maxLen2 int) (int, error)
- func (m *Match) RegexpFromStart(pos int, res string, cache bool, maxLen int) (int, error)
- func (m *Match) RegexpFromStartCached(pos int, res string, maxLen int) (int, error)
- func (m *Match) ReverseMode(pos int, reverse bool, fn MFn) (int, error)
- func (m *Match) Rune(pos int, ru rune) (int, error)
- func (m *Match) RuneFn(pos int, fn func(rune) bool) (int, error)
- func (m *Match) RuneFnLoop(pos int, fn func(rune) bool) (int, error)
- func (m *Match) RuneNoneOf(pos int, rs []rune) (int, error)
- func (m *Match) RuneOneOf(pos int, rs []rune) (int, error)
- func (m *Match) RuneRanges(pos int, rrs ...RuneRange) (int, error)
- func (m *Match) RuneSequence(pos int, seq []rune) (int, error)
- func (m *Match) RuneSequenceMid(pos int, rs []rune) (int, error)
- func (m *Match) RuneValue(pos int, fn MFn) (any, int, error)
- func (m *Match) Section(pos int, open, close string, esc rune, failOnNewline bool, max int, ...) (int, error)
- func (m *Match) Sequence(pos int, seq string) (int, error)
- func (m *Match) SequenceMid(pos int, seq string) (int, error)
- func (m *Match) Spaces(pos int, opt SpacesOpt) (int, error)
- func (m *Match) SpacesExceptNewline(pos int) (int, error)
- func (m *Match) SpacesIncludingNewline(pos int) (int, error)
- func (m *Match) StaticCondFn(pos int, v bool, tfn, ffn MFn) (int, error)
- func (m *Match) StrValue(pos int, fn MFn) (any, int, error)
- func (m *Match) StringSection(pos int, openclose string, esc rune, failOnNewline bool, maxLen int, ...) (int, error)
- type RuneRange
- type Scanner
- func (sc *Scanner) RawSrc() []byte
- func (sc *Scanner) ReadByte(pos int) (byte, int, error)
- func (sc *Scanner) ReadRune(pos int) (rune, int, error)
- func (sc *Scanner) SetSrc(src []byte)
- func (sc *Scanner) SetSrc2(src []byte, offset int)
- func (sc *Scanner) SrcByte(i int) byte
- func (sc *Scanner) SrcError(pos int, err error) error
- func (sc *Scanner) SrcFrom(a int) []byte
- func (sc *Scanner) SrcFromTo(a, b int) []byte
- func (sc *Scanner) SrcLineCol(pos int) (int, int, bool)
- func (sc *Scanner) SrcMax() int
- func (sc *Scanner) SrcMin() int
- func (sc *Scanner) SrcSection(pos int) string
- func (sc *Scanner) SrcTo(b int) []byte
- func (sc *Scanner) ValidPos(i int) int
- type SpacesOpt
- type VFn
- type Wrap
- func (w *Wrap) And(fns ...MFn) MFn
- func (w *Wrap) And2(aopt AndOpt, fns ...MFn) MFn
- func (w *Wrap) AndFlexValue(fns ...any) VFn
- func (w *Wrap) AndNoReverse(fns ...MFn) MFn
- func (w *Wrap) AndOptSpaces(sopt SpacesOpt, fns ...MFn) MFn
- func (w *Wrap) AndValue(fns ...VFn) VFn
- func (w *Wrap) Byte(b byte) MFn
- func (w *Wrap) ByteFn(fn func(byte) bool) MFn
- func (w *Wrap) ByteFnLoop(fn func(byte) bool) MFn
- func (w *Wrap) ByteSequence(seq []byte) MFn
- func (w *Wrap) BytesValue(fn MFn) VFn
- func (w *Wrap) Digit() MFn
- func (w *Wrap) Digits() MFn
- func (w *Wrap) DoubleQuotedString(maxLen int) MFn
- func (w *Wrap) EmptyEof() MFn
- func (w *Wrap) EmptyLine() MFn
- func (w *Wrap) EmptyRestOfLine() MFn
- func (w *Wrap) Eof() MFn
- func (w *Wrap) EscapeAny(escape rune) MFn
- func (w *Wrap) FailForOr(fn MFn) MFn
- func (w *Wrap) FatalOnError(s string, fn MFn) MFn
- func (w *Wrap) Float() MFn
- func (w *Wrap) Float32Value() VFn
- func (w *Wrap) Float64Value() VFn
- func (w *Wrap) FloatOrInteger() MFn
- func (w *Wrap) HexBytes() MFn
- func (w *Wrap) Identifier() MFn
- func (w *Wrap) Int64Value() VFn
- func (w *Wrap) IntFnValue(fn MFn) VFn
- func (w *Wrap) IntValue() VFn
- func (w *Wrap) Integer() MFn
- func (w *Wrap) Letter() MFn
- func (w *Wrap) LettersAndDigits() MFn
- func (w *Wrap) Loop(min, max int, fn MFn) MFn
- func (w *Wrap) LoopN(n int, fn MFn) MFn
- func (w *Wrap) LoopOneOrMore(fn MFn) MFn
- func (w *Wrap) LoopSep(optLastSep bool, fn, sepFn MFn) MFn
- func (w *Wrap) LoopSepValue(optLastSep bool, fn VFn, sepFn MFn) VFn
- func (w *Wrap) LoopStartEnd(min, max int, startFn, consumeFn, endFn MFn) MFn
- func (w *Wrap) LoopUntilNLOrEof(max int, includeNL bool, esc rune) MFn
- func (w *Wrap) LoopValue(min, max int, fn VFn) VFn
- func (w *Wrap) LoopZeroOrMore(fn MFn) MFn
- func (w *Wrap) MustErr(fn MFn) MFn
- func (w *Wrap) NBytes(n int) MFn
- func (w *Wrap) NBytesFn(n int, fn func(byte) bool) MFn
- func (w *Wrap) NRunes(n int) MFn
- func (w *Wrap) NRunesFn(n int, fn func(rune) bool) MFn
- func (w *Wrap) Newline() MFn
- func (w *Wrap) NilValue(fn MFn) VFn
- func (w *Wrap) NotEof() MFn
- func (w *Wrap) OneByte() MFn
- func (w *Wrap) OneRune() MFn
- func (w *Wrap) Optional(fn MFn) MFn
- func (w *Wrap) OptionalValue(fn VFn) VFn
- func (w *Wrap) Or(fns ...MFn) MFn
- func (w *Wrap) OrValue(fns ...VFn) VFn
- func (w *Wrap) Peek(fn MFn) MFn
- func (w *Wrap) PrintLineColAndSrc() MFn
- func (w *Wrap) PrintLineColAndSrcForOr() MFn
- func (w *Wrap) PrintPosAndSrc() MFn
- func (w *Wrap) PrintPosAndSrcForOr() MFn
- func (w *Wrap) Printf(f string, args ...any) MFn
- func (w *Wrap) PrintfForOr(f string, args ...any) MFn
- func (w *Wrap) PtrFalse(v *bool) MFn
- func (w *Wrap) PtrFn(fn *MFn) MFn
- func (w *Wrap) PtrTrue(v *bool) MFn
- func (w *Wrap) QuotedString() MFn
- func (w *Wrap) QuotedString2(esc rune, maxLen1, maxLen2 int) MFn
- func (w *Wrap) RegexpFromStart(res string, cache bool, maxLen int) MFn
- func (w *Wrap) RegexpFromStartCached(res string, maxLen int) MFn
- func (w *Wrap) ReverseMode(reverse bool, fn MFn) MFn
- func (w *Wrap) Rune(ru rune) MFn
- func (w *Wrap) RuneFn(fn func(rune) bool) MFn
- func (w *Wrap) RuneFnLoop(fn func(rune) bool) MFn
- func (w *Wrap) RuneNoneOf(rs []rune) MFn
- func (w *Wrap) RuneOneOf(rs []rune) MFn
- func (w *Wrap) RuneRanges(rrs ...RuneRange) MFn
- func (w *Wrap) RuneSequence(seq []rune) MFn
- func (w *Wrap) RuneSequenceMid(rs []rune) MFn
- func (w *Wrap) RuneValue(fn MFn) VFn
- func (w *Wrap) Section(open, close string, esc rune, failOnNewline bool, max int, eofClose bool, ...) MFn
- func (w *Wrap) Sequence(seq string) MFn
- func (w *Wrap) SequenceMid(seq string) MFn
- func (w *Wrap) Spaces(opt SpacesOpt) MFn
- func (w *Wrap) SpacesExceptNewline() MFn
- func (w *Wrap) SpacesIncludingNewline() MFn
- func (w *Wrap) StaticCondFn(v bool, tfn, ffn MFn) MFn
- func (w *Wrap) StrValue(fn MFn) VFn
- func (w *Wrap) StringSection(openclose string, esc rune, failOnNewline bool, maxLen int, eofClose bool) MFn
Constants ¶
This section is empty.
Variables ¶
var EOF = io.EOF
var NoMatchErr = errors.New("no match")
var SOF = errors.New("SOF") // start-of-file (as opposed to EOF)
Functions ¶
func FatalError ¶ added in v1.3.11
func FindLineColumn ¶ added in v1.3.11
probably belongs to a textutil pkg, but here to reduce dependencies
func IsFatalError ¶ added in v1.3.11
func LoopSepValue ¶ added in v1.3.11
Types ¶
type Match ¶
type Match struct {
W *Wrap
// contains filtered or unexported fields
}
func (*Match) AndFlexValue ¶ added in v1.3.11
func (*Match) AndNoReverse ¶ added in v1.3.11
runs in order, even when in reverse mode; usefull because and() might be needed to run in order, but have each fn honor internally the reverse setting
func (*Match) AndOptSpaces ¶ added in v1.3.11
func (*Match) ByteFnLoop ¶
one or more
func (*Match) DoubleQuotedString ¶
func (*Match) EmptyEof ¶ added in v1.3.11
NOTE: because of eof, if inside a loop can lead to inf loop
func (*Match) EmptyRestOfLine ¶ added in v1.3.11
NOTE: because of eof, if inside a loop can lead to inf loop
func (*Match) Float32Value ¶ added in v1.3.11
func (*Match) FloatOrInteger ¶ added in v1.3.11
func (*Match) LettersAndDigits ¶ added in v1.3.11
func (*Match) LoopOneOrMore ¶ added in v1.3.11
func (*Match) LoopSepValue ¶ added in v1.3.11
func (*Match) LoopStartEnd ¶ added in v1.3.11
func (*Match) LoopUntilNLOrEof ¶ added in v1.3.11
note that it can read zero if on eof; inside a loop could give endless loop
func (*Match) LoopZeroOrMore ¶ added in v1.3.11
func (*Match) OptionalValue ¶ added in v1.3.11
func (*Match) PrintLineColAndSrc ¶ added in v1.3.11
func (*Match) PrintLineColAndSrcForOr ¶ added in v1.3.11
func (*Match) PrintPosAndSrc ¶ added in v1.3.11
func (*Match) PrintPosAndSrcForOr ¶ added in v1.3.11
func (*Match) PrintfForOr ¶ added in v1.3.11
func (*Match) QuotedString2 ¶
allows escaped runes with esc!=0
func (*Match) RegexpFromStart ¶
func (*Match) RegexpFromStartCached ¶
func (*Match) RuneFnLoop ¶
one or more
func (*Match) Section ¶
func (m *Match) Section(pos int, open, close string, esc rune, failOnNewline bool, max int, eofClose bool, consumeFn MFn) (int, error)
match opened/closed sections.
func (*Match) SpacesExceptNewline ¶ added in v1.3.11
func (*Match) SpacesIncludingNewline ¶ added in v1.3.11
func (*Match) StaticCondFn ¶ added in v1.3.11
type Scanner ¶
type Scanner struct {
Reverse bool
Debug bool
M *Match
W *Wrap
// contains filtered or unexported fields
}
func NewScanner ¶
func NewScanner() *Scanner
func (*Scanner) RawSrc ¶ added in v1.3.11
WARNING: use with caution, using pos in resulting []byte might fail when there is offset func (sc *Scanner) SrcFullFromOffset() []byte { return sc.SrcFromTo(sc.SrcMin(), sc.SrcMax())
func (*Scanner) SrcLineCol ¶ added in v1.3.11
func (*Scanner) SrcSection ¶
type VFn ¶
func WLoopSepValue ¶ added in v1.3.11
type Wrap ¶
type Wrap struct {
M *Match
// contains filtered or unexported fields
}