|
TuringSim
C++ framework to simulate abstract computing models
|
3 #include <utils/compare.h>
4 #include <transition/FSM/finiteStateMachineTransition.h>
27 static_assert(std::is_same_v<StateType, StateType_>);
29 static_assert(std::is_same_v<ApplyHelperType, std::monostate>);
67 if(state == preState && letter && *letter == preLetter) {
68 return {std::monostate{}};
73 #pragma clang diagnostic push
74 #pragma clang diagnostic ignored "-Wunused-parameter"
86 #pragma clang diagnostic pop
107 if(preState < other.preState) {
110 if(preState > other.preState) {
113 if(preLetter < other.preLetter) {
116 if(preLetter > other.preLetter) {
119 if(postState < other.postState) {
122 if(postState > other.postState) {
151 template<
typename CharT,
typename Traits = std::
char_traits<CharT>>
153 return os <<
"(" << transition.preState <<
", " << transition.preLetter <<
") -> " << transition.postState;
Class to represent a word memory, as used by a FSA.
virtual ~SimpleFiniteStateMachineTransition() override=default
The default virtual destructor.
int compare(const SimpleFiniteStateMachineTransition &other) const
Compare two transitions. OCaml style, waiting for <=>. Strong ordering.
StorageType_ StorageType
The type of storage.
friend std::basic_ostream< CharT, Traits > & operator<<(std::basic_ostream< CharT, Traits > &os, const SimpleFiniteStateMachineTransition &transition)
Debug printer for transitions.
SymbolType_ SymbolType
The type of symbols on the tape.
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...
bool operator<(const SimpleFiniteStateMachineTransition &other) const
Less than operator. Strong order.
Transition of finite state machines, i.e. transition on a word, without epsilon-transitions.
const SymbolType & getPreLetter() const noexcept
Get the pre-letter for optimized containers.
ApplyHelperType_ ApplyHelperType
The type of apply helpers.
SimpleFiniteStateMachineTransition(StateType preState, SymbolType preLetter, StateType postState)
Builds a SimpleFiniteStateMachineTransition from its elements.
SimpleFiniteStateMachineTransition(const SimpleFiniteStateMachineTransition &)=default
The default copy constructor.
const StateType & getPreState() const noexcept
Get the pre-state for optimized containers.
virtual StateType apply(const StateType &state, StorageType &storage, ApplyHelperType &&helper, bool &running) const override final
Eat the current letter and return the new state.
SimpleFiniteStateMachineTransition & operator=(SimpleFiniteStateMachineTransition &&)=default
The default move assignment operator.
StateType_ StateType
The type of states.
Transitions for finite-state machines.
bool operator==(const SimpleFiniteStateMachineTransition &other) const
Equality operator.
Transition of finite state machines, i.e. transition on a word.
SimpleFiniteStateMachineTransition & operator=(const SimpleFiniteStateMachineTransition &)=default
The default copy assignment operator.
SymbolType_ SymbolType
The type of symbols on the tape.
SimpleFiniteStateMachineTransition(SimpleFiniteStateMachineTransition &&)=default
The default move constructor.
StateType_ StateType
The type of states.