prefixcomp

package
v0.0.8 Latest Latest
Warning

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

Go to latest
Published: Jan 15, 2024 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TokenEOF = iota
	TokenWord
	TokenOr
	TokenInteger
	TokenLeftBracket
	TokenRightBracket
	TokenColon
	TokenAll
)

Token types

Variables

This section is empty.

Functions

This section is empty.

Types

type Parser

type Parser struct {
	// contains filtered or unexported fields
}

Parser represents a parser.

func NewParser

func NewParser(tokens []Token) *Parser

NewParser creates a new parser.

func (*Parser) Parse

func (p *Parser) Parse() (*PrimaryFilterAST, error)

Parse parses the tokens into an AST.

type PrimaryFilterAST

type PrimaryFilterAST struct {
	// When All is true, it represents the '*' and it means ignore the Words entirely.
	All   bool
	Words []string
	Slice *slicecomp.Slice
}

PrimaryFilterAST represents the primary filter syntax.

func ParsePrimaryFilter

func ParsePrimaryFilter(input string) (*PrimaryFilterAST, error)

func (*PrimaryFilterAST) Count

func (p *PrimaryFilterAST) Count() int

func (*PrimaryFilterAST) IsAll

func (p *PrimaryFilterAST) IsAll() bool

func (*PrimaryFilterAST) PrefixAt

func (p *PrimaryFilterAST) PrefixAt(idx int) string

func (*PrimaryFilterAST) Query added in v0.0.8

func (p *PrimaryFilterAST) Query() string

func (*PrimaryFilterAST) String

func (p *PrimaryFilterAST) String() string

type Token

type Token struct {
	Type  int
	Value string
}

Token represents a lexical token.

func Tokenize

func Tokenize(input string) ([]Token, error)

type Tokenizer

type Tokenizer struct {
	// contains filtered or unexported fields
}

Tokenizer holds the state of the scanner.

func NewTokenizer

func NewTokenizer(input string) *Tokenizer

NewTokenizer returns a new instance of Tokenizer.

func (*Tokenizer) Next

func (t *Tokenizer) Next() Token

Next returns the next token from the input.

Jump to

Keyboard shortcuts

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