Documentation ¶
Index ¶
- type DFA
- func (m *DFA) GetStart() string
- func (m *DFA) GetState(name string) *State
- func (m *DFA) GetSymbols() []string
- func (m *DFA) Index()
- func (m *DFA) InspectStates(from, to string) []string
- func (m *DFA) InspectSymbols(symbol string) []*Edge
- func (m *DFA) Run(tokens []string) ([]string, bool)
- func (m *DFA) SetStart(state string)
- func (m *DFA) SetState(state *State)
- func (m *DFA) SetStates(states []*State)
- func (m *DFA) StateExists(name string) bool
- func (m *DFA) Step(state, symbol string) (string, bool, error)
- type Edge
- type State
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type DFA ¶
type DFA struct { Name string // States holds the state name as well as the state structure States map[string]*State // StateLookup holds key: symbol->symbol and all the states that // are in between of this symbol->state->symbol constellation. StateLookup map[string][]string // EdgeLookup holds key: symbol and as value all state pairs that // are connected by this symbol. EdgeLookup map[string][]*Edge Indexed bool Start string }
DFA holds everything that is needed in order to execute the automaton.
func (*DFA) GetSymbols ¶ added in v0.1.2
GetSymbols returns distinct symbols used in this DFA
func (*DFA) Index ¶
func (m *DFA) Index()
Index indexes all symbol to symbol transitions with the states that are in between. And also indexes a symbol with all the state pairs where it is in between.
func (*DFA) InspectStates ¶
InspectStates returns (if indexed) all states that have a connection from a symbol to a symbol. It answers the questions which state is in between these two symbols.
func (*DFA) InspectSymbols ¶
InspectSymbols returns (if indexed) all states that have a connection from a symbol to a symbol. It answers the questions which state is in between these two symbols.
func (*DFA) Run ¶
Run runs the DFA from the starting point with the given events and returns the states that the events have taken
func (*DFA) StateExists ¶
StateExists tests if the state exists
type State ¶
type State struct { // Name represents the name of the state Name string // Transitions represents the transitions of the state. // The map is structured map[Symbol]State Transitions map[string]string Final bool }
func (*State) AddTransition ¶
AddTransitions adds a symbol that leads to a state - meaning a transition
func (*State) AddTransitions ¶
AddTransitions adds a bulk of symbols to the state that all end up in the same state
func (*State) GetTransitions ¶ added in v0.1.3
GetTransitions returns the symbols that would lead to a transition