box

package
v0.0.0-...-65d4b07 Latest Latest
Warning

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

Go to latest
Published: Feb 9, 2025 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	OpOr            = ','
	OpAnd           = ' '
	OpGroupOpen     = '['
	OpGroupClose    = ']'
	OpNegation      = '^'
	OpExact         = '='
	OpNewline       = '\n'
	OpSigilLatest   = ':'
	OpSigilHistory  = '+'
	OpSigilExternal = '.'
	OpSigilHidden   = '?'
	OpPathSeparator = '/'
	OpType          = '!'
	OpVirtual       = '%'
	OpBlob          = '@'
)
View Source
const (
	SeqTypeUnknown    = SeqType(iota)
	SeqTypeIdentifier // one/uno, tag, !type, /browser/bookmark-1, @abcd
	SeqTypeField      // url=blah blob=hello contents="wow" contents="wow with\" quote"
)
View Source
const (
	TokenTypeIncomplete = TokenType(iota)
	TokenTypeOperator   // " =,.:+?^[]"
	TokenTypeIdentifier // ["one", "uno", "tag", "one", "type", "/browser/bookmark-1", "@sha"...]
	TokenTypeLiteral    // ["\"some text\"", "\"some text \\\" with escape\""]
)

Variables

This section is empty.

Functions

func IsOperator

func IsOperator(r rune, dotAllowed bool) (ok bool)

func IsSequenceOperator

func IsSequenceOperator(r rune) (ok bool)

func TokenMatcherOr

func TokenMatcherOr(tm ...TokenMatcher) tokenMatcherOr

Types

type Scanner

type Scanner struct {
	io.RuneScanner
	// contains filtered or unexported fields
}

func (*Scanner) CanScan

func (ts *Scanner) CanScan() (ok bool)

func (*Scanner) ConsumeSpacesOrErrorOnFalse

func (ts *Scanner) ConsumeSpacesOrErrorOnFalse() (ok bool)

Consumes any spaces currently available in the underlying RuneReader. If this returns false, it means that a read error has occurred, not that no spaces were consumed.

func (*Scanner) Error

func (scanner *Scanner) Error() error

func (*Scanner) GetSeq

func (scanner *Scanner) GetSeq() Seq

Valid only until the next call to any scan method. To keep the sequence, make a clone of it by calling Seq.Clone()

func (*Scanner) N

func (scanner *Scanner) N() int64

func (*Scanner) ReadRune

func (ts *Scanner) ReadRune() (r rune, n int, err error)

func (*Scanner) Reset

func (ts *Scanner) Reset(r io.RuneScanner)

func (*Scanner) Scan

func (ts *Scanner) Scan() (ok bool)

func (*Scanner) ScanDotAllowedInIdentifiers

func (ts *Scanner) ScanDotAllowedInIdentifiers() (ok bool)

func (*Scanner) ScanSkipSpace

func (ts *Scanner) ScanSkipSpace() (ok bool)

func (*Scanner) UnreadRune

func (ts *Scanner) UnreadRune() (err error)

TODO add support for unscan

func (*Scanner) Unscan

func (ts *Scanner) Unscan()

type Seq

type Seq []Token

func (*Seq) Add

func (seq *Seq) Add(tokenType TokenType, contents []byte)

func (*Seq) AddToken

func (seq *Seq) AddToken(token Token)

func (Seq) At

func (seq Seq) At(idx int) Token

func (Seq) Clone

func (src Seq) Clone() (dst Seq)

func (Seq) EqualsSeq

func (a Seq) EqualsSeq(b Seq) bool

func (Seq) GetTokenTypes

func (seq Seq) GetTokenTypes() TokenTypes

func (Seq) Len

func (seq Seq) Len() int

func (Seq) MatchAll

func (seq Seq) MatchAll(tokens ...TokenMatcher) bool

func (Seq) MatchEnd

func (seq Seq) MatchEnd(tokens ...TokenMatcher) (ok bool, left, right Seq)

func (Seq) PartitionFavoringLeft

func (seq Seq) PartitionFavoringLeft(
	m TokenMatcher,
) (ok bool, left, right Seq, partition Token)

func (Seq) PartitionFavoringRight

func (seq Seq) PartitionFavoringRight(
	m TokenMatcher,
) (ok bool, left, right Seq, partition Token)

func (*Seq) Reset

func (seq *Seq) Reset()

func (Seq) String

func (seq Seq) String() string

func (Seq) StringDebug

func (seq Seq) StringDebug() string

type SeqRuneScanner

type SeqRuneScanner struct {
	Seq
	// contains filtered or unexported fields
}

func (*SeqRuneScanner) IsFull

func (scanner *SeqRuneScanner) IsFull() bool

func (*SeqRuneScanner) ReadRune

func (scanner *SeqRuneScanner) ReadRune() (r rune, size int, err error)

func (*SeqRuneScanner) Reset

func (scanner *SeqRuneScanner) Reset()

func (*SeqRuneScanner) UnreadRune

func (scanner *SeqRuneScanner) UnreadRune() (err error)

type SeqType

type SeqType int

func (SeqType) String

func (i SeqType) String() string

type Token

type Token struct {
	Contents []byte
	TokenType
}

func (Token) Clone

func (src Token) Clone() (dst Token)

func (Token) String

func (token Token) String() string

type TokenMatcher

type TokenMatcher interface {
	Match(Token) bool
}

type TokenMatcherOp

type TokenMatcherOp byte

func (TokenMatcherOp) Match

func (tokenMatcher TokenMatcherOp) Match(token Token) bool

type TokenType

type TokenType int

func (TokenType) Match

func (expected TokenType) Match(actual Token) bool

func (TokenType) String

func (i TokenType) String() string

type TokenTypes

type TokenTypes []TokenType

func (TokenTypes) Equals

func (actual TokenTypes) Equals(expected ...TokenType) bool

Jump to

Keyboard shortcuts

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