![]() |
Elementa v8.0.0
Minimalistic library for any C++ application (C++11 and up)
|
Base support for FSMs.

Classes | |
| class | elementa::adts::BaseFSM |
| Common functionality for any FSM. More... | |
| class | elementa::adts::FSM< Obs > |
| Base interface for FSMs with a given observation type. More... | |
| class | elementa::adts::BaseTextFSM |
| Shortcut for FSMs that work with chars. More... | |
| class | elementa::adts::CharFSM |
| A FSM that recognizes only a given character. More... | |
| class | elementa::adts::SeparatorsFSM |
| A FSM that recognizes sequences of separator characters. More... | |
| class | elementa::adts::IdentifierFSM |
| A FSM that recognizes a standard identifier in text. More... | |
| class | elementa::adts::KeywordFSM |
| A FSM that recognizes some fixed, short (shorter than 255 chars) string. More... | |
| class | elementa::adts::CommentsFSM |
| A FSM that recognizes uni- or multi-line comments. More... | |
| class | elementa::adts::IntegerTextFSM |
| A FSM that recognizes an integer number from text. More... | |
| class | elementa::adts::NumberTextFSM |
| A FSM that recognizes a real or integer number from a decimal text. More... | |
| class elementa::adts::BaseFSM |
Common functionality for any FSM.
A FSM is formally a directed graph where there is an initial ("reset") edge from no specified vertex, and some ending vertices. Each edge recognizes some observation(s), and may lead to the same vertex or to another. Even while being in an ending vertex, there may be edges that continue recognizing observations, or that lead to a non-ending vertex.

Public Types | |
Types, consts, etc. | |
| using | Num = size_t |
| To represent a number of FSMs. More... | |
Public Member Functions | |
Constructors | |
| virtual | ~BaseFSM (void)=default |
| Just for polymorphic deletions. | |
Methods | |
| virtual bool | atEnd (void) const =0 |
| Must return TRUE if the current state is an absorbing/final one. More... | |
| virtual void | reset (void)=0 |
| Must set the FSM to a preliminary state when it has not been fed yet. More... | |
| void | resetCheck (void) |
| Reset checking the post-condition that the FSM does not go to an ending. More... | |
| virtual std::string | to_string (void) const |
| Return a text representation of the FSM. Can be overriden. More... | |
| using elementa::adts::BaseFSM::Num = size_t |
|
pure virtual |
Must return TRUE if the current state is an absorbing/final one.
After a reset, the fsm must not be in an ending state.
Implemented in elementa::adts::CharFSM, elementa::adts::SeparatorsFSM, elementa::adts::IdentifierFSM, elementa::adts::KeywordFSM, elementa::adts::CommentsFSM, elementa::adts::IntegerTextFSM, and elementa::adts::NumberTextFSM.
Referenced by resetCheck(), and to_string().
|
pure virtual |
Must set the FSM to a preliminary state when it has not been fed yet.
Therefore, after this method, atEnd() must return FALSE. This method should be called from the constructors of derived FSMs to prepare them for reading observations.
Implemented in elementa::adts::CharFSM, elementa::adts::SeparatorsFSM, elementa::adts::IdentifierFSM, elementa::adts::KeywordFSM, elementa::adts::CommentsFSM, elementa::adts::IntegerTextFSM, and elementa::adts::NumberTextFSM.
Referenced by resetCheck().
|
inline |
Reset checking the post-condition that the FSM does not go to an ending.
Definition at line 107 of file fsms.h.
References atEnd(), ELE_CODE_INVSTATE, reset(), and to_string().
|
inlinevirtual |
Return a text representation of the FSM. Can be overriden.
Reimplemented in elementa::adts::CharFSM, elementa::adts::SeparatorsFSM, elementa::adts::IdentifierFSM, elementa::adts::KeywordFSM, elementa::adts::CommentsFSM, elementa::adts::IntegerTextFSM, and elementa::adts::NumberTextFSM.
Definition at line 114 of file fsms.h.
References atEnd(), elementa::base::kYesNoCString(), and elementa::base::to_number().
Referenced by resetCheck(), elementa::adts::CharFSM::to_string(), elementa::adts::SeparatorsFSM::to_string(), elementa::adts::IdentifierFSM::to_string(), elementa::adts::KeywordFSM::to_string(), elementa::adts::CommentsFSM::to_string(), elementa::adts::IntegerTextFSM::to_string(), and elementa::adts::NumberTextFSM::to_string().
| class elementa::adts::FSM |
Base interface for FSMs with a given observation type.
| Obs | is the type of the observations that the machine reads. It must be a simple type. |


