guts

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: May 6, 2019 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	UintMax = ^uint(0)
	U64Max  = ^uint64(0)
	IntMax  = int(UintMax >> 1)
	IntMin  = ^IntMax
)

Variables

This section is empty.

Functions

func DenseBit

func DenseBit(ch rune) uint64

func EqualRunes

func EqualRunes(a, b []rune) bool

func IsHex

func IsHex(ch rune) bool

func IsOct

func IsOct(ch rune) bool

func IsPunct

func IsPunct(ch rune) bool

func SafeAppendRune

func SafeAppendRune(runes []rune, ch rune) []rune

Types

type AnyMatch

type AnyMatch struct{}

func (*AnyMatch) ForEachRange

func (*AnyMatch) ForEachRange(fn func(lo, hi rune))

func (*AnyMatch) MatchRune

func (*AnyMatch) MatchRune(ch rune) bool

func (*AnyMatch) Not

func (*AnyMatch) Not() RuneMatcher

type Capture

type Capture struct {
	InputP   uint
	InputQ   uint
	SegmentP uint
	PatternP uint
	PatternQ uint
}

type ExceptRangeMatch

type ExceptRangeMatch struct{ Lo, Hi rune }

func (*ExceptRangeMatch) ForEachRange

func (m *ExceptRangeMatch) ForEachRange(fn func(lo, hi rune))

func (*ExceptRangeMatch) MatchRune

func (m *ExceptRangeMatch) MatchRune(ch rune) bool

func (*ExceptRangeMatch) Not

func (m *ExceptRangeMatch) Not() RuneMatcher

type ExceptSetMatch

type ExceptSetMatch struct {
	Dense0 uint64
	Dense1 uint64
	Ranges SortedLoHi
}

func (*ExceptSetMatch) ForEachRange

func (m *ExceptSetMatch) ForEachRange(fn func(lo, hi rune))

func (*ExceptSetMatch) MatchRune

func (m *ExceptSetMatch) MatchRune(ch rune) bool

func (*ExceptSetMatch) Not

func (m *ExceptSetMatch) Not() RuneMatcher

type ExplodedString

type ExplodedString struct {
	String string
	Runes  []rune
	Map    []uint
}

func Norm

func Norm(in string) ExplodedString

func (ExplodedString) Substring

func (x ExplodedString) Substring(i, j uint) string

type Glob

type Glob struct {
	Pattern   ExplodedString
	Segments  []Segment
	MinLength uint
	MaxLength uint
}

func (*Glob) Compile

func (g *Glob) Compile(input string) error

func (*Glob) Matcher

func (g *Glob) Matcher(out *Matcher, input string)

type IndexSet

type IndexSet map[uint]bool

type IsMatch

type IsMatch struct{ Rune rune }

func (*IsMatch) ForEachRange

func (m *IsMatch) ForEachRange(fn func(lo, hi rune))

func (*IsMatch) MatchRune

func (m *IsMatch) MatchRune(ch rune) bool

func (*IsMatch) Not

func (m *IsMatch) Not() RuneMatcher

type IsNotMatch

type IsNotMatch struct{ Rune rune }

func (*IsNotMatch) ForEachRange

func (m *IsNotMatch) ForEachRange(fn func(lo, hi rune))

func (*IsNotMatch) MatchRune

func (m *IsNotMatch) MatchRune(ch rune) bool

func (*IsNotMatch) Not

func (m *IsNotMatch) Not() RuneMatcher

type LoHi

type LoHi struct{ Lo, Hi rune }

type Matcher

type Matcher struct {
	Memo     MemoMap
	Input    ExplodedString
	C        Capture
	InputI   uint
	InputJ   uint
	SegmentI uint
	SegmentJ uint
	Valid    bool
}

func (*Matcher) Capture

func (m *Matcher) Capture() *Capture

func (*Matcher) HasNext

func (m *Matcher) HasNext(g *Glob) bool

func (*Matcher) Matches

func (m *Matcher) Matches(g *Glob) bool

func (*Matcher) OK

func (m *Matcher) OK() bool

func (*Matcher) Tick

func (m *Matcher) Tick(g *Glob, seg Segment, moreSegments bool) (uint, bool)

func (*Matcher) WouldAccept

func (m *Matcher) WouldAccept(g *Glob, i uint) bool

type MemoKey

type MemoKey struct{ InputI, SegmentI uint }

type MemoMap

type MemoMap map[MemoKey]*MemoValue

type MemoValue

type MemoValue struct {
	Checked  bool
	Rejected bool
	Index    uint
}

type NoneMatch

type NoneMatch struct{}

func (*NoneMatch) ForEachRange

func (*NoneMatch) ForEachRange(func(lo, hi rune))

func (*NoneMatch) MatchRune

func (*NoneMatch) MatchRune(ch rune) bool

