fsm

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Aug 8, 2020 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type State

type State struct {
	Terminal    bool
	Transitions StateTransitions
}

State is the basic building block in the FSM. A State can be final or not, and has transitions to other states

func NewState

func NewState() *State

NewState create a new state

func (*State) Parse

func (s *State) Parse(args []string) error

Parse tries to navigate into the FSM according to the provided args

func (*State) Prepare

func (s *State) Prepare()

Prepare simplifies the FSM and sorts the transitions according to their priorities

func (*State) T

func (s *State) T(matcher matcher.Matcher, next *State) *State

T creates a transition between 2 states

type StateTransitions

type StateTransitions []*Transition

StateTransitions is a sortable slice of transitions according to their priorities

func (StateTransitions) Len

func (t StateTransitions) Len() int

func (StateTransitions) Less

func (t StateTransitions) Less(i, j int) bool

func (StateTransitions) Swap

func (t StateTransitions) Swap(i, j int)

type Transition

type Transition struct {
	Matcher matcher.Matcher
	Next    *State
}

Transition links 2 states. If a transition's matcher matches, the next state can be reached

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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