Public Types | |
| using | Ptr = std::shared_ptr< FSM > |
| Pointer to a FSM that consumes observations of type Obs. More... | |
Types, consts, etc. | |
| using | Num = size_t |
| To represent a number of FSMs. More... | |
Public Member Functions | |
| virtual bool | consume (Obs o)=0 |
| Must consume the given observation and change state if necessary. More... | |
Methods | |
| virtual bool | atEnd (void) const =0 |
| Must return TRUE if the current state is an absorbing/final one. More... | |
| virtual void | reset (void)=0 |
| Must set the FSM to a preliminary state when it has not been fed yet. More... | |
| void | resetCheck (void) |
| Reset checking the post-condition that the FSM does not go to an ending. More... | |
| virtual std::string | to_string (void) const |
| Return a text representation of the FSM. Can be overriden. More... | |
| using elementa::adts::FSM< Obs >::Ptr = std::shared_ptr<FSM> |
|
inherited |
|
pure virtual |
Must consume the given observation and change state if necessary.
Must return TRUE if the observation can be consumed in the current state, either changing state or not. Must do nothing and return FALSE if it cannot consume that observation (it may change to end state if it is not there already).
|
pure virtualinherited |
Must return TRUE if the current state is an absorbing/final one.
After a reset, the fsm must not be in an ending state.
Implemented in elementa::adts::CharFSM, elementa::adts::SeparatorsFSM, elementa::adts::IdentifierFSM, elementa::adts::KeywordFSM, elementa::adts::CommentsFSM, elementa::adts::IntegerTextFSM, and elementa::adts::NumberTextFSM.
Referenced by elementa::adts::BaseFSM::resetCheck(), and elementa::adts::BaseFSM::to_string().
|
pure virtualinherited |
Must set the FSM to a preliminary state when it has not been fed yet.
Therefore, after this method, atEnd() must return FALSE. This method should be called from the constructors of derived FSMs to prepare them for reading observations.
Implemented in elementa::adts::CharFSM, elementa::adts::SeparatorsFSM, elementa::adts::IdentifierFSM, elementa::adts::KeywordFSM, elementa::adts::CommentsFSM, elementa::adts::IntegerTextFSM, and elementa::adts::NumberTextFSM.
Referenced by elementa::adts::BaseFSM::resetCheck().
|
inlineinherited |
Reset checking the post-condition that the FSM does not go to an ending.
Definition at line 107 of file fsms.h.
References elementa::adts::BaseFSM::atEnd(), ELE_CODE_INVSTATE, elementa::adts::BaseFSM::reset(), and elementa::adts::BaseFSM::to_string().
|
inlinevirtualinherited |
Return a text representation of the FSM. Can be overriden.
Reimplemented in elementa::adts::CharFSM, elementa::adts::SeparatorsFSM, elementa::adts::IdentifierFSM, elementa::adts::KeywordFSM, elementa::adts::CommentsFSM, elementa::adts::IntegerTextFSM, and elementa::adts::NumberTextFSM.
Definition at line 114 of file fsms.h.
References elementa::adts::BaseFSM::atEnd(), elementa::base::kYesNoCString(), and elementa::base::to_number().
Referenced by elementa::adts::BaseFSM::resetCheck(), elementa::adts::CharFSM::to_string(), elementa::adts::SeparatorsFSM::to_string(), elementa::adts::IdentifierFSM::to_string(), elementa::adts::KeywordFSM::to_string(), elementa::adts::CommentsFSM::to_string(), elementa::adts::IntegerTextFSM::to_string(), and elementa::adts::NumberTextFSM::to_string().
| class elementa::adts::BaseTextFSM |


