|
TuringSim
C++ framework to simulate abstract computing models
|
3 #include <transition/FSM/finiteStateMachineTransition.h>
26 static_assert(std::is_same_v<StateType, StateType_>);
28 static_assert(std::is_same_v<ApplyHelperType, std::monostate>);
39 const std::optional<SymbolType>& preLetter,
54 preLetter(std::nullopt),
78 if(state == preState && (!preLetter || *letter == preLetter)) {
79 return {std::monostate{}};
84 #pragma clang diagnostic push
85 #pragma clang diagnostic ignored "-Wunused-parameter"
99 #pragma clang diagnostic pop
120 if(preState < other.preState) {
123 if(preState > other.preState) {
126 if(preLetter < other.preLetter) {
129 if(preLetter > other.preLetter) {
132 if(postState < other.postState) {
135 if(postState > other.postState) {
164 template<
typename CharT,
typename Traits = std::
char_traits<CharT>>
166 if(transition.preLetter) {
167 return os <<
"(" << transition.preState <<
", " << *transition.preLetter <<
") -> "
168 << transition.postState;
170 return os << transition.preState <<
" -> " << transition.postState;
176 std::optional<SymbolType> preLetter;
MaybeEpsilonFiniteStateMachineTransition(const MaybeEpsilonFiniteStateMachineTransition &)=default
The default copy constructor.
Class to represent a word memory, as used by a FSA.
StorageType_ StorageType
The type of storage.
SymbolType_ SymbolType
The type of symbols on the tape.
friend std::basic_ostream< CharT, Traits > & operator<<(std::basic_ostream< CharT, Traits > &os, const MaybeEpsilonFiniteStateMachineTransition &transition)
Debug printer for transitions.
MaybeEpsilonFiniteStateMachineTransition(const StateType &preState, const StateType &postState)
Builds an epsilon transition.
bool operator<(const MaybeEpsilonFiniteStateMachineTransition &other) const
Less than operator. Strong order.
StateType_ StateType
The type of states.
ApplyHelperType_ ApplyHelperType
The type of apply helpers.
MaybeEpsilonFiniteStateMachineTransition & operator=(const MaybeEpsilonFiniteStateMachineTransition &)=default
The default copy assignment operator.
bool operator==(const MaybeEpsilonFiniteStateMachineTransition &other) const
Equality operator.
Transition of finite state machines, i.e. transition on a word, without epsilon-transitions.
virtual StateType apply(const StateType &state, StorageType &storage, ApplyHelperType &&helper, bool &running) const override final
Eat the current letter and return the new state.
int compare(const MaybeEpsilonFiniteStateMachineTransition &other) const
Compare two transitions. OCaml style, waiting for <=>. Strong ordering.
StateType_ StateType
The type of states.
Transitions for finite-state machines.
MaybeEpsilonFiniteStateMachineTransition(MaybeEpsilonFiniteStateMachineTransition &&)=default
The default move constructor.
MaybeEpsilonFiniteStateMachineTransition & operator=(MaybeEpsilonFiniteStateMachineTransition &&)=default
The default move assignment operator.
Transition of finite state machines, i.e. transition on a word.
const StateType & getPreState() const noexcept
Get the pre-state for optimized containers.
const std::optional< SymbolType > & getPreLetter() const noexcept
Get the pre-letter for optimized containers.
virtual ~MaybeEpsilonFiniteStateMachineTransition() override=default
The default virtual destructor.
virtual std::optional< ApplyHelperType > matchFromCurrentLetter(const StateType &state, const std::optional< SymbolType > &letter) const override final
Test whether the transition matches a configuration. Returned optional is empty iff the transition do...
MaybeEpsilonFiniteStateMachineTransition(const StateType &preState, const std::optional< SymbolType > &preLetter, const StateType &postState)
Builds a MaybeEpsilonFiniteStateMachineTransition from its elements.