diff --git a/alib2algo/src/grammar/simplify/EpsilonRemover.cpp b/alib2algo/src/grammar/simplify/EpsilonRemover.cpp index d9aebc987ee0da1cbd0b2eae263db5788827a0e9..80ec843bf2d0a7f3a6832342e993d55f227093f0 100644 --- a/alib2algo/src/grammar/simplify/EpsilonRemover.cpp +++ b/alib2algo/src/grammar/simplify/EpsilonRemover.cpp @@ -12,15 +12,59 @@ namespace grammar { namespace simplify { -auto EpsilonRemoverCFG = registration::AbstractRegister < EpsilonRemover, grammar::EpsilonFreeCFG < >, const grammar::CFG < > & > ( EpsilonRemover::remove ); -auto EpsilonRemoverEpsilonFreeCFG = registration::AbstractRegister < EpsilonRemover, grammar::EpsilonFreeCFG < >, const grammar::EpsilonFreeCFG < > & > ( EpsilonRemover::remove ); -auto EpsilonRemoverCNF = registration::AbstractRegister < EpsilonRemover, grammar::CNF < >, const grammar::CNF < > & > ( EpsilonRemover::remove ); -auto EpsilonRemoverGNF = registration::AbstractRegister < EpsilonRemover, grammar::GNF < >, const grammar::GNF < > & > ( EpsilonRemover::remove ); -auto EpsilonRemoverLG = registration::AbstractRegister < EpsilonRemover, grammar::EpsilonFreeCFG < >, const grammar::LG < > & > ( EpsilonRemover::remove ); -auto EpsilonRemoverLeftLG = registration::AbstractRegister < EpsilonRemover, grammar::EpsilonFreeCFG < >, const grammar::LeftLG < > & > ( EpsilonRemover::remove ); -auto EpsilonRemoverLeftRG = registration::AbstractRegister < EpsilonRemover, grammar::LeftRG < >, const grammar::LeftRG < > & > ( EpsilonRemover::remove ); -auto EpsilonRemoverRightLG = registration::AbstractRegister < EpsilonRemover, grammar::EpsilonFreeCFG < >, const grammar::RightLG < > & > ( EpsilonRemover::remove ); -auto EpsilonRemoverRightRG = registration::AbstractRegister < EpsilonRemover, grammar::RightRG < >, const grammar::RightRG < > & > ( EpsilonRemover::remove ); +auto EpsilonRemoverCFG = registration::AbstractRegister < EpsilonRemover, grammar::EpsilonFreeCFG < >, const grammar::CFG < > & > ( EpsilonRemover::remove, "grammar" ).setDocumentation ( +"Removes epsilon rules from the given grammar.\n\ +\n\ +@param grammar the modified grammar\n\ +@return grammar without epsilon rules" ); + +auto EpsilonRemoverEpsilonFreeCFG = registration::AbstractRegister < EpsilonRemover, grammar::EpsilonFreeCFG < >, const grammar::EpsilonFreeCFG < > & > ( EpsilonRemover::remove, "grammar" ).setDocumentation ( +"Removes epsilon rules from the given grammar.\n\ +\n\ +@param grammar the modified grammar\n\ +@return grammar without epsilon rules" ); + +auto EpsilonRemoverCNF = registration::AbstractRegister < EpsilonRemover, grammar::CNF < >, const grammar::CNF < > & > ( EpsilonRemover::remove, "grammar" ).setDocumentation ( +"Removes epsilon rules from the given grammar.\n\ +\n\ +@param grammar the modified grammar\n\ +@return grammar without epsilon rules" ); + +auto EpsilonRemoverGNF = registration::AbstractRegister < EpsilonRemover, grammar::GNF < >, const grammar::GNF < > & > ( EpsilonRemover::remove, "grammar" ).setDocumentation ( +"Removes epsilon rules from the given grammar.\n\ +\n\ +@param grammar the modified grammar\n\ +@return grammar without epsilon rules" ); + +auto EpsilonRemoverLG = registration::AbstractRegister < EpsilonRemover, grammar::EpsilonFreeCFG < >, const grammar::LG < > & > ( EpsilonRemover::remove, "grammar" ).setDocumentation ( +"Removes epsilon rules from the given grammar.\n\ +\n\ +@param grammar the modified grammar\n\ +@return grammar without epsilon rules" ); + +auto EpsilonRemoverLeftLG = registration::AbstractRegister < EpsilonRemover, grammar::EpsilonFreeCFG < >, const grammar::LeftLG < > & > ( EpsilonRemover::remove, "grammar" ).setDocumentation ( +"Removes epsilon rules from the given grammar.\n\ +\n\ +@param grammar the modified grammar\n\ +@return grammar without epsilon rules" ); + +auto EpsilonRemoverLeftRG = registration::AbstractRegister < EpsilonRemover, grammar::LeftRG < >, const grammar::LeftRG < > & > ( EpsilonRemover::remove, "grammar" ).setDocumentation ( +"Removes epsilon rules from the given grammar.\n\ +\n\ +@param grammar the modified grammar\n\ +@return grammar without epsilon rules" ); + +auto EpsilonRemoverRightLG = registration::AbstractRegister < EpsilonRemover, grammar::EpsilonFreeCFG < >, const grammar::RightLG < > & > ( EpsilonRemover::remove, "grammar" ).setDocumentation ( +"Removes epsilon rules from the given grammar.\n\ +\n\ +@param grammar the modified grammar\n\ +@return grammar without epsilon rules" ); + +auto EpsilonRemoverRightRG = registration::AbstractRegister < EpsilonRemover, grammar::RightRG < >, const grammar::RightRG < > & > ( EpsilonRemover::remove, "grammar" ).setDocumentation ( +"Removes epsilon rules from the given grammar.\n\ +\n\ +@param grammar the modified grammar\n\ +@return grammar without epsilon rules" ); } /* namespace simplify */ diff --git a/alib2algo/src/grammar/simplify/EpsilonRemover.h b/alib2algo/src/grammar/simplify/EpsilonRemover.h index 46ae389fc9cec6f5bc3eea39834eb4dabc7fcd22..cfca0a6886d9bf6ff4de5baecab218b42448aeaf 100644 --- a/alib2algo/src/grammar/simplify/EpsilonRemover.h +++ b/alib2algo/src/grammar/simplify/EpsilonRemover.h @@ -37,23 +37,122 @@ class EpsilonRemover { template<class T, class TerminalSymbolType = typename grammar::TerminalSymbolTypeOfGrammar < T >, class NonterminalSymbolType = typename grammar::NonterminalSymbolTypeOfGrammar < T > > static grammar::EpsilonFreeCFG < TerminalSymbolType, NonterminalSymbolType > removeInternal( const T & origGrammar ); + public: + /** + * Removes epsilon rules from the given grammar. + * + * \tparam TerminalSymbolType the type of terminals in the grammar + * \tparam NonterminalSymbolType the type of nonterminals in the grammar + * + * \param grammar the modified grammar + * + * \return grammar without epsilon rules + */ template < class TerminalSymbolType, class NonterminalSymbolType > static grammar::EpsilonFreeCFG < TerminalSymbolType, NonterminalSymbolType > remove( const grammar::CFG < TerminalSymbolType, NonterminalSymbolType > & grammar ); + + /** + * Removes epsilon rules from the given grammar. + * + * \tparam TerminalSymbolType the type of terminals in the grammar + * \tparam NonterminalSymbolType the type of nonterminals in the grammar + * + * \param grammar the modified grammar + * + * \return grammar without epsilon rules + */ template < class TerminalSymbolType, class NonterminalSymbolType > static grammar::EpsilonFreeCFG < TerminalSymbolType, NonterminalSymbolType > remove( const grammar::EpsilonFreeCFG < TerminalSymbolType, NonterminalSymbolType > & grammar ); + + /** + * Removes epsilon rules from the given grammar. + * + * \tparam TerminalSymbolType the type of terminals in the grammar + * \tparam NonterminalSymbolType the type of nonterminals in the grammar + * + * \param grammar the modified grammar + * + * \return grammar without epsilon rules + */ template < class TerminalSymbolType, class NonterminalSymbolType > static grammar::GNF < TerminalSymbolType, NonterminalSymbolType > remove( const grammar::GNF < TerminalSymbolType, NonterminalSymbolType > & grammar ); + + /** + * Removes epsilon rules from the given grammar. + * + * \tparam TerminalSymbolType the type of terminals in the grammar + * \tparam NonterminalSymbolType the type of nonterminals in the grammar + * + * \param grammar the modified grammar + * + * \return grammar without epsilon rules + */ template < class TerminalSymbolType, class NonterminalSymbolType > static grammar::CNF < TerminalSymbolType, NonterminalSymbolType > remove( const grammar::CNF < TerminalSymbolType, NonterminalSymbolType > & grammar ); + + /** + * Removes epsilon rules from the given grammar. + * + * \tparam TerminalSymbolType the type of terminals in the grammar + * \tparam NonterminalSymbolType the type of nonterminals in the grammar + * + * \param grammar the modified grammar + * + * \return grammar without epsilon rules + */ template < class TerminalSymbolType, class NonterminalSymbolType > static grammar::EpsilonFreeCFG < TerminalSymbolType, NonterminalSymbolType > remove( const grammar::LG < TerminalSymbolType, NonterminalSymbolType > & grammar ); + + /** + * Removes epsilon rules from the given grammar. + * + * \tparam TerminalSymbolType the type of terminals in the grammar + * \tparam NonterminalSymbolType the type of nonterminals in the grammar + * + * \param grammar the modified grammar + * + * \return grammar without epsilon rules + */ template < class TerminalSymbolType, class NonterminalSymbolType > static grammar::EpsilonFreeCFG < TerminalSymbolType, NonterminalSymbolType > remove( const grammar::LeftLG < TerminalSymbolType, NonterminalSymbolType > & grammar ); + + /** + * Removes epsilon rules from the given grammar. + * + * \tparam TerminalSymbolType the type of terminals in the grammar + * \tparam NonterminalSymbolType the type of nonterminals in the grammar + * + * \param grammar the modified grammar + * + * \return grammar without epsilon rules + */ template < class TerminalSymbolType, class NonterminalSymbolType > static grammar::LeftRG < TerminalSymbolType, NonterminalSymbolType > remove( const grammar::LeftRG < TerminalSymbolType, NonterminalSymbolType > & grammar ); + + /** + * Removes epsilon rules from the given grammar. + * + * \tparam TerminalSymbolType the type of terminals in the grammar + * \tparam NonterminalSymbolType the type of nonterminals in the grammar + * + * \param grammar the modified grammar + * + * \return grammar without epsilon rules + */ template < class TerminalSymbolType, class NonterminalSymbolType > static grammar::EpsilonFreeCFG < TerminalSymbolType, NonterminalSymbolType > remove( const grammar::RightLG < TerminalSymbolType, NonterminalSymbolType > & grammar ); + + /** + * Removes epsilon rules from the given grammar. + * + * \tparam TerminalSymbolType the type of terminals in the grammar + * \tparam NonterminalSymbolType the type of nonterminals in the grammar + * + * \param grammar the modified grammar + * + * \return grammar without epsilon rules + */ template < class TerminalSymbolType, class NonterminalSymbolType > static grammar::RightRG < TerminalSymbolType, NonterminalSymbolType > remove( const grammar::RightRG < TerminalSymbolType, NonterminalSymbolType > & grammar ); }; diff --git a/alib2algo/src/grammar/simplify/LeftRecursionRemover.cpp b/alib2algo/src/grammar/simplify/LeftRecursionRemover.cpp index 5349c991f5399729a627da8c9455f545bbee4f16..0d8fe536f18f39f64a5780698c69f5773f644402 100644 --- a/alib2algo/src/grammar/simplify/LeftRecursionRemover.cpp +++ b/alib2algo/src/grammar/simplify/LeftRecursionRemover.cpp @@ -12,13 +12,47 @@ namespace grammar { namespace simplify { -auto LeftRecursionRemoverEpsilonFreeCFG = registration::AbstractRegister < LeftRecursionRemover, grammar::EpsilonFreeCFG < >, const grammar::EpsilonFreeCFG < > & > ( LeftRecursionRemover::remove ); -auto LeftRecursionRemoverCNF = registration::AbstractRegister < LeftRecursionRemover, grammar::EpsilonFreeCFG < >, const grammar::CNF < > & > ( LeftRecursionRemover::remove ); -auto LeftRecursionRemoverGNF = registration::AbstractRegister < LeftRecursionRemover, grammar::GNF < >, const grammar::GNF < > & > ( LeftRecursionRemover::remove ); -auto LeftRecursionRemoverRightRG = registration::AbstractRegister < LeftRecursionRemover, grammar::RightRG < >, const grammar::RightRG < > & > ( LeftRecursionRemover::remove ); -auto LeftRecursionRemoverRightLG = registration::AbstractRegister < LeftRecursionRemover, grammar::RightLG < >, const grammar::RightLG < > & > ( LeftRecursionRemover::remove ); -auto LeftRecursionRemoverLeftRG = registration::AbstractRegister < LeftRecursionRemover, grammar::RightRG < >, const grammar::LeftRG < > & > ( LeftRecursionRemover::remove ); -auto LeftRecursionRemoverLeftLG = registration::AbstractRegister < LeftRecursionRemover, grammar::RightLG < >, const grammar::LeftLG < > & > ( LeftRecursionRemover::remove ); +auto LeftRecursionRemoverEpsilonFreeCFG = registration::AbstractRegister < LeftRecursionRemover, grammar::EpsilonFreeCFG < >, const grammar::EpsilonFreeCFG < > & > ( LeftRecursionRemover::remove, "grammar" ).setDocumentation ( +"Removes left recursion from the given grammar.\n\ +\n\ +@param grammar the modified grammar\n\ +@return grammar without left recursion" ); + +auto LeftRecursionRemoverCNF = registration::AbstractRegister < LeftRecursionRemover, grammar::EpsilonFreeCFG < >, const grammar::CNF < > & > ( LeftRecursionRemover::remove, "grammar" ).setDocumentation ( +"Removes left recursion from the given grammar.\n\ +\n\ +@param grammar the modified grammar\n\ +@return grammar without left recursion" ); + +auto LeftRecursionRemoverGNF = registration::AbstractRegister < LeftRecursionRemover, grammar::GNF < >, const grammar::GNF < > & > ( LeftRecursionRemover::remove, "grammar" ).setDocumentation ( +"Removes left recursion from the given grammar.\n\ +\n\ +@param grammar the modified grammar\n\ +@return grammar without left recursion" ); + +auto LeftRecursionRemoverRightRG = registration::AbstractRegister < LeftRecursionRemover, grammar::RightRG < >, const grammar::RightRG < > & > ( LeftRecursionRemover::remove, "grammar" ).setDocumentation ( +"Removes left recursion from the given grammar.\n\ +\n\ +@param grammar the modified grammar\n\ +@return grammar without left recursion" ); + +auto LeftRecursionRemoverRightLG = registration::AbstractRegister < LeftRecursionRemover, grammar::RightLG < >, const grammar::RightLG < > & > ( LeftRecursionRemover::remove, "grammar" ).setDocumentation ( +"Removes left recursion from the given grammar.\n\ +\n\ +@param grammar the modified grammar\n\ +@return grammar without left recursion" ); + +auto LeftRecursionRemoverLeftRG = registration::AbstractRegister < LeftRecursionRemover, grammar::RightRG < >, const grammar::LeftRG < > & > ( LeftRecursionRemover::remove, "grammar" ).setDocumentation ( +"Removes left recursion from the given grammar.\n\ +\n\ +@param grammar the modified grammar\n\ +@return grammar without left recursion" ); + +auto LeftRecursionRemoverLeftLG = registration::AbstractRegister < LeftRecursionRemover, grammar::RightLG < >, const grammar::LeftLG < > & > ( LeftRecursionRemover::remove, "grammar" ).setDocumentation ( +"Removes left recursion from the given grammar.\n\ +\n\ +@param grammar the modified grammar\n\ +@return grammar without left recursion" ); } /* namespace simplify */ diff --git a/alib2algo/src/grammar/simplify/LeftRecursionRemover.h b/alib2algo/src/grammar/simplify/LeftRecursionRemover.h index 9e9ac733a1eee75a7294e2101bfa5e39b5a9c75f..8b4a5fee3546e3ef05f4da9c81d8dacbe3c2fb22 100644 --- a/alib2algo/src/grammar/simplify/LeftRecursionRemover.h +++ b/alib2algo/src/grammar/simplify/LeftRecursionRemover.h @@ -37,18 +37,94 @@ class LeftRecursionRemover { template < class TerminalSymbolType, class NonterminalSymbolType > static grammar::EpsilonFreeCFG < TerminalSymbolType, NonterminalSymbolType > assignAsOrder ( const grammar::EpsilonFreeCFG < TerminalSymbolType, NonterminalSymbolType > & origGrammar, unsigned i, const ext::set < NonterminalSymbolType > & origNonterminals ); public: + /** + * Removes left recursion from the given grammar. + * + * \tparam TerminalSymbolType the type of terminals in the grammar + * \tparam NonterminalSymbolType the type of nonterminals in the grammar + * + * \param grammar the modified grammar + * + * \return grammar without left recursion + */ template < class TerminalSymbolType, class NonterminalSymbolType > static grammar::EpsilonFreeCFG < TerminalSymbolType, NonterminalSymbolType > remove( const grammar::EpsilonFreeCFG < TerminalSymbolType, NonterminalSymbolType > & grammar ); + + /** + * Removes left recursion from the given grammar. + * + * \tparam TerminalSymbolType the type of terminals in the grammar + * \tparam NonterminalSymbolType the type of nonterminals in the grammar + * + * \param grammar the modified grammar + * + * \return grammar without left recursion + */ template < class TerminalSymbolType, class NonterminalSymbolType > static grammar::EpsilonFreeCFG < TerminalSymbolType, NonterminalSymbolType > remove( const grammar::CNF < TerminalSymbolType, NonterminalSymbolType > & grammar ); + + /** + * Removes left recursion from the given grammar. + * + * \tparam TerminalSymbolType the type of terminals in the grammar + * \tparam NonterminalSymbolType the type of nonterminals in the grammar + * + * \param grammar the modified grammar + * + * \return grammar without left recursion + */ template < class TerminalSymbolType, class NonterminalSymbolType > static grammar::GNF < TerminalSymbolType, NonterminalSymbolType > remove( const grammar::GNF < TerminalSymbolType, NonterminalSymbolType > & grammar ); + + /** + * Removes left recursion from the given grammar. + * + * \tparam TerminalSymbolType the type of terminals in the grammar + * \tparam NonterminalSymbolType the type of nonterminals in the grammar + * + * \param grammar the modified grammar + * + * \return grammar without left recursion + */ template < class TerminalSymbolType, class NonterminalSymbolType > static grammar::RightRG < TerminalSymbolType, NonterminalSymbolType > remove( const grammar::RightRG < TerminalSymbolType, NonterminalSymbolType > & grammar ); + + /** + * Removes left recursion from the given grammar. + * + * \tparam TerminalSymbolType the type of terminals in the grammar + * \tparam NonterminalSymbolType the type of nonterminals in the grammar + * + * \param grammar the modified grammar + * + * \return grammar without left recursion + */ template < class TerminalSymbolType, class NonterminalSymbolType > static grammar::RightLG < TerminalSymbolType, NonterminalSymbolType > remove( const grammar::RightLG < TerminalSymbolType, NonterminalSymbolType > & grammar ); + + /** + * Removes left recursion from the given grammar. + * + * \tparam TerminalSymbolType the type of terminals in the grammar + * \tparam NonterminalSymbolType the type of nonterminals in the grammar + * + * \param grammar the modified grammar + * + * \return grammar without left recursion + */ template < class TerminalSymbolType, class NonterminalSymbolType > static grammar::RightRG < TerminalSymbolType, NonterminalSymbolType > remove( const grammar::LeftRG < TerminalSymbolType, NonterminalSymbolType > & grammar ); + + /** + * Removes left recursion from the given grammar. + * + * \tparam TerminalSymbolType the type of terminals in the grammar + * \tparam NonterminalSymbolType the type of nonterminals in the grammar + * + * \param grammar the modified grammar + * + * \return grammar without left recursion + */ template < class TerminalSymbolType, class NonterminalSymbolType > static grammar::RightLG < TerminalSymbolType, NonterminalSymbolType > remove( const grammar::LeftLG < TerminalSymbolType, NonterminalSymbolType > & grammar ); }; diff --git a/alib2algo/src/grammar/simplify/SimpleRulesRemover.cpp b/alib2algo/src/grammar/simplify/SimpleRulesRemover.cpp index 47f627ec953b46a1e6e36f9838e5b0737be50166..0f51e05e12166da43049264fbf75420ed316e84c 100644 --- a/alib2algo/src/grammar/simplify/SimpleRulesRemover.cpp +++ b/alib2algo/src/grammar/simplify/SimpleRulesRemover.cpp @@ -12,15 +12,59 @@ namespace grammar { namespace simplify { -auto SimpleRulesRemoverCFG = registration::AbstractRegister < SimpleRulesRemover, grammar::CFG < >, const grammar::CFG < > & > ( SimpleRulesRemover::remove ); -auto SimpleRulesRemoverEpsilonFreeCFG = registration::AbstractRegister < SimpleRulesRemover, grammar::EpsilonFreeCFG < >, const grammar::EpsilonFreeCFG < > & > ( SimpleRulesRemover::remove ); -auto SimpleRulesRemoverCNF = registration::AbstractRegister < SimpleRulesRemover, grammar::CNF < >, const grammar::CNF < > & > ( SimpleRulesRemover::remove ); -auto SimpleRulesRemoverGNF = registration::AbstractRegister < SimpleRulesRemover, grammar::GNF < >, const grammar::GNF < > & > ( SimpleRulesRemover::remove ); -auto SimpleRulesRemoverLG = registration::AbstractRegister < SimpleRulesRemover, grammar::LG < >, const grammar::LG < > & > ( SimpleRulesRemover::remove ); -auto SimpleRulesRemoverLeftLG = registration::AbstractRegister < SimpleRulesRemover, grammar::LeftLG < >, const grammar::LeftLG < > & > ( SimpleRulesRemover::remove ); -auto SimpleRulesRemoverLeftRG = registration::AbstractRegister < SimpleRulesRemover, grammar::LeftRG < >, const grammar::LeftRG < > & > ( SimpleRulesRemover::remove ); -auto SimpleRulesRemoverRightLG = registration::AbstractRegister < SimpleRulesRemover, grammar::RightLG < >, const grammar::RightLG < > & > ( SimpleRulesRemover::remove ); -auto SimpleRulesRemoverRightRG = registration::AbstractRegister < SimpleRulesRemover, grammar::RightRG < >, const grammar::RightRG < > & > ( SimpleRulesRemover::remove ); +auto SimpleRulesRemoverCFG = registration::AbstractRegister < SimpleRulesRemover, grammar::CFG < >, const grammar::CFG < > & > ( SimpleRulesRemover::remove, "grammar" ).setDocumentation ( +"Removes simple rules from the given grammar.\n\ +\n\ +@param grammar the modified grammar\n\ +@return grammar without simple rules" ); + +auto SimpleRulesRemoverEpsilonFreeCFG = registration::AbstractRegister < SimpleRulesRemover, grammar::EpsilonFreeCFG < >, const grammar::EpsilonFreeCFG < > & > ( SimpleRulesRemover::remove, "grammar" ).setDocumentation ( +"Removes simple rules from the given grammar.\n\ +\n\ +@param grammar the modified grammar\n\ +@return grammar without simple rules" ); + +auto SimpleRulesRemoverCNF = registration::AbstractRegister < SimpleRulesRemover, grammar::CNF < >, const grammar::CNF < > & > ( SimpleRulesRemover::remove, "grammar" ).setDocumentation ( +"Removes simple rules from the given grammar.\n\ +\n\ +@param grammar the modified grammar\n\ +@return grammar without simple rules" ); + +auto SimpleRulesRemoverGNF = registration::AbstractRegister < SimpleRulesRemover, grammar::GNF < >, const grammar::GNF < > & > ( SimpleRulesRemover::remove, "grammar" ).setDocumentation ( +"Removes simple rules from the given grammar.\n\ +\n\ +@param grammar the modified grammar\n\ +@return grammar without simple rules" ); + +auto SimpleRulesRemoverLG = registration::AbstractRegister < SimpleRulesRemover, grammar::LG < >, const grammar::LG < > & > ( SimpleRulesRemover::remove, "grammar" ).setDocumentation ( +"Removes simple rules from the given grammar.\n\ +\n\ +@param grammar the modified grammar\n\ +@return grammar without simple rules" ); + +auto SimpleRulesRemoverLeftLG = registration::AbstractRegister < SimpleRulesRemover, grammar::LeftLG < >, const grammar::LeftLG < > & > ( SimpleRulesRemover::remove, "grammar" ).setDocumentation ( +"Removes simple rules from the given grammar.\n\ +\n\ +@param grammar the modified grammar\n\ +@return grammar without simple rules" ); + +auto SimpleRulesRemoverLeftRG = registration::AbstractRegister < SimpleRulesRemover, grammar::LeftRG < >, const grammar::LeftRG < > & > ( SimpleRulesRemover::remove, "grammar" ).setDocumentation ( +"Removes simple rules from the given grammar.\n\ +\n\ +@param grammar the modified grammar\n\ +@return grammar without simple rules" ); + +auto SimpleRulesRemoverRightLG = registration::AbstractRegister < SimpleRulesRemover, grammar::RightLG < >, const grammar::RightLG < > & > ( SimpleRulesRemover::remove, "grammar" ).setDocumentation ( +"Removes simple rules from the given grammar.\n\ +\n\ +@param grammar the modified grammar\n\ +@return grammar without simple rules" ); + +auto SimpleRulesRemoverRightRG = registration::AbstractRegister < SimpleRulesRemover, grammar::RightRG < >, const grammar::RightRG < > & > ( SimpleRulesRemover::remove, "grammar" ).setDocumentation ( +"Removes simple rules from the given grammar.\n\ +\n\ +@param grammar the modified grammar\n\ +@return grammar without simple rules" ); } /* namespace simplify */ diff --git a/alib2algo/src/grammar/simplify/SimpleRulesRemover.h b/alib2algo/src/grammar/simplify/SimpleRulesRemover.h index 320462b1bd0331384f7d4140821e7692dbe61b74..5ca91b785989460c12801c8d7873308b760099e1 100644 --- a/alib2algo/src/grammar/simplify/SimpleRulesRemover.h +++ b/alib2algo/src/grammar/simplify/SimpleRulesRemover.h @@ -36,22 +36,120 @@ class SimpleRulesRemover { static T removeNonEpsilonFree( const T & origGrammar ); public: + /** + * Removes simple rules from the given grammar. + * + * \tparam TerminalSymbolType the type of terminals in the grammar + * \tparam NonterminalSymbolType the type of nonterminals in the grammar + * + * \param grammar the modified grammar + * + * \return grammar without simple rules + */ template < class TerminalSymbolType, class NonterminalSymbolType > static grammar::CFG < TerminalSymbolType, NonterminalSymbolType > remove( const grammar::CFG < TerminalSymbolType, NonterminalSymbolType > & grammar ); + + /** + * Removes simple rules from the given grammar. + * + * \tparam TerminalSymbolType the type of terminals in the grammar + * \tparam NonterminalSymbolType the type of nonterminals in the grammar + * + * \param grammar the modified grammar + * + * \return grammar without simple rules + */ template < class TerminalSymbolType, class NonterminalSymbolType > static grammar::EpsilonFreeCFG < TerminalSymbolType, NonterminalSymbolType > remove( const grammar::EpsilonFreeCFG < TerminalSymbolType, NonterminalSymbolType > & grammar ); + + /** + * Removes simple rules from the given grammar. + * + * \tparam TerminalSymbolType the type of terminals in the grammar + * \tparam NonterminalSymbolType the type of nonterminals in the grammar + * + * \param grammar the modified grammar + * + * \return grammar without simple rules + */ template < class TerminalSymbolType, class NonterminalSymbolType > static grammar::GNF < TerminalSymbolType, NonterminalSymbolType > remove( const grammar::GNF < TerminalSymbolType, NonterminalSymbolType > & grammar ); + + /** + * Removes simple rules from the given grammar. + * + * \tparam TerminalSymbolType the type of terminals in the grammar + * \tparam NonterminalSymbolType the type of nonterminals in the grammar + * + * \param grammar the modified grammar + * + * \return grammar without simple rules + */ template < class TerminalSymbolType, class NonterminalSymbolType > static grammar::CNF < TerminalSymbolType, NonterminalSymbolType > remove( const grammar::CNF < TerminalSymbolType, NonterminalSymbolType > & grammar ); + + /** + * Removes simple rules from the given grammar. + * + * \tparam TerminalSymbolType the type of terminals in the grammar + * \tparam NonterminalSymbolType the type of nonterminals in the grammar + * + * \param grammar the modified grammar + * + * \return grammar without simple rules + */ template < class TerminalSymbolType, class NonterminalSymbolType > static grammar::LG < TerminalSymbolType, NonterminalSymbolType > remove( const grammar::LG < TerminalSymbolType, NonterminalSymbolType > & grammar ); + + /** + * Removes simple rules from the given grammar. + * + * \tparam TerminalSymbolType the type of terminals in the grammar + * \tparam NonterminalSymbolType the type of nonterminals in the grammar + * + * \param grammar the modified grammar + * + * \return grammar without simple rules + */ template < class TerminalSymbolType, class NonterminalSymbolType > static grammar::LeftLG < TerminalSymbolType, NonterminalSymbolType > remove( const grammar::LeftLG < TerminalSymbolType, NonterminalSymbolType > & grammar ); + + /** + * Removes simple rules from the given grammar. + * + * \tparam TerminalSymbolType the type of terminals in the grammar + * \tparam NonterminalSymbolType the type of nonterminals in the grammar + * + * \param grammar the modified grammar + * + * \return grammar without simple rules + */ template < class TerminalSymbolType, class NonterminalSymbolType > static grammar::LeftRG < TerminalSymbolType, NonterminalSymbolType > remove( const grammar::LeftRG < TerminalSymbolType, NonterminalSymbolType > & grammar ); + + /** + * Removes simple rules from the given grammar. + * + * \tparam TerminalSymbolType the type of terminals in the grammar + * \tparam NonterminalSymbolType the type of nonterminals in the grammar + * + * \param grammar the modified grammar + * + * \return grammar without simple rules + */ template < class TerminalSymbolType, class NonterminalSymbolType > static grammar::RightLG < TerminalSymbolType, NonterminalSymbolType > remove( const grammar::RightLG < TerminalSymbolType, NonterminalSymbolType > & grammar ); + + /** + * Removes simple rules from the given grammar. + * + * \tparam TerminalSymbolType the type of terminals in the grammar + * \tparam NonterminalSymbolType the type of nonterminals in the grammar + * + * \param grammar the modified grammar + * + * \return grammar without simple rules + */ template < class TerminalSymbolType, class NonterminalSymbolType > static grammar::RightRG < TerminalSymbolType, NonterminalSymbolType > remove( const grammar::RightRG < TerminalSymbolType, NonterminalSymbolType > & grammar ); };