Public Types | |
| using | Ptr = std::shared_ptr< FSM > |
| Pointer to a FSM that consumes observations of type Obs. More... | |
Types, consts, etc. | |
| using | Num = size_t |
| To represent a number of FSMs. More... | |
Public Member Functions | |
| BaseTextFSM (bool casesensitive=true) | |
| Constructor. More... | |
| virtual bool | consume (Obs o)=0 |
| Must consume the given observation and change state if necessary. More... | |
Methods | |
| virtual bool | atEnd (void) const =0 |
| Must return TRUE if the current state is an absorbing/final one. More... | |
| virtual void | reset (void)=0 |
| Must set the FSM to a preliminary state when it has not been fed yet. More... | |
| void | resetCheck (void) |
| Reset checking the post-condition that the FSM does not go to an ending. More... | |
| virtual std::string | to_string (void) const |
| Return a text representation of the FSM. Can be overriden. More... | |
Protected Member Functions | |
| char | caseChar (char c) |
|
inherited |
|
inherited |
|
inline |
|
inlineprotected |
|
pure virtualinherited |
Must consume the given observation and change state if necessary.
Must return TRUE if the observation can be consumed in the current state, either changing state or not. Must do nothing and return FALSE if it cannot consume that observation (it may change to end state if it is not there already).
|
pure virtualinherited |
Must return TRUE if the current state is an absorbing/final one.
After a reset, the fsm must not be in an ending state.
Implemented in elementa::adts::CharFSM, elementa::adts::SeparatorsFSM, elementa::adts::IdentifierFSM, elementa::adts::KeywordFSM, elementa::adts::CommentsFSM, elementa::adts::IntegerTextFSM, and elementa::adts::NumberTextFSM.
Referenced by elementa::adts::BaseFSM::resetCheck(), and elementa::adts::BaseFSM::to_string().
|
pure virtualinherited |
Must set the FSM to a preliminary state when it has not been fed yet.
Therefore, after this method, atEnd() must return FALSE. This method should be called from the constructors of derived FSMs to prepare them for reading observations.
Implemented in elementa::adts::CharFSM, elementa::adts::SeparatorsFSM, elementa::adts::IdentifierFSM, elementa::adts::KeywordFSM, elementa::adts::CommentsFSM, elementa::adts::IntegerTextFSM, and elementa::adts::NumberTextFSM.
Referenced by elementa::adts::BaseFSM::resetCheck().
|
inlineinherited |
Reset checking the post-condition that the FSM does not go to an ending.
Definition at line 107 of file fsms.h.
References elementa::adts::BaseFSM::atEnd(), ELE_CODE_INVSTATE, elementa::adts::BaseFSM::reset(), and elementa::adts::BaseFSM::to_string().
|
inlinevirtualinherited |
Return a text representation of the FSM. Can be overriden.
Reimplemented in elementa::adts::CharFSM, elementa::adts::SeparatorsFSM, elementa::adts::IdentifierFSM, elementa::adts::KeywordFSM, elementa::adts::CommentsFSM, elementa::adts::IntegerTextFSM, and elementa::adts::NumberTextFSM.
Definition at line 114 of file fsms.h.
References elementa::adts::BaseFSM::atEnd(), elementa::base::kYesNoCString(), and elementa::base::to_number().
Referenced by elementa::adts::BaseFSM::resetCheck(), elementa::adts::CharFSM::to_string(), elementa::adts::SeparatorsFSM::to_string(), elementa::adts::IdentifierFSM::to_string(), elementa::adts::KeywordFSM::to_string(), elementa::adts::CommentsFSM::to_string(), elementa::adts::IntegerTextFSM::to_string(), and elementa::adts::NumberTextFSM::to_string().
| class elementa::adts::CharFSM |


