Documentation
¶
Index ¶
- type Lexer
- func (l *Lexer[T, V]) FirstMatch(input iter.Seq[T]) (V, int, bool)
- func (l *Lexer[T, V]) FirstMatchSlice(input []T) (V, int, bool)
- func (l *Lexer[T, V]) InsertIter(pattern iter.Seq[T], value V)
- func (l *Lexer[T, V]) InsertSlice(pattern []T, value V)
- func (l *Lexer[T, V]) LongestMatch(input iter.Seq[T]) (V, int, bool)
- func (l *Lexer[T, V]) LongestMatchSlice(input []T) (V, int, bool)
- func (l *Lexer[T, V]) Match(input iter.Seq[T]) (V, bool)
- func (l *Lexer[T, V]) MatchSlice(input []T) (V, bool)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Lexer ¶
type Lexer[T comparable, V any] struct { // contains filtered or unexported fields }
Lexer is a simple trie-based lexer
func (*Lexer[T, V]) FirstMatch ¶
FirstMatch returns the first (shortest) pattern that matches a prefix of the input. Returns the value, number of elements consumed, and whether a match was found.
func (*Lexer[T, V]) FirstMatchSlice ¶
FirstMatchSlice returns the first (shortest) pattern that matches a prefix of the input.
func (*Lexer[T, V]) InsertIter ¶
InsertIter inserts a pattern into the trie with the associated value.
func (*Lexer[T, V]) InsertSlice ¶
func (l *Lexer[T, V]) InsertSlice(pattern []T, value V)
InsertSlice inserts a slice pattern into the trie with the associated value.
func (*Lexer[T, V]) LongestMatch ¶
LongestMatch returns the longest pattern that matches a prefix of the input. Returns the value, number of elements consumed, and whether a match was found.
func (*Lexer[T, V]) LongestMatchSlice ¶
LongestMatchSlice returns the longest pattern that matches a prefix of the input.
func (*Lexer[T, V]) MatchSlice ¶
MatchSlice returns the value if the entire input exactly matches a pattern.