Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var Epsilon = epsilon{}
Epsilon is the ε (empty string) input.
Functions ¶
This section is empty.
Types ¶
type State ¶
type State struct {
// ID of the state.
// It is assigned by the NFA and should be read-only.
ID uint32
// Transitions of the state.
// Transitions should only be added using NFA.AddTransitions.
Transitions stablemap.Map[any, *array.Array[*State]]
// Accept indicates that the state machine should accept/recognize the input.
// You set this yourself.
Accept bool
// NonGreedy, in combination with Accept, indicate that the state machine
// should accept the current string without consuming additional input.
NonGreedy bool
// Data is some user-data associated with this state.
// Your set this yourself (or don't, I don't care).
Data any
}
State is a state in a NFA. NFA represents a Nondeterministic Finite Automaton. https://en.wikipedia.org/wiki/Nondeterministic_finite_automaton The NFA is state machine where: - A state is allowed to have multiple transitions for the same input. - The input ε (empty string) is allowed. State should only created using StateFactory.
func (*State) AddTransition ¶
AddTransition adds a transition between two states on a given input. The input can be any comparable data, including Epsilon.
type StateFactory ¶
type StateFactory struct {
// contains filtered or unexported fields
}
func NewStateFactory ¶
func NewStateFactory() *StateFactory
func (*StateFactory) NewState ¶
func (n *StateFactory) NewState() *State
NewState creates a new state in the NFA.
Click to show internal directories.
Click to hide internal directories.