Public Types | |
| using | Ptr = std::shared_ptr< FSM > |
| Pointer to a FSM that consumes observations of type Obs. More... | |
Types, consts, etc. | |
| using | Num = size_t |
| To represent a number of FSMs. More... | |
Public Member Functions | |
| CharFSM (char c) | |
| Constructor. More... | |
| void | reset (void) |
| Must set the FSM to a preliminary state when it has not been fed yet. More... | |
| bool | atEnd (void) const |
| Must return TRUE if the current state is an absorbing/final one. More... | |
| bool | consume (char o) |
| char | character (void) const noexcept |
| Return the character this fsm is able to recognize. More... | |
| std::string | to_string (void) const |
| Return a text representation of the FSM. Can be overriden. More... | |
| virtual bool | consume (Obs o)=0 |
| Must consume the given observation and change state if necessary. More... | |
Methods | |
| void | resetCheck (void) |
| Reset checking the post-condition that the FSM does not go to an ending. More... | |
Protected Member Functions | |
| char | caseChar (char c) |
|
inherited |
|
inherited |
|
inline |
|
inlinevirtual |
Must set the FSM to a preliminary state when it has not been fed yet.
Therefore, after this method, atEnd() must return FALSE. This method should be called from the constructors of derived FSMs to prepare them for reading observations.
Implements elementa::adts::BaseFSM.
Definition at line 200 of file fsms.h.
Referenced by CharFSM().
|
inlinevirtual |
Must return TRUE if the current state is an absorbing/final one.
After a reset, the fsm must not be in an ending state.
Implements elementa::adts::BaseFSM.
|
inlinenoexcept |
|
inlinevirtual |
Return a text representation of the FSM. Can be overriden.
Reimplemented from elementa::adts::BaseFSM.
Definition at line 209 of file fsms.h.
References elementa::adts::BaseFSM::to_string().
|
inlineprotectedinherited |
|
pure virtualinherited |
Must consume the given observation and change state if necessary.
Must return TRUE if the observation can be consumed in the current state, either changing state or not. Must do nothing and return FALSE if it cannot consume that observation (it may change to end state if it is not there already).
|
inlineinherited |
Reset checking the post-condition that the FSM does not go to an ending.
Definition at line 107 of file fsms.h.
References elementa::adts::BaseFSM::atEnd(), ELE_CODE_INVSTATE, elementa::adts::BaseFSM::reset(), and elementa::adts::BaseFSM::to_string().
| class elementa::adts::SeparatorsFSM |
A FSM that recognizes sequences of separator characters.
This FSM consumes observations while they correspond to separators. Reaches end states whenever a separator is consumed.


Public Types | |
| using | Ptr = std::shared_ptr< FSM > |
| Pointer to a FSM that consumes observations of type Obs. More... | |
Types, consts, etc. | |
| using | Num = size_t |
| To represent a number of FSMs. More... | |
Public Member Functions | |
| SeparatorsFSM (const std::string &seps="\n\t \f\r\v\x00") | |
| Constructor. More... | |
| void | reset (void) |
| Must set the FSM to a preliminary state when it has not been fed yet. More... | |
| bool | atEnd (void) const |
| Must return TRUE if the current state is an absorbing/final one. More... | |
| bool | consume (char o) |
| const std::string & | separators (void) const noexcept |
| Return a reference to the separators this fsm is able to recognize. More... | |
| std::string | to_string (void) const |
| Return a text representation of the FSM. Can be overriden. More... | |
| virtual bool | consume (Obs o)=0 |
| Must consume the given observation and change state if necessary. More... | |
Methods | |
| void | resetCheck (void) |
| Reset checking the post-condition that the FSM does not go to an ending. More... | |
Protected Member Functions | |
| char | caseChar (char c) |
|
inherited |
|
inherited |
|
inline |
|
inlinevirtual |
Must set the FSM to a preliminary state when it has not been fed yet.
Therefore, after this method, atEnd() must return FALSE. This method should be called from the constructors of derived FSMs to prepare them for reading observations.
Implements elementa::adts::BaseFSM.
Definition at line 239 of file fsms.h.
Referenced by SeparatorsFSM().
|
inlinevirtual |
Must return TRUE if the current state is an absorbing/final one.
After a reset, the fsm must not be in an ending state.
Implements elementa::adts::BaseFSM.
|
inlinenoexcept |
|
inlinevirtual |
Return a text representation of the FSM. Can be overriden.
Reimplemented from elementa::adts::BaseFSM.
Definition at line 251 of file fsms.h.
References elementa::adts::BaseFSM::to_string().
|
inlineprotectedinherited |
|
pure virtualinherited |
Must consume the given observation and change state if necessary.
Must return TRUE if the observation can be consumed in the current state, either changing state or not. Must do nothing and return FALSE if it cannot consume that observation (it may change to end state if it is not there already).
|
inlineinherited |
Reset checking the post-condition that the FSM does not go to an ending.
Definition at line 107 of file fsms.h.
References elementa::adts::BaseFSM::atEnd(), ELE_CODE_INVSTATE, elementa::adts::BaseFSM::reset(), and elementa::adts::BaseFSM::to_string().
| class elementa::adts::IdentifierFSM |
A FSM that recognizes a standard identifier in text.
This FSM consumes observations while they correspond to the identifier. Reaches end states whenever the already consumed observations form a valid identifier. A standard identifier may being with a letter or an underscore, and follows with letters, digits or underscores.


