Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CompactedTrieBuilder ¶ added in v0.2.0
type CompactedTrieBuilder struct {
// contains filtered or unexported fields
}
Builder for compacted tries.
func NewCompactedTrieBuilder ¶ added in v0.2.0
func NewCompactedTrieBuilder(opts ...CompactedTrieBuilderOption) *CompactedTrieBuilder
NewCompactedTrieBuilder creates a new builder that builds a compacted trie.
func (*CompactedTrieBuilder) Add ¶ added in v0.2.0
func (b *CompactedTrieBuilder) Add(wf, v string) error
Add adds a key-value pair to the builder. The resulting automaton then associates key wf with value v.
func (*CompactedTrieBuilder) AddToAlphabet ¶ added in v0.2.0
func (b *CompactedTrieBuilder) AddToAlphabet(chars string)
AddToAlphabet adds all characters (bytes) in str to the builder's internal alphabet.
All characters of keys added to the builder must be added to the alphabet before being added to the builder. The zero character \0 has special meaning and cannot be added to the builder's alphabet.
func (*CompactedTrieBuilder) Build ¶ added in v0.2.0
func (b *CompactedTrieBuilder) Build() (*FSA, error)
Build finishes the building process and returns the CFSA.
func (*CompactedTrieBuilder) Statistics ¶ added in v0.2.0
func (b *CompactedTrieBuilder) Statistics() Statistics
Statistics returns a Statistics struct.
type CompactedTrieBuilderOption ¶ added in v0.2.0
type CompactedTrieBuilderOption func(*CompactedTrieBuilder)
func CompactedTrieWithSeperator ¶ added in v0.2.0
func CompactedTrieWithSeperator(enable bool) CompactedTrieBuilderOption
Enables special handling of ` ` characters in the input strings. If this option is enabled and such a seperator is encountered in an input string, the resulting automaton accepts one or more sequences of ` ` within the accepted strings.
type DFANodeBuilder ¶
type DFANodeBuilder interface { NewNode(string) DFAState // Return a new DFANode instance. LinkNodes(DFAState, byte, DFAState) // Link the two nodes together with a specific byte. }
DFANodeBuilder is used to build and link DFANodes by fsa.Determinize.
type DFAState ¶ added in v0.4.0
type DFAState interface { Final() (string, bool) // Return if the state is final and additional data if the state is final. Target(c byte) DFAState // Target for the given transition }
DFAState represents a state in a DFA. They can be used to construct a FSA instance.
Final states should return their rewrite data in the implementation of the Final() method. If a node has no target transition, nil should be returned.
func Determinize ¶
func Determinize(initial NDFAState, b DFANodeBuilder) DFAState
Determinize determinizes a non-deterministic FSA.
type FSA ¶
type FSA struct {
// contains filtered or unexported fields
}
func NewFSAFromNodes ¶
NewFSAFromNodes creates a new fsa from the given initial state. The function panics if the nodes do not represent a dfa.
func (*FSA) Delta ¶
Delta executes a transition from s using c and returns the target state. If no transition can be executed, 0 is returned.
type NDFAState ¶ added in v0.4.0
type NDFAState interface { Final() (string, bool) // Return if the state is final and additional final data if the state is final. Targets(c byte) []NDFAState // Targets for the given transitions. ID() uint64 // The unique id for the node. }
NDFAState represents a state in a NDFA. They can be used to construct an deterministic automaton and from there be converted into a FSA instance.
Final states should return their rewrite data in the implementation of the Final() method. If a node has no target transition, nil should be returned.