From 669cb676301577d46524fbef846558812c8ea564 Mon Sep 17 00:00:00 2001 From: Jan Travnicek <Jan.Travnicek@fit.cvut.cz> Date: Wed, 6 Feb 2019 08:58:36 +0100 Subject: [PATCH] user documentation of some grammar simplify algos --- .../src/grammar/simplify/EpsilonRemover.cpp | 62 ++++++++++-- .../src/grammar/simplify/EpsilonRemover.h | 99 +++++++++++++++++++ .../grammar/simplify/LeftRecursionRemover.cpp | 48 +++++++-- .../grammar/simplify/LeftRecursionRemover.h | 76 ++++++++++++++ .../grammar/simplify/SimpleRulesRemover.cpp | 62 ++++++++++-- .../src/grammar/simplify/SimpleRulesRemover.h | 98 ++++++++++++++++++ 6 files changed, 420 insertions(+), 25 deletions(-) diff --git a/alib2algo/src/grammar/simplify/EpsilonRemover.cpp b/alib2algo/src/grammar/simplify/EpsilonRemover.cpp index d9aebc987e..80ec843bf2 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 46ae389fc9..cfca0a6886 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 5349c991f5..0d8fe536f1 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 9e9ac733a1..8b4a5fee35 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 47f627ec95..0f51e05e12 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 320462b1bd..5ca91b7859 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 ); }; -- GitLab