Public Types | |
| using | Ptr = std::shared_ptr< FSM > |
| Pointer to a FSM that consumes observations of type Obs. More... | |
Types, consts, etc. | |
| using | Num = size_t |
| To represent a number of FSMs. More... | |
Public Member Functions | |
| IdentifierFSM (void) | |
| Constructor. */. More... | |
| bool | atEnd (void) const |
| Must return TRUE if the current state is an absorbing/final one. More... | |
| bool | consume (char o) |
| void | reset (void) |
| Must set the FSM to a preliminary state when it has not been fed yet. More... | |
| std::string | to_string (void) const |
| Return a text representation of the FSM. Can be overriden. More... | |
| virtual bool | consume (Obs o)=0 |
| Must consume the given observation and change state if necessary. More... | |
Methods | |
| void | resetCheck (void) |
| Reset checking the post-condition that the FSM does not go to an ending. More... | |
Protected Member Functions | |
| char | caseChar (char c) |
|
inherited |
|
inherited |
|
inline |
|
inlinevirtual |
Must return TRUE if the current state is an absorbing/final one.
After a reset, the fsm must not be in an ending state.
Implements elementa::adts::BaseFSM.
|
inlinevirtual |
Must set the FSM to a preliminary state when it has not been fed yet.
Therefore, after this method, atEnd() must return FALSE. This method should be called from the constructors of derived FSMs to prepare them for reading observations.
Implements elementa::adts::BaseFSM.
Definition at line 284 of file fsms.h.
Referenced by IdentifierFSM().
|
inlinevirtual |
Return a text representation of the FSM. Can be overriden.
Reimplemented from elementa::adts::BaseFSM.
Definition at line 286 of file fsms.h.
References elementa::adts::BaseFSM::to_string().
|
inlineprotectedinherited |
|
pure virtualinherited |
Must consume the given observation and change state if necessary.
Must return TRUE if the observation can be consumed in the current state, either changing state or not. Must do nothing and return FALSE if it cannot consume that observation (it may change to end state if it is not there already).
|
inlineinherited |
Reset checking the post-condition that the FSM does not go to an ending.
Definition at line 107 of file fsms.h.
References elementa::adts::BaseFSM::atEnd(), ELE_CODE_INVSTATE, elementa::adts::BaseFSM::reset(), and elementa::adts::BaseFSM::to_string().
| class elementa::adts::KeywordFSM |
A FSM that recognizes some fixed, short (shorter than 255 chars) string.
In this FSM, the end state is reached only when the entire word has been consumed and nothing else can be consumed further. If an observation comes that cannot be consumed in the current state, that does not lead to an end state.