func (*NoneMatch) Not

func (*NoneMatch) Not() RuneMatcher

type ParseState

type ParseState byte
const (
	RootState ParseState = iota
	RootEscState
	RootOctState
	RootHexState
	CharsetInitialState
	CharsetHeadState
	CharsetHeadEscState
	CharsetHeadOctState
	CharsetHeadHexState
	CharsetMidState
	CharsetTailState
	CharsetTailEscState
	CharsetTailOctState
	CharsetTailHexState
)

func (ParseState) GoString

func (x ParseState) GoString() string

func (ParseState) String

func (x ParseState) String() string

type Parser

type Parser struct {
	Input            ExplodedString
	Segments         []Segment
	Ranges           []LoHi
	PartialLiteral   []rune
	PartialEscape    []rune
	LastSegment      *Segment
	Err              error
	InputP           uint
	InputQ           uint
	InputI           uint
	InputJ           uint
	MinLength        uint
	MaxLength        uint
	EscapeIntroducer rune
	State            ParseState
	EscapeLen        byte
	Negate           bool
	WantSet          bool
}

func (*Parser) EmitLiteral

func (p *Parser) EmitLiteral(ch rune)

func (*Parser) EmitSegment

func (p *Parser) EmitSegment(t SegmentType, PatternP, PatternQ uint)

func (*Parser) EmitSetHi

func (p *Parser) EmitSetHi(ch rune)

func (*Parser) EmitSetLo

func (p *Parser) EmitSetLo(ch rune)

func (*Parser) Fail

func (p *Parser) Fail(format string, args ...interface{})

func (*Parser) FlushLiteral

func (p *Parser) FlushLiteral()

func (*Parser) FlushSet

func (p *Parser) FlushSet()

func (*Parser) MakeError

func (p *Parser) MakeError(format string, args ...interface{}) error

func (*Parser) ProcessEscape

func (p *Parser) ProcessEscape(ch rune, ifOct, ifHex, ifPunct ParseState, emit func(rune))

func (*Parser) ProcessHex

func (p *Parser) ProcessHex(ch rune, ifDone ParseState, emit func(rune))

func (*Parser) ProcessOct

func (p *Parser) ProcessOct(ch rune, ifDone ParseState, emit func(rune))

func (*Parser) Run

func (p *Parser) Run()

type RangeMatch

type RangeMatch struct{ Lo, Hi rune }

func (*RangeMatch) ForEachRange

func (m *RangeMatch) ForEachRange(fn func(lo, hi rune))

func (*RangeMatch) MatchRune

func (m *RangeMatch) MatchRune(ch rune) bool

func (*RangeMatch) Not

func (m *RangeMatch) Not() RuneMatcher

type RuneMatcher

type RuneMatcher interface {
	MatchRune(rune) bool
	ForEachRange(func(lo, hi rune))
	Not() RuneMatcher
}
var (
	AnyValue  RuneMatcher = &AnyMatch{}
	NoneValue RuneMatcher = &NoneMatch{}
)

func Any

func Any() RuneMatcher

func BuildSet

func BuildSet(ranges []LoHi) RuneMatcher

func CompileRuneMatcher

func CompileRuneMatcher(input string) (RuneMatcher, error)

func Is

func Is(ch rune) RuneMatcher

func None

func None() RuneMatcher

func Range

func Range(lo, hi rune) RuneMatcher

func Set

func Set(matchers ...RuneMatcher) RuneMatcher

type Segment

type Segment struct {
	Type      SegmentType
	Literal   ExplodedString
	Matcher   RuneMatcher
	PatternP  uint
	PatternQ  uint
	MinLength uint
	MaxLength uint
}

type SegmentType

type SegmentType byte
const (
	LiteralSegment SegmentType = iota
	RuneMatchSegment
	QuestionSegment
	StarSegment
	DoubleStarSegment
	DoubleStarSlashSegment
)

func (SegmentType) GoString

func (x SegmentType) GoString() string

func (SegmentType) String

func (x SegmentType) String() string

type SetMatch

type SetMatch struct {
	Dense0 uint64
	Dense1 uint64
	Ranges SortedLoHi
}

func (*SetMatch) ForEachRange

func (m *SetMatch) ForEachRange(fn func(lo, hi rune))

func (*SetMatch) MatchRune

func (m *SetMatch) MatchRune(ch rune) bool

func (*SetMatch) Not

func (m *SetMatch) Not() RuneMatcher

type SortedLoHi

type SortedLoHi []LoHi

func (SortedLoHi) Len

func (x SortedLoHi) Len() int

func (SortedLoHi) Less

func (x SortedLoHi) Less(i, j int) bool

func (SortedLoHi) Swap

func (x SortedLoHi) Swap(i, j int)

Jump to

Keyboard shortcuts

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