diff --git a/alib2algo/src/grammar/generate/GenerateUpToLength.cpp b/alib2algo/src/grammar/generate/GenerateUpToLength.cpp index 9a0e6b4ad059392a346ec203e10965dcecf15663..5ea114bf421b41a7a71c5fae3ee3346f8ee818ed 100644 --- a/alib2algo/src/grammar/generate/GenerateUpToLength.cpp +++ b/alib2algo/src/grammar/generate/GenerateUpToLength.cpp @@ -12,11 +12,40 @@ namespace grammar { namespace generate { -auto GenerateUpToLengthEpsilonFreeCFG = registration::AbstractRegister < GenerateUpToLength, ext::trie < DefaultSymbolType, bool >, const grammar::EpsilonFreeCFG < > &, unsigned > ( GenerateUpToLength::generate ); -auto GenerateUpToLengthGNF = registration::AbstractRegister < GenerateUpToLength, ext::trie < DefaultSymbolType, bool >, const grammar::GNF < > &, unsigned > ( GenerateUpToLength::generate ); -auto GenerateUpToLengthCNF = registration::AbstractRegister < GenerateUpToLength, ext::trie < DefaultSymbolType, bool >, const grammar::CNF < > &, unsigned > ( GenerateUpToLength::generate ); -auto GenerateUpToLengthLeftRG = registration::AbstractRegister < GenerateUpToLength, ext::trie < DefaultSymbolType, bool >, const grammar::LeftRG < > &, unsigned > ( GenerateUpToLength::generate ); -auto GenerateUpToLengthRightRG = registration::AbstractRegister < GenerateUpToLength, ext::trie < DefaultSymbolType, bool >, const grammar::RightRG < > &, unsigned > ( GenerateUpToLength::generate ); +auto GenerateUpToLengthEpsilonFreeCFG = registration::AbstractRegister < GenerateUpToLength, ext::trie < DefaultSymbolType, bool >, const grammar::EpsilonFreeCFG < > &, unsigned > ( GenerateUpToLength::generate, "grammar", "length" ).setDocumentation ( +"Implements the construction of index of all strings generated by given grammar shorter than given size.\n\ +\n\ +@param grammar the given grammar generating the language\n\ +@param length the limiting size of considered strings\n\ +@return trie where for each node the path from root to the node represents a string and a boolean flag determines whether the string is in the language or not." ); + +auto GenerateUpToLengthGNF = registration::AbstractRegister < GenerateUpToLength, ext::trie < DefaultSymbolType, bool >, const grammar::GNF < > &, unsigned > ( GenerateUpToLength::generate, "grammar", "length" ).setDocumentation ( +"Implements the construction of index of all strings generated by given grammar shorter than given size.\n\ +\n\ +@param grammar the given grammar generating the language\n\ +@param length the limiting size of considered strings\n\ +@return trie where for each node the path from root to the node represents a string and a boolean flag determines whether the string is in the language or not." ); + +auto GenerateUpToLengthCNF = registration::AbstractRegister < GenerateUpToLength, ext::trie < DefaultSymbolType, bool >, const grammar::CNF < > &, unsigned > ( GenerateUpToLength::generate, "grammar", "length" ).setDocumentation ( +"Implements the construction of index of all strings generated by given grammar shorter than given size.\n\ +\n\ +@param grammar the given grammar generating the language\n\ +@param length the limiting size of considered strings\n\ +@return trie where for each node the path from root to the node represents a string and a boolean flag determines whether the string is in the language or not." ); + +auto GenerateUpToLengthLeftRG = registration::AbstractRegister < GenerateUpToLength, ext::trie < DefaultSymbolType, bool >, const grammar::LeftRG < > &, unsigned > ( GenerateUpToLength::generate, "grammar", "length" ).setDocumentation ( +"Implements the construction of index of all strings generated by given grammar shorter than given size.\n\ +\n\ +@param grammar the given grammar generating the language\n\ +@param length the limiting size of considered strings\n\ +@return trie where for each node the path from root to the node represents a string and a boolean flag determines whether the string is in the language or not." ); + +auto GenerateUpToLengthRightRG = registration::AbstractRegister < GenerateUpToLength, ext::trie < DefaultSymbolType, bool >, const grammar::RightRG < > &, unsigned > ( GenerateUpToLength::generate, "grammar", "length" ).setDocumentation ( +"Implements the construction of index of all strings generated by given grammar shorter than given size.\n\ +\n\ +@param grammar the given grammar generating the language\n\ +@param length the limiting size of considered strings\n\ +@return trie where for each node the path from root to the node represents a string and a boolean flag determines whether the string is in the language or not." ); } /* namespace generate */ diff --git a/alib2algo/src/grammar/generate/GenerateUpToLength.h b/alib2algo/src/grammar/generate/GenerateUpToLength.h index d1efd89586aa27a4040d459e3e367af028e0e2c5..484e0b5f66f1445491c2d115c01c8c73202493ee 100644 --- a/alib2algo/src/grammar/generate/GenerateUpToLength.h +++ b/alib2algo/src/grammar/generate/GenerateUpToLength.h @@ -28,7 +28,7 @@ namespace grammar { namespace generate { /** - * Implements algorithms from Melichar, chapter 3.3 + * Implements the construction of index of all strings generated by given grammar shorter than given size. */ class GenerateUpToLength { template < class TerminalSymbolType > @@ -43,6 +43,18 @@ class GenerateUpToLength { } public: + /** + * Implements the construction of index of all strings generated by given grammar shorter than given size. + * + * \tparam T the type of grammar accepted + * \tparam TerminalSymbolType the type of terminal symbol of the grammar + * \tparam NonterminalSymbolType the type of nonterminal symbol of the grammar + * + * \param grammar the given grammar generating the language + * \param length the limiting size of considered strings + * + * \return trie where for each node the path from root to the node represents a string and a boolean flag determines whether the string is in the language or not. + */ template < class T, class TerminalSymbolType = typename grammar::TerminalSymbolTypeOfGrammar < T >, class NontermimnalSymbolType = typename grammar::NonterminalSymbolTypeOfGrammar < T > > static ext::trie < TerminalSymbolType, bool > generate ( const T & grammar, unsigned length ); };