Public Types | |
| using | Ptr = std::shared_ptr< FSM > |
| Pointer to a FSM that consumes observations of type Obs. More... | |
Types, consts, etc. | |
| using | Num = size_t |
| To represent a number of FSMs. More... | |
Public Member Functions | |
| KeywordFSM (const std::string &word, bool casesens=true) | |
| Constructor from the word. That word is copied inside. More... | |
| KeywordFSM (const KeywordFSM &o) | |
| KeywordFSM & | operator= (const KeywordFSM &o) |
| KeywordFSM (KeywordFSM &&o)=delete | |
| KeywordFSM & | operator= (KeywordFSM &&o)=delete |
| ~KeywordFSM (void) | |
| Destructor. More... | |
| std::string | word (void) const |
| Getter for the word. More... | |
| bool | atEnd (void) const |
| Must return TRUE if the current state is an absorbing/final one. More... | |
| bool | consume (char o) |
| void | reset (void) |
| Must set the FSM to a preliminary state when it has not been fed yet. More... | |
| std::string | to_string (void) const |
| Return a text representation of the FSM. Can be overriden. More... | |
| virtual bool | consume (Obs o)=0 |
| Must consume the given observation and change state if necessary. More... | |
Methods | |
| void | resetCheck (void) |
| Reset checking the post-condition that the FSM does not go to an ending. More... | |
Protected Member Functions | |
| char | caseChar (char c) |
|
inherited |
|
inherited |
| elementa::adts::KeywordFSM::KeywordFSM | ( | const std::string & | word, |
| bool | casesens = true |
||
| ) |
Constructor from the word. That word is copied inside.
The word can be empty, but it must be shorter than 255 chars.
|
inline |
|
inline |
|
inline |
|
inline |
|
inlinevirtual |
Must return TRUE if the current state is an absorbing/final one.
After a reset, the fsm must not be in an ending state.
Implements elementa::adts::BaseFSM.
|
inlinevirtual |
Must set the FSM to a preliminary state when it has not been fed yet.
Therefore, after this method, atEnd() must return FALSE. This method should be called from the constructors of derived FSMs to prepare them for reading observations.
Implements elementa::adts::BaseFSM.
|
inlinevirtual |
Return a text representation of the FSM. Can be overriden.
Reimplemented from elementa::adts::BaseFSM.
Definition at line 343 of file fsms.h.
References elementa::adts::BaseFSM::to_string(), and word().
|
inlineprotectedinherited |
|
pure virtualinherited |
Must consume the given observation and change state if necessary.
Must return TRUE if the observation can be consumed in the current state, either changing state or not. Must do nothing and return FALSE if it cannot consume that observation (it may change to end state if it is not there already).
|
inlineinherited |
Reset checking the post-condition that the FSM does not go to an ending.
Definition at line 107 of file fsms.h.
References elementa::adts::BaseFSM::atEnd(), ELE_CODE_INVSTATE, elementa::adts::BaseFSM::reset(), and elementa::adts::BaseFSM::to_string().
| class elementa::adts::CommentsFSM |
A FSM that recognizes uni- or multi-line comments.
This FSM consumes observations while they are in a comment. Reaches end state whenever the comment is finished.


Public Types | |
| using | Ptr = std::shared_ptr< FSM > |
| Pointer to a FSM that consumes observations of type Obs. More... | |
Types, consts, etc. | |
| using | Num = size_t |
| To represent a number of FSMs. More... | |
Public Member Functions | |
| CommentsFSM (const std::string &commstart="/*", const std::string &commend="*/") | |
| Constructor. More... | |
| CommentsFSM (const CommentsFSM &)=delete | |
| CommentsFSM (CommentsFSM &&)=delete | |
| CommentsFSM & | operator= (const CommentsFSM &)=delete |
| CommentsFSM & | operator= (CommentsFSM &&)=delete |
| void | reset (void) |
| Must set the FSM to a preliminary state when it has not been fed yet. More... | |
| bool | atEnd (void) const |
| Must return TRUE if the current state is an absorbing/final one. More... | |
| bool | consume (char o) |
| std::string | beginText (void) const |
| Return the start text for comments. More... | |
| std::string | endText (void) const |
| Return the end text for comments. More... | |
| std::string | to_string (void) const |
| Return a text representation of the FSM. Can be overriden. More... | |
| virtual bool | consume (Obs o)=0 |
| Must consume the given observation and change state if necessary. More... | |
Methods | |
| void | resetCheck (void) |
| Reset checking the post-condition that the FSM does not go to an ending. More... | |
Protected Member Functions | |
| char | caseChar (char c) |
|
inherited |
|
inherited |
| elementa::adts::CommentsFSM::CommentsFSM | ( | const std::string & | commstart = "/*", |
| const std::string & | commend = "*/" |
||
| ) |
Constructor.
| commstart | is the sequence of characters that begin the comment. |
| commend | is the sequence of characters that end the comment. |
|
inlinevirtual |
Must set the FSM to a preliminary state when it has not been fed yet.
Therefore, after this method, atEnd() must return FALSE. This method should be called from the constructors of derived FSMs to prepare them for reading observations.
Implements elementa::adts::BaseFSM.
|
inlinevirtual |
Must return TRUE if the current state is an absorbing/final one.
After a reset, the fsm must not be in an ending state.
Implements elementa::adts::BaseFSM.
|
inline |
|
inline |
|
inlinevirtual |
Return a text representation of the FSM. Can be overriden.
Reimplemented from elementa::adts::BaseFSM.
Definition at line 405 of file fsms.h.
References elementa::adts::BaseFSM::to_string().
|
inlineprotectedinherited |
|
pure virtualinherited |
Must consume the given observation and change state if necessary.
Must return TRUE if the observation can be consumed in the current state, either changing state or not. Must do nothing and return FALSE if it cannot consume that observation (it may change to end state if it is not there already).
|
inlineinherited |
Reset checking the post-condition that the FSM does not go to an ending.
Definition at line 107 of file fsms.h.
References elementa::adts::BaseFSM::atEnd(), ELE_CODE_INVSTATE, elementa::adts::BaseFSM::reset(), and elementa::adts::BaseFSM::to_string().
| class elementa::adts::IntegerTextFSM |
A FSM that recognizes an integer number from text.
This FSM consumes observations while they correspond to the number. Reaches end states whenever the alreay consumed observations form a valid number. It can go to a non-ending state after being in an ending state.


Public Types | |
| using | Ptr = std::shared_ptr< FSM > |
| Pointer to a FSM that consumes observations of type Obs. More... | |
Types, consts, etc. | |
| using | Num = size_t |
| To represent a number of FSMs. More... | |
Public Member Functions | |
| ELE_CLASS_ENUM (Kind, kDec, kHex, kOct, kBin) | |
| Kinds of number that can be recognized. | |
| IntegerTextFSM (Kind kind=Kind::kDec, bool withsign=true) | |
| Constructor. More... | |
| IntegerTextFSM (const IntegerTextFSM &o) | |
| IntegerTextFSM (IntegerTextFSM &&o) | |
| IntegerTextFSM & | operator= (const IntegerTextFSM &o) |
| IntegerTextFSM & | operator= (IntegerTextFSM &&o) |
| bool | atEnd (void) const |
| Must return TRUE if the current state is an absorbing/final one. More... | |
| bool | consume (char o) |
| void | reset (void) |
| Must set the FSM to a preliminary state when it has not been fed yet. More... | |
| std::string | to_string (void) const |
| Return a text representation of the FSM. Can be overriden. More... | |
| virtual bool | consume (Obs o)=0 |
| Must consume the given observation and change state if necessary. More... | |
Methods | |
| void | resetCheck (void) |
| Reset checking the post-condition that the FSM does not go to an ending. More... | |
Protected Member Functions | |
| char | caseChar (char c) |
|
inherited |
|
inherited |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inlinevirtual |
Must return TRUE if the current state is an absorbing/final one.
After a reset, the fsm must not be in an ending state.
Implements elementa::adts::BaseFSM.
|
virtual |
Must set the FSM to a preliminary state when it has not been fed yet.
Therefore, after this method, atEnd() must return FALSE. This method should be called from the constructors of derived FSMs to prepare them for reading observations.
Implements elementa::adts::BaseFSM.
Referenced by IntegerTextFSM().
|
inlinevirtual |
Return a text representation of the FSM. Can be overriden.
Reimplemented from elementa::adts::BaseFSM.
Definition at line 458 of file fsms.h.
References elementa::adts::BaseFSM::to_string().
|
inlineprotectedinherited |
|
pure virtualinherited |
Must consume the given observation and change state if necessary.
Must return TRUE if the observation can be consumed in the current state, either changing state or not. Must do nothing and return FALSE if it cannot consume that observation (it may change to end state if it is not there already).
|
inlineinherited |
Reset checking the post-condition that the FSM does not go to an ending.
Definition at line 107 of file fsms.h.
References elementa::adts::BaseFSM::atEnd(), ELE_CODE_INVSTATE, elementa::adts::BaseFSM::reset(), and elementa::adts::BaseFSM::to_string().
| class elementa::adts::NumberTextFSM |
A FSM that recognizes a real or integer number from a decimal text.
This FSM consumes observations while they correspond to the number. Reaches end states whenever the alreay consumed observations form a valid number. It can go to a non-ending state after being in an ending state.


Public Types | |
| using | Ptr = std::shared_ptr< FSM > |
| Pointer to a FSM that consumes observations of type Obs. More... | |
Types, consts, etc. | |
| using | Num = size_t |
| To represent a number of FSMs. More... | |
Public Member Functions | |
| NumberTextFSM (void) | |
| Constructor. More... | |
| NumberTextFSM (const NumberTextFSM &o) | |
| NumberTextFSM (NumberTextFSM &&o) | |
| NumberTextFSM & | operator= (const NumberTextFSM &o) |
| NumberTextFSM & | operator= (NumberTextFSM &&o) |
| bool | atEnd (void) const |
| Must return TRUE if the current state is an absorbing/final one. More... | |
| bool | consume (char o) |
| void | reset (void) |
| Must set the FSM to a preliminary state when it has not been fed yet. More... | |
| std::string | to_string (void) const |
| Return a text representation of the FSM. Can be overriden. More... | |
| virtual bool | consume (Obs o)=0 |
| Must consume the given observation and change state if necessary. More... | |
Methods | |
| void | resetCheck (void) |
| Reset checking the post-condition that the FSM does not go to an ending. More... | |
Protected Member Functions | |
| char | caseChar (char c) |
|
inherited |
|
inherited |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inlinevirtual |
Must return TRUE if the current state is an absorbing/final one.
After a reset, the fsm must not be in an ending state.
Implements elementa::adts::BaseFSM.
|
virtual |
Must set the FSM to a preliminary state when it has not been fed yet.
Therefore, after this method, atEnd() must return FALSE. This method should be called from the constructors of derived FSMs to prepare them for reading observations.
Implements elementa::adts::BaseFSM.
Referenced by NumberTextFSM().
|
inlinevirtual |
Return a text representation of the FSM. Can be overriden.
Reimplemented from elementa::adts::BaseFSM.
Definition at line 508 of file fsms.h.
References elementa::adts::BaseFSM::to_string().
|
inlineprotectedinherited |
|
pure virtualinherited |
Must consume the given observation and change state if necessary.
Must return TRUE if the observation can be consumed in the current state, either changing state or not. Must do nothing and return FALSE if it cannot consume that observation (it may change to end state if it is not there already).
|
inlineinherited |
Reset checking the post-condition that the FSM does not go to an ending.
Definition at line 107 of file fsms.h.
References elementa::adts::BaseFSM::atEnd(), ELE_CODE_INVSTATE, elementa::adts::BaseFSM::reset(), and elementa::adts::BaseFSM::to_string().