diff --git a/alib2algo/src/grammar/properties/IsLanguageEmpty.cpp b/alib2algo/src/grammar/properties/IsLanguageEmpty.cpp index f9fd96cd1d7457c6fc08579dcaec7b47c3b56862..dc2a5b5400224ac0acac26fbc6109c9031045243 100644 --- a/alib2algo/src/grammar/properties/IsLanguageEmpty.cpp +++ b/alib2algo/src/grammar/properties/IsLanguageEmpty.cpp @@ -22,15 +22,77 @@ namespace grammar { namespace properties { -auto IsLanguageEmptyCFG = registration::AbstractRegister < IsLanguageEmpty, bool, const grammar::CFG < > & > ( IsLanguageEmpty::isLanguageEmpty ); -auto IsLanguageEmptyEpsilonFreeCFG = registration::AbstractRegister < IsLanguageEmpty, bool, const grammar::EpsilonFreeCFG < > & > ( IsLanguageEmpty::isLanguageEmpty ); -auto IsLanguageEmptyGNF = registration::AbstractRegister < IsLanguageEmpty, bool, const grammar::GNF < > & > ( IsLanguageEmpty::isLanguageEmpty ); -auto IsLanguageEmptyCNF = registration::AbstractRegister < IsLanguageEmpty, bool, const grammar::CNF < > & > ( IsLanguageEmpty::isLanguageEmpty ); -auto IsLanguageEmptyLG = registration::AbstractRegister < IsLanguageEmpty, bool, const grammar::LG < > & > ( IsLanguageEmpty::isLanguageEmpty ); -auto IsLanguageEmptyLeftLG = registration::AbstractRegister < IsLanguageEmpty, bool, const grammar::LeftLG < > & > ( IsLanguageEmpty::isLanguageEmpty ); -auto IsLanguageEmptyLeftRG = registration::AbstractRegister < IsLanguageEmpty, bool, const grammar::LeftRG < > & > ( IsLanguageEmpty::isLanguageEmpty ); -auto IsLanguageEmptyRightLG = registration::AbstractRegister < IsLanguageEmpty, bool, const grammar::RightLG < > & > ( IsLanguageEmpty::isLanguageEmpty ); -auto IsLanguageEmptyRightRG = registration::AbstractRegister < IsLanguageEmpty, bool, const grammar::RightRG < > & > ( IsLanguageEmpty::isLanguageEmpty ); +auto IsLanguageEmptyCFG = registration::AbstractRegister < IsLanguageEmpty, bool, const grammar::CFG < > & > ( IsLanguageEmpty::isLanguageEmpty, "grammar" ).setDocumentation ( +"Decides whether L( grammar ) = \\0\n\ +\n\ +Severals steps implemented in @see grammar::properties::ProductiveNonterminals\n\ +\n\ +@param grammar the tested grammar\n\ +@returns true if L(@p grammar) = \\0"); + +auto IsLanguageEmptyEpsilonFreeCFG = registration::AbstractRegister < IsLanguageEmpty, bool, const grammar::EpsilonFreeCFG < > & > ( IsLanguageEmpty::isLanguageEmpty, "grammar" ).setDocumentation ( +"Decides whether L( grammar ) = \\0\n\ +\n\ +Severals steps implemented in @see grammar::properties::ProductiveNonterminals\n\ +\n\ +@param grammar the tested grammar\n\ +@returns true if L(@p grammar) = \\0"); + +auto IsLanguageEmptyGNF = registration::AbstractRegister < IsLanguageEmpty, bool, const grammar::GNF < > & > ( IsLanguageEmpty::isLanguageEmpty, "grammar" ).setDocumentation ( +"Decides whether L( grammar ) = \\0\n\ +\n\ +Severals steps implemented in @see grammar::properties::ProductiveNonterminals\n\ +\n\ +@param grammar the tested grammar\n\ +@returns true if L(@p grammar) = \\0"); + +auto IsLanguageEmptyCNF = registration::AbstractRegister < IsLanguageEmpty, bool, const grammar::CNF < > & > ( IsLanguageEmpty::isLanguageEmpty, "grammar" ).setDocumentation ( +"Decides whether L( grammar ) = \\0\n\ +\n\ +Severals steps implemented in @see grammar::properties::ProductiveNonterminals\n\ +\n\ +@param grammar the tested grammar\n\ +@returns true if L(@p grammar) = \\0"); + +auto IsLanguageEmptyLG = registration::AbstractRegister < IsLanguageEmpty, bool, const grammar::LG < > & > ( IsLanguageEmpty::isLanguageEmpty, "grammar" ).setDocumentation ( +"Decides whether L( grammar ) = \\0\n\ +\n\ +Severals steps implemented in @see grammar::properties::ProductiveNonterminals\n\ +\n\ +@param grammar the tested grammar\n\ +@returns true if L(@p grammar) = \\0"); + +auto IsLanguageEmptyLeftLG = registration::AbstractRegister < IsLanguageEmpty, bool, const grammar::LeftLG < > & > ( IsLanguageEmpty::isLanguageEmpty, "grammar" ).setDocumentation ( +"Decides whether L( grammar ) = \\0\n\ +\n\ +Severals steps implemented in @see grammar::properties::ProductiveNonterminals\n\ +\n\ +@param grammar the tested grammar\n\ +@returns true if L(@p grammar) = \\0"); + +auto IsLanguageEmptyLeftRG = registration::AbstractRegister < IsLanguageEmpty, bool, const grammar::LeftRG < > & > ( IsLanguageEmpty::isLanguageEmpty, "grammar" ).setDocumentation ( +"Decides whether L( grammar ) = \\0\n\ +\n\ +Severals steps implemented in @see grammar::properties::ProductiveNonterminals\n\ +\n\ +@param grammar the tested grammar\n\ +@returns true if L(@p grammar) = \\0"); + +auto IsLanguageEmptyRightLG = registration::AbstractRegister < IsLanguageEmpty, bool, const grammar::RightLG < > & > ( IsLanguageEmpty::isLanguageEmpty, "grammar" ).setDocumentation ( +"Decides whether L( grammar ) = \\0\n\ +\n\ +Severals steps implemented in @see grammar::properties::ProductiveNonterminals\n\ +\n\ +@param grammar the tested grammar\n\ +@returns true if L(@p grammar) = \\0"); + +auto IsLanguageEmptyRightRG = registration::AbstractRegister < IsLanguageEmpty, bool, const grammar::RightRG < > & > ( IsLanguageEmpty::isLanguageEmpty, "grammar" ).setDocumentation ( +"Decides whether L( grammar ) = \\0\n\ +\n\ +Severals steps implemented in @see grammar::properties::ProductiveNonterminals\n\ +\n\ +@param grammar the tested grammar\n\ +@returns true if L(@p grammar) = \\0"); } /* namespace properties */ diff --git a/alib2algo/src/grammar/properties/IsLanguageEmpty.h b/alib2algo/src/grammar/properties/IsLanguageEmpty.h index 95924c8a6ca11e666c241564be4de6cf08ddc464..1b8845c9f8aba9a0374950ddaa41c22c3be9865f 100644 --- a/alib2algo/src/grammar/properties/IsLanguageEmpty.h +++ b/alib2algo/src/grammar/properties/IsLanguageEmpty.h @@ -15,15 +15,20 @@ namespace grammar { namespace properties { /** - * Implements algorithms from Melichar, chapter 3.3 + * Based on algorithm 3.6 from Melichar, chapter 3.3 */ class IsLanguageEmpty { public: /* - * Melichar 3.6 - decides whether L( grammar ) = \0 + * Decides whether L( grammar ) = \0 * - * Severals steps implemented in method CFGTransformations::getProductiveNonTerminals(); - * @see getProductiveNonTerminals + * Severals steps implemented in method @see grammar::properties::ProductiveNonterminals::getProductiveNonTerminals(); + * + * \tparam T the type of the tested grammar + * + * \param grammar the tested grammar + * + * \returns true if L(@p grammar) = \0 */ template<class T> static bool isLanguageEmpty( const T & grammar ); diff --git a/alib2algo/src/grammar/properties/IsLanguageGeneratingEpsilon.cpp b/alib2algo/src/grammar/properties/IsLanguageGeneratingEpsilon.cpp index adccc6364eff28b80569f7848a6d776898cfedef..0486b39de300b7f8e56f1ed99cd95bb4244e59e5 100644 --- a/alib2algo/src/grammar/properties/IsLanguageGeneratingEpsilon.cpp +++ b/alib2algo/src/grammar/properties/IsLanguageGeneratingEpsilon.cpp @@ -22,15 +22,68 @@ namespace grammar { namespace properties { -auto IsLanguageGeneratingEpsilonCFG = registration::AbstractRegister < IsLanguageGeneratingEpsilon, bool, const grammar::CFG < > & > ( IsLanguageGeneratingEpsilon::isLanguageGeneratingEpsilon ); -auto IsLanguageGeneratingEpsilonEpsilonFreeCFG = registration::AbstractRegister < IsLanguageGeneratingEpsilon, bool, const grammar::EpsilonFreeCFG < > & > ( IsLanguageGeneratingEpsilon::isLanguageGeneratingEpsilon ); -auto IsLanguageGeneratingEpsilonGNF = registration::AbstractRegister < IsLanguageGeneratingEpsilon, bool, const grammar::GNF < > & > ( IsLanguageGeneratingEpsilon::isLanguageGeneratingEpsilon ); -auto IsLanguageGeneratingEpsilonCNF = registration::AbstractRegister < IsLanguageGeneratingEpsilon, bool, const grammar::CNF < > & > ( IsLanguageGeneratingEpsilon::isLanguageGeneratingEpsilon ); -auto IsLanguageGeneratingEpsilonLG = registration::AbstractRegister < IsLanguageGeneratingEpsilon, bool, const grammar::LG < > & > ( IsLanguageGeneratingEpsilon::isLanguageGeneratingEpsilon ); -auto IsLanguageGeneratingEpsilonLeftLG = registration::AbstractRegister < IsLanguageGeneratingEpsilon, bool, const grammar::LeftLG < > & > ( IsLanguageGeneratingEpsilon::isLanguageGeneratingEpsilon ); -auto IsLanguageGeneratingEpsilonLeftRG = registration::AbstractRegister < IsLanguageGeneratingEpsilon, bool, const grammar::LeftRG < > & > ( IsLanguageGeneratingEpsilon::isLanguageGeneratingEpsilon ); -auto IsLanguageGeneratingEpsilonRightLG = registration::AbstractRegister < IsLanguageGeneratingEpsilon, bool, const grammar::RightLG < > & > ( IsLanguageGeneratingEpsilon::isLanguageGeneratingEpsilon ); -auto IsLanguageGeneratingEpsilonRightRG = registration::AbstractRegister < IsLanguageGeneratingEpsilon, bool, const grammar::RightRG < > & > ( IsLanguageGeneratingEpsilon::isLanguageGeneratingEpsilon ); +auto IsLanguageGeneratingEpsilonCFG = registration::AbstractRegister < IsLanguageGeneratingEpsilon, bool, const grammar::CFG < > & > ( IsLanguageGeneratingEpsilon::isLanguageGeneratingEpsilon, "grammar" ).setDocumentation ( +"Decides whether \\e in L( grammar )\n\ +Severals steps implemented in method @see grammar::properties::NullableNonterminals::getNullableNonterminals();\n\ +\n\ +@param grammar the tested grammar\n\ +@returns true if \\e in L(@p grammar)" ); + +auto IsLanguageGeneratingEpsilonEpsilonFreeCFG = registration::AbstractRegister < IsLanguageGeneratingEpsilon, bool, const grammar::EpsilonFreeCFG < > & > ( IsLanguageGeneratingEpsilon::isLanguageGeneratingEpsilon, "grammar" ).setDocumentation ( +"Decides whether \\e in L( grammar )\n\ +Severals steps implemented in method @see grammar::properties::NullableNonterminals::getNullableNonterminals();\n\ +\n\ +@param grammar the tested grammar\n\ +@returns true if \\e in L(@p grammar)" ); + +auto IsLanguageGeneratingEpsilonGNF = registration::AbstractRegister < IsLanguageGeneratingEpsilon, bool, const grammar::GNF < > & > ( IsLanguageGeneratingEpsilon::isLanguageGeneratingEpsilon, "grammar" ).setDocumentation ( +"Decides whether \\e in L( grammar )\n\ +Severals steps implemented in method @see grammar::properties::NullableNonterminals::getNullableNonterminals();\n\ +\n\ +@param grammar the tested grammar\n\ +@returns true if \\e in L(@p grammar)" ); + +auto IsLanguageGeneratingEpsilonCNF = registration::AbstractRegister < IsLanguageGeneratingEpsilon, bool, const grammar::CNF < > & > ( IsLanguageGeneratingEpsilon::isLanguageGeneratingEpsilon, "grammar" ).setDocumentation ( +"Decides whether \\e in L( grammar )\n\ +Severals steps implemented in method @see grammar::properties::NullableNonterminals::getNullableNonterminals();\n\ +\n\ +@param grammar the tested grammar\n\ +@returns true if \\e in L(@p grammar)" ); + +auto IsLanguageGeneratingEpsilonLG = registration::AbstractRegister < IsLanguageGeneratingEpsilon, bool, const grammar::LG < > & > ( IsLanguageGeneratingEpsilon::isLanguageGeneratingEpsilon, "grammar" ).setDocumentation ( +"Decides whether \\e in L( grammar )\n\ +Severals steps implemented in method @see grammar::properties::NullableNonterminals::getNullableNonterminals();\n\ +\n\ +@param grammar the tested grammar\n\ +@returns true if \\e in L(@p grammar)" ); + +auto IsLanguageGeneratingEpsilonLeftLG = registration::AbstractRegister < IsLanguageGeneratingEpsilon, bool, const grammar::LeftLG < > & > ( IsLanguageGeneratingEpsilon::isLanguageGeneratingEpsilon, "grammar" ).setDocumentation ( +"Decides whether \\e in L( grammar )\n\ +Severals steps implemented in method @see grammar::properties::NullableNonterminals::getNullableNonterminals();\n\ +\n\ +@param grammar the tested grammar\n\ +@returns true if \\e in L(@p grammar)" ); + +auto IsLanguageGeneratingEpsilonLeftRG = registration::AbstractRegister < IsLanguageGeneratingEpsilon, bool, const grammar::LeftRG < > & > ( IsLanguageGeneratingEpsilon::isLanguageGeneratingEpsilon, "grammar" ).setDocumentation ( +"Decides whether \\e in L( grammar )\n\ +Severals steps implemented in method @see grammar::properties::NullableNonterminals::getNullableNonterminals();\n\ +\n\ +@param grammar the tested grammar\n\ +@returns true if \\e in L(@p grammar)" ); + +auto IsLanguageGeneratingEpsilonRightLG = registration::AbstractRegister < IsLanguageGeneratingEpsilon, bool, const grammar::RightLG < > & > ( IsLanguageGeneratingEpsilon::isLanguageGeneratingEpsilon, "grammar" ).setDocumentation ( +"Decides whether \\e in L( grammar )\n\ +Severals steps implemented in method @see grammar::properties::NullableNonterminals::getNullableNonterminals();\n\ +\n\ +@param grammar the tested grammar\n\ +@returns true if \\e in L(@p grammar)" ); + +auto IsLanguageGeneratingEpsilonRightRG = registration::AbstractRegister < IsLanguageGeneratingEpsilon, bool, const grammar::RightRG < > & > ( IsLanguageGeneratingEpsilon::isLanguageGeneratingEpsilon, "grammar" ).setDocumentation ( +"Decides whether \\e in L( grammar )\n\ +Severals steps implemented in method @see grammar::properties::NullableNonterminals::getNullableNonterminals();\n\ +\n\ +@param grammar the tested grammar\n\ +@returns true if \\e in L(@p grammar)" ); } /* namespace properties */ diff --git a/alib2algo/src/grammar/properties/IsLanguageGeneratingEpsilon.h b/alib2algo/src/grammar/properties/IsLanguageGeneratingEpsilon.h index 5f74204fedc0610c967b9730228f41f58d5c558e..d3b4314c054cd2c956d396ee04e17ac13dc75a4d 100644 --- a/alib2algo/src/grammar/properties/IsLanguageGeneratingEpsilon.h +++ b/alib2algo/src/grammar/properties/IsLanguageGeneratingEpsilon.h @@ -15,15 +15,20 @@ namespace grammar { namespace properties { /** - * Implements algorithms from Melichar, chapter 3.3 + * Based on algorithm 2.4 from Melichar, chapter 2.2 */ class IsLanguageGeneratingEpsilon { public: /* - * Melichar 3.6 - decides whether L( grammar ) = \0 + * Decides whether \e \in L( grammar ) * - * Severals steps implemented in method CFGTransformations::getProductiveNonTerminals(); - * @see getProductiveNonTerminals + * Severals steps implemented in method @see grammar::properties::NullableNonterminals::getNullableNonterminals(); + * + * \tparam T the type of the tested grammar + * + * \param grammar the tested grammar + * + * \returns true if \e \in L(@p grammar) */ template<class T> static bool isLanguageGeneratingEpsilon( const T & grammar ); diff --git a/alib2algo/src/grammar/properties/NonterminalUnitRuleCycle.cpp b/alib2algo/src/grammar/properties/NonterminalUnitRuleCycle.cpp index 9cc687c675c1a892def92a5e3cd6fb0729d5bb91..8deadec0f07482cd78c4b4c1df13e64183741a0e 100644 --- a/alib2algo/src/grammar/properties/NonterminalUnitRuleCycle.cpp +++ b/alib2algo/src/grammar/properties/NonterminalUnitRuleCycle.cpp @@ -22,15 +22,77 @@ namespace grammar { namespace properties { -auto NonterminalUnitRuleCycleCFG = registration::AbstractRegister < NonterminalUnitRuleCycle, ext::set < DefaultSymbolType >, const grammar::CFG < > &, const DefaultSymbolType & > ( NonterminalUnitRuleCycle::getNonterminalUnitRuleCycle ); -auto NonterminalUnitRuleCycleEpsilonFreeCFG = registration::AbstractRegister < NonterminalUnitRuleCycle, ext::set < DefaultSymbolType >, const grammar::EpsilonFreeCFG < > &, const DefaultSymbolType & > ( NonterminalUnitRuleCycle::getNonterminalUnitRuleCycle ); -auto NonterminalUnitRuleCycleGNF = registration::AbstractRegister < NonterminalUnitRuleCycle, ext::set < DefaultSymbolType >, const grammar::GNF < > &, const DefaultSymbolType & > ( NonterminalUnitRuleCycle::getNonterminalUnitRuleCycle ); -auto NonterminalUnitRuleCycleCNF = registration::AbstractRegister < NonterminalUnitRuleCycle, ext::set < DefaultSymbolType >, const grammar::CNF < > &, const DefaultSymbolType & > ( NonterminalUnitRuleCycle::getNonterminalUnitRuleCycle ); -auto NonterminalUnitRuleCycleLG = registration::AbstractRegister < NonterminalUnitRuleCycle, ext::set < DefaultSymbolType >, const grammar::LG < > &, const DefaultSymbolType & > ( NonterminalUnitRuleCycle::getNonterminalUnitRuleCycle ); -auto NonterminalUnitRuleCycleLeftLG = registration::AbstractRegister < NonterminalUnitRuleCycle, ext::set < DefaultSymbolType >, const grammar::LeftLG < > &, const DefaultSymbolType & > ( NonterminalUnitRuleCycle::getNonterminalUnitRuleCycle ); -auto NonterminalUnitRuleCycleLeftRG = registration::AbstractRegister < NonterminalUnitRuleCycle, ext::set < DefaultSymbolType >, const grammar::LeftRG < > &, const DefaultSymbolType & > ( NonterminalUnitRuleCycle::getNonterminalUnitRuleCycle ); -auto NonterminalUnitRuleCycleRightLG = registration::AbstractRegister < NonterminalUnitRuleCycle, ext::set < DefaultSymbolType >, const grammar::RightLG < > &, const DefaultSymbolType & > ( NonterminalUnitRuleCycle::getNonterminalUnitRuleCycle ); -auto NonterminalUnitRuleCycleRightRG = registration::AbstractRegister < NonterminalUnitRuleCycle, ext::set < DefaultSymbolType >, const grammar::RightRG < > &, const DefaultSymbolType & > ( NonterminalUnitRuleCycle::getNonterminalUnitRuleCycle ); +auto NonterminalUnitRuleCycleCFG = registration::AbstractRegister < NonterminalUnitRuleCycle, ext::set < DefaultSymbolType >, const grammar::CFG < > &, const DefaultSymbolType & > ( NonterminalUnitRuleCycle::getNonterminalUnitRuleCycle, "grammar", "nonterminal" ).setDocumentation ( +"Retrieves set N = {B : A->^* B} for given @p grammar and @p nonterminal.\n\ +Source: Melichar, algorithm 2.6, step 1\n\ +\n\ +@param grammar grammar\n\ +@param nonterminal nonterminal\n\ +@return set of nonterminals that can be derived from the given nonterminal in finite number of steps" ); + +auto NonterminalUnitRuleCycleEpsilonFreeCFG = registration::AbstractRegister < NonterminalUnitRuleCycle, ext::set < DefaultSymbolType >, const grammar::EpsilonFreeCFG < > &, const DefaultSymbolType & > ( NonterminalUnitRuleCycle::getNonterminalUnitRuleCycle, "grammar", "nonterminal" ).setDocumentation ( +"Retrieves set N = {B : A->^* B} for given @p grammar and @p nonterminal.\n\ +Source: Melichar, algorithm 2.6, step 1\n\ +\n\ +@param grammar grammar\n\ +@param nonterminal nonterminal\n\ +@return set of nonterminals that can be derived from the given nonterminal in finite number of steps" ); + +auto NonterminalUnitRuleCycleGNF = registration::AbstractRegister < NonterminalUnitRuleCycle, ext::set < DefaultSymbolType >, const grammar::GNF < > &, const DefaultSymbolType & > ( NonterminalUnitRuleCycle::getNonterminalUnitRuleCycle, "grammar", "nonterminal" ).setDocumentation ( +"Retrieves set N = {B : A->^* B} for given @p grammar and @p nonterminal.\n\ +Source: Melichar, algorithm 2.6, step 1\n\ +\n\ +@param grammar grammar\n\ +@param nonterminal nonterminal\n\ +@return set of nonterminals that can be derived from the given nonterminal in finite number of steps" ); + +auto NonterminalUnitRuleCycleCNF = registration::AbstractRegister < NonterminalUnitRuleCycle, ext::set < DefaultSymbolType >, const grammar::CNF < > &, const DefaultSymbolType & > ( NonterminalUnitRuleCycle::getNonterminalUnitRuleCycle, "grammar", "nonterminal" ).setDocumentation ( +"Retrieves set N = {B : A->^* B} for given @p grammar and @p nonterminal.\n\ +Source: Melichar, algorithm 2.6, step 1\n\ +\n\ +@param grammar grammar\n\ +@param nonterminal nonterminal\n\ +@return set of nonterminals that can be derived from the given nonterminal in finite number of steps" ); + +auto NonterminalUnitRuleCycleLG = registration::AbstractRegister < NonterminalUnitRuleCycle, ext::set < DefaultSymbolType >, const grammar::LG < > &, const DefaultSymbolType & > ( NonterminalUnitRuleCycle::getNonterminalUnitRuleCycle, "grammar", "nonterminal" ).setDocumentation ( +"Retrieves set N = {B : A->^* B} for given @p grammar and @p nonterminal.\n\ +Source: Melichar, algorithm 2.6, step 1\n\ +\n\ +@param grammar grammar\n\ +@param nonterminal nonterminal\n\ +@return set of nonterminals that can be derived from the given nonterminal in finite number of steps" ); + +auto NonterminalUnitRuleCycleLeftLG = registration::AbstractRegister < NonterminalUnitRuleCycle, ext::set < DefaultSymbolType >, const grammar::LeftLG < > &, const DefaultSymbolType & > ( NonterminalUnitRuleCycle::getNonterminalUnitRuleCycle, "grammar", "nonterminal" ).setDocumentation ( +"Retrieves set N = {B : A->^* B} for given @p grammar and @p nonterminal.\n\ +Source: Melichar, algorithm 2.6, step 1\n\ +\n\ +@param grammar grammar\n\ +@param nonterminal nonterminal\n\ +@return set of nonterminals that can be derived from the given nonterminal in finite number of steps" ); + +auto NonterminalUnitRuleCycleLeftRG = registration::AbstractRegister < NonterminalUnitRuleCycle, ext::set < DefaultSymbolType >, const grammar::LeftRG < > &, const DefaultSymbolType & > ( NonterminalUnitRuleCycle::getNonterminalUnitRuleCycle, "grammar", "nonterminal" ).setDocumentation ( +"Retrieves set N = {B : A->^* B} for given @p grammar and @p nonterminal.\n\ +Source: Melichar, algorithm 2.6, step 1\n\ +\n\ +@param grammar grammar\n\ +@param nonterminal nonterminal\n\ +@return set of nonterminals that can be derived from the given nonterminal in finite number of steps" ); + +auto NonterminalUnitRuleCycleRightLG = registration::AbstractRegister < NonterminalUnitRuleCycle, ext::set < DefaultSymbolType >, const grammar::RightLG < > &, const DefaultSymbolType & > ( NonterminalUnitRuleCycle::getNonterminalUnitRuleCycle, "grammar", "nonterminal" ).setDocumentation ( +"Retrieves set N = {B : A->^* B} for given @p grammar and @p nonterminal.\n\ +Source: Melichar, algorithm 2.6, step 1\n\ +\n\ +@param grammar grammar\n\ +@param nonterminal nonterminal\n\ +@return set of nonterminals that can be derived from the given nonterminal in finite number of steps" ); + +auto NonterminalUnitRuleCycleRightRG = registration::AbstractRegister < NonterminalUnitRuleCycle, ext::set < DefaultSymbolType >, const grammar::RightRG < > &, const DefaultSymbolType & > ( NonterminalUnitRuleCycle::getNonterminalUnitRuleCycle, "grammar", "nonterminal" ).setDocumentation ( +"Retrieves set N = {B : A->^* B} for given @p grammar and @p nonterminal.\n\ +Source: Melichar, algorithm 2.6, step 1\n\ +\n\ +@param grammar grammar\n\ +@param nonterminal nonterminal\n\ +@return set of nonterminals that can be derived from the given nonterminal in finite number of steps" ); } /* namespace properties */ diff --git a/alib2algo/src/grammar/properties/NonterminalUnitRuleCycle.h b/alib2algo/src/grammar/properties/NonterminalUnitRuleCycle.h index 9561f25272fa023a7d137fab67e718776a861c6b..b448d5586bd0718ea6a143cef6bdfd12270a193e 100644 --- a/alib2algo/src/grammar/properties/NonterminalUnitRuleCycle.h +++ b/alib2algo/src/grammar/properties/NonterminalUnitRuleCycle.h @@ -20,18 +20,21 @@ namespace grammar { namespace properties { /** - * Implements algorithms from Melichar, chapter 3.3 + * Implements algorithms from Melichar, chapter 2.2 */ class NonterminalUnitRuleCycle { public: /** - * Retrieves set N = {B : A->^* B} for given grammar and nonterminal + * Retrieves set N = {B : A->^* B} for given @p grammar and @p nonterminal * * Source: Melichar, algorithm 2.6, step 1 * - * @param grammar grammar - * @param nonterminal nonterminal - * @return set of nonterminals for which we can be derived from giveUnitRuleCyclen nonterminals in finite number of steps + * \tparam T the type of tested grammar + * \tparam NonterminalSymbolType the type of nonterminals in the tested grammar + * + * \param grammar grammar + * \param nonterminal nonterminal + * \return set of nonterminals that can be derived from the given nonterminal in finite number of steps */ template < class T, class NonterminalSymbolType > static ext::set < NonterminalSymbolType > getNonterminalUnitRuleCycle ( const T& grammar, const NonterminalSymbolType& nonterminal); @@ -59,11 +62,11 @@ ext::set<NonterminalSymbolType> NonterminalUnitRuleCycle::getNonterminalUnitRule Ni.at(i).insert(rhs.front().template get < NonterminalSymbolType > ( ) ); } } - } + ;} if(Ni.at(i) == Ni.at(i-1)) break; - + i += 1; } diff --git a/alib2algo/src/grammar/properties/NullableNonterminals.cpp b/alib2algo/src/grammar/properties/NullableNonterminals.cpp index dac4f6179205fa954e10f3d0e33cc7b34fec7ae6..e7e5c1d70cd9e444b2d31355dce885c7397f43d1 100644 --- a/alib2algo/src/grammar/properties/NullableNonterminals.cpp +++ b/alib2algo/src/grammar/properties/NullableNonterminals.cpp @@ -22,15 +22,77 @@ namespace grammar { namespace properties { -auto NullableNonterminalsCFG = registration::AbstractRegister < NullableNonterminals, ext::set < DefaultSymbolType >, const grammar::CFG < > & > ( NullableNonterminals::getNullableNonterminals ); -auto NullableNonterminalsEpsilonFreeCFG = registration::AbstractRegister < NullableNonterminals, ext::set < DefaultSymbolType >, const grammar::EpsilonFreeCFG < > & > ( NullableNonterminals::getNullableNonterminals ); -auto NullableNonterminalsGNF = registration::AbstractRegister < NullableNonterminals, ext::set < DefaultSymbolType >, const grammar::GNF < > & > ( NullableNonterminals::getNullableNonterminals ); -auto NullableNonterminalsCNF = registration::AbstractRegister < NullableNonterminals, ext::set < DefaultSymbolType >, const grammar::CNF < > & > ( NullableNonterminals::getNullableNonterminals ); -auto NullableNonterminalsLG = registration::AbstractRegister < NullableNonterminals, ext::set < DefaultSymbolType >, const grammar::LG < > & > ( NullableNonterminals::getNullableNonterminals ); -auto NullableNonterminalsLeftLG = registration::AbstractRegister < NullableNonterminals, ext::set < DefaultSymbolType >, const grammar::LeftLG < > & > ( NullableNonterminals::getNullableNonterminals ); -auto NullableNonterminalsLeftRG = registration::AbstractRegister < NullableNonterminals, ext::set < DefaultSymbolType >, const grammar::LeftRG < > & > ( NullableNonterminals::getNullableNonterminals ); -auto NullableNonterminalsRightLG = registration::AbstractRegister < NullableNonterminals, ext::set < DefaultSymbolType >, const grammar::RightLG < > & > ( NullableNonterminals::getNullableNonterminals ); -auto NullableNonterminalsRightRG = registration::AbstractRegister < NullableNonterminals, ext::set < DefaultSymbolType >, const grammar::RightRG < > & > ( NullableNonterminals::getNullableNonterminals ); +auto NullableNonterminalsCFG = registration::AbstractRegister < NullableNonterminals, ext::set < DefaultSymbolType >, const grammar::CFG < > & > ( NullableNonterminals::getNullableNonterminals, "grammar" ).setDocumentation ( +"Retrieve all nullable nonterminals from grammar\n\ +Nullable nonterminal is such nonterminal A for which holds that A ->^* \\eps\n\ +Source: Melichar, algorithm 2.4, step 1\n\ +\n\ +@param grammar the tested grammar\n\ +@return set of nullable nonterminals from the @p grammar"); + +auto NullableNonterminalsEpsilonFreeCFG = registration::AbstractRegister < NullableNonterminals, ext::set < DefaultSymbolType >, const grammar::EpsilonFreeCFG < > & > ( NullableNonterminals::getNullableNonterminals, "grammar" ).setDocumentation ( +"Retrieve all nullable nonterminals from grammar\n\ +Nullable nonterminal is such nonterminal A for which holds that A ->^* \\eps\n\ +Source: Melichar, algorithm 2.4, step 1\n\ +\n\ +@param grammar the tested grammar\n\ +@return set of nullable nonterminals from the @p grammar"); + +auto NullableNonterminalsGNF = registration::AbstractRegister < NullableNonterminals, ext::set < DefaultSymbolType >, const grammar::GNF < > & > ( NullableNonterminals::getNullableNonterminals, "grammar" ).setDocumentation ( +"Retrieve all nullable nonterminals from grammar\n\ +Nullable nonterminal is such nonterminal A for which holds that A ->^* \\eps\n\ +Source: Melichar, algorithm 2.4, step 1\n\ +\n\ +@param grammar the tested grammar\n\ +@return set of nullable nonterminals from the @p grammar"); + +auto NullableNonterminalsCNF = registration::AbstractRegister < NullableNonterminals, ext::set < DefaultSymbolType >, const grammar::CNF < > & > ( NullableNonterminals::getNullableNonterminals, "grammar" ).setDocumentation ( +"Retrieve all nullable nonterminals from grammar\n\ +Nullable nonterminal is such nonterminal A for which holds that A ->^* \\eps\n\ +Source: Melichar, algorithm 2.4, step 1\n\ +\n\ +@param grammar the tested grammar\n\ +@return set of nullable nonterminals from the @p grammar"); + +auto NullableNonterminalsLG = registration::AbstractRegister < NullableNonterminals, ext::set < DefaultSymbolType >, const grammar::LG < > & > ( NullableNonterminals::getNullableNonterminals, "grammar" ).setDocumentation ( +"Retrieve all nullable nonterminals from grammar\n\ +Nullable nonterminal is such nonterminal A for which holds that A ->^* \\eps\n\ +Source: Melichar, algorithm 2.4, step 1\n\ +\n\ +@param grammar the tested grammar\n\ +@return set of nullable nonterminals from the @p grammar"); + +auto NullableNonterminalsLeftLG = registration::AbstractRegister < NullableNonterminals, ext::set < DefaultSymbolType >, const grammar::LeftLG < > & > ( NullableNonterminals::getNullableNonterminals, "grammar" ).setDocumentation ( +"Retrieve all nullable nonterminals from grammar\n\ +Nullable nonterminal is such nonterminal A for which holds that A ->^* \\eps\n\ +Source: Melichar, algorithm 2.4, step 1\n\ +\n\ +@param grammar the tested grammar\n\ +@return set of nullable nonterminals from the @p grammar"); + +auto NullableNonterminalsLeftRG = registration::AbstractRegister < NullableNonterminals, ext::set < DefaultSymbolType >, const grammar::LeftRG < > & > ( NullableNonterminals::getNullableNonterminals, "grammar" ).setDocumentation ( +"Retrieve all nullable nonterminals from grammar\n\ +Nullable nonterminal is such nonterminal A for which holds that A ->^* \\eps\n\ +Source: Melichar, algorithm 2.4, step 1\n\ +\n\ +@param grammar the tested grammar\n\ +@return set of nullable nonterminals from the @p grammar"); + +auto NullableNonterminalsRightLG = registration::AbstractRegister < NullableNonterminals, ext::set < DefaultSymbolType >, const grammar::RightLG < > & > ( NullableNonterminals::getNullableNonterminals, "grammar" ).setDocumentation ( +"Retrieve all nullable nonterminals from grammar\n\ +Nullable nonterminal is such nonterminal A for which holds that A ->^* \\eps\n\ +Source: Melichar, algorithm 2.4, step 1\n\ +\n\ +@param grammar the tested grammar\n\ +@return set of nullable nonterminals from the @p grammar"); + +auto NullableNonterminalsRightRG = registration::AbstractRegister < NullableNonterminals, ext::set < DefaultSymbolType >, const grammar::RightRG < > & > ( NullableNonterminals::getNullableNonterminals, "grammar" ).setDocumentation ( +"Retrieve all nullable nonterminals from grammar\n\ +Nullable nonterminal is such nonterminal A for which holds that A ->^* \\eps\n\ +Source: Melichar, algorithm 2.4, step 1\n\ +\n\ +@param grammar the tested grammar\n\ +@return set of nullable nonterminals from the @p grammar"); } /* namespace properties */ diff --git a/alib2algo/src/grammar/properties/NullableNonterminals.h b/alib2algo/src/grammar/properties/NullableNonterminals.h index 3e047166500ac09063d2bef48e0db4eb32e84b86..920caf47cfc923dbb93d3f869402d5b46aa17db3 100644 --- a/alib2algo/src/grammar/properties/NullableNonterminals.h +++ b/alib2algo/src/grammar/properties/NullableNonterminals.h @@ -21,7 +21,7 @@ namespace grammar { namespace properties { /** - * Implements algorithms from Melichar, chapter 3.3 + * Implements algorithms from Melichar, chapter 2.2 */ class NullableNonterminals { public: @@ -31,8 +31,12 @@ public: * * Source: Melichar, algorithm 2.4, step 1 * - * @param grammar grammar - * @return set of nullable nonterminals from grammar + * \tparam T the type of the tested grammar + * \tparam TerminalSymbolType the type of terminals in the tested grammar + * \tparam NonterminalSymbolType the type of nonterminals in the tested grammar + * + * \param grammar the tested grammar + * \return set of nullable nonterminals from the @p grammar */ template<class T, class TerminalSymbolType = typename grammar::TerminalSymbolTypeOfGrammar < T >, class NonterminalSymbolType = typename grammar::NonterminalSymbolTypeOfGrammar < T > > static ext::set < NonterminalSymbolType > getNullableNonterminals ( const T & grammar ); diff --git a/alib2algo/src/grammar/properties/ProductiveNonterminals.cpp b/alib2algo/src/grammar/properties/ProductiveNonterminals.cpp index 38f8b325a73b95bf0dc750d8c0d2147196d67e61..dd510d9ca2465dedee40dea29162a7bbe0897643 100644 --- a/alib2algo/src/grammar/properties/ProductiveNonterminals.cpp +++ b/alib2algo/src/grammar/properties/ProductiveNonterminals.cpp @@ -22,15 +22,59 @@ namespace grammar { namespace properties { -auto ProductiveNonterminalsCFG = registration::AbstractRegister < ProductiveNonterminals, ext::set < DefaultSymbolType >, const grammar::CFG < > & > ( ProductiveNonterminals::getProductiveNonterminals ); -auto ProductiveNonterminalsEpsilonFreeCFG = registration::AbstractRegister < ProductiveNonterminals, ext::set < DefaultSymbolType >, const grammar::EpsilonFreeCFG < > & > ( ProductiveNonterminals::getProductiveNonterminals ); -auto ProductiveNonterminalsGNF = registration::AbstractRegister < ProductiveNonterminals, ext::set < DefaultSymbolType >, const grammar::GNF < > & > ( ProductiveNonterminals::getProductiveNonterminals ); -auto ProductiveNonterminalsCNF = registration::AbstractRegister < ProductiveNonterminals, ext::set < DefaultSymbolType >, const grammar::CNF < > & > ( ProductiveNonterminals::getProductiveNonterminals ); -auto ProductiveNonterminalsLG = registration::AbstractRegister < ProductiveNonterminals, ext::set < DefaultSymbolType >, const grammar::LG < > & > ( ProductiveNonterminals::getProductiveNonterminals ); -auto ProductiveNonterminalsLeftLG = registration::AbstractRegister < ProductiveNonterminals, ext::set < DefaultSymbolType >, const grammar::LeftLG < > & > ( ProductiveNonterminals::getProductiveNonterminals ); -auto ProductiveNonterminalsLeftRG = registration::AbstractRegister < ProductiveNonterminals, ext::set < DefaultSymbolType >, const grammar::LeftRG < > & > ( ProductiveNonterminals::getProductiveNonterminals ); -auto ProductiveNonterminalsRightLG = registration::AbstractRegister < ProductiveNonterminals, ext::set < DefaultSymbolType >, const grammar::RightLG < > & > ( ProductiveNonterminals::getProductiveNonterminals ); -auto ProductiveNonterminalsRightRG = registration::AbstractRegister < ProductiveNonterminals, ext::set < DefaultSymbolType >, const grammar::RightRG < > & > ( ProductiveNonterminals::getProductiveNonterminals ); +auto ProductiveNonterminalsCFG = registration::AbstractRegister < ProductiveNonterminals, ext::set < DefaultSymbolType >, const grammar::CFG < > & > ( ProductiveNonterminals::getProductiveNonterminals, "grammar" ).setDocumentation ( +"Retrieves set of nonterminals N = { A : A => T* }\n\ +\n\ +@param grammar the tested grammar\n\ +@returns set of nonterminals that can be rewriten to a sentence" ); + +auto ProductiveNonterminalsEpsilonFreeCFG = registration::AbstractRegister < ProductiveNonterminals, ext::set < DefaultSymbolType >, const grammar::EpsilonFreeCFG < > & > ( ProductiveNonterminals::getProductiveNonterminals, "grammar" ).setDocumentation ( +"Retrieves set of nonterminals N = { A : A => T* }\n\ +\n\ +@param grammar the tested grammar\n\ +@returns set of nonterminals that can be rewriten to a sentence" ); + +auto ProductiveNonterminalsGNF = registration::AbstractRegister < ProductiveNonterminals, ext::set < DefaultSymbolType >, const grammar::GNF < > & > ( ProductiveNonterminals::getProductiveNonterminals, "grammar" ).setDocumentation ( +"Retrieves set of nonterminals N = { A : A => T* }\n\ +\n\ +@param grammar the tested grammar\n\ +@returns set of nonterminals that can be rewriten to a sentence" ); + +auto ProductiveNonterminalsCNF = registration::AbstractRegister < ProductiveNonterminals, ext::set < DefaultSymbolType >, const grammar::CNF < > & > ( ProductiveNonterminals::getProductiveNonterminals, "grammar" ).setDocumentation ( +"Retrieves set of nonterminals N = { A : A => T* }\n\ +\n\ +@param grammar the tested grammar\n\ +@returns set of nonterminals that can be rewriten to a sentence" ); + +auto ProductiveNonterminalsLG = registration::AbstractRegister < ProductiveNonterminals, ext::set < DefaultSymbolType >, const grammar::LG < > & > ( ProductiveNonterminals::getProductiveNonterminals, "grammar" ).setDocumentation ( +"Retrieves set of nonterminals N = { A : A => T* }\n\ +\n\ +@param grammar the tested grammar\n\ +@returns set of nonterminals that can be rewriten to a sentence" ); + +auto ProductiveNonterminalsLeftLG = registration::AbstractRegister < ProductiveNonterminals, ext::set < DefaultSymbolType >, const grammar::LeftLG < > & > ( ProductiveNonterminals::getProductiveNonterminals, "grammar" ).setDocumentation ( +"Retrieves set of nonterminals N = { A : A => T* }\n\ +\n\ +@param grammar the tested grammar\n\ +@returns set of nonterminals that can be rewriten to a sentence" ); + +auto ProductiveNonterminalsLeftRG = registration::AbstractRegister < ProductiveNonterminals, ext::set < DefaultSymbolType >, const grammar::LeftRG < > & > ( ProductiveNonterminals::getProductiveNonterminals, "grammar" ).setDocumentation ( +"Retrieves set of nonterminals N = { A : A => T* }\n\ +\n\ +@param grammar the tested grammar\n\ +@returns set of nonterminals that can be rewriten to a sentence" ); + +auto ProductiveNonterminalsRightLG = registration::AbstractRegister < ProductiveNonterminals, ext::set < DefaultSymbolType >, const grammar::RightLG < > & > ( ProductiveNonterminals::getProductiveNonterminals, "grammar" ).setDocumentation ( +"Retrieves set of nonterminals N = { A : A => T* }\n\ +\n\ +@param grammar the tested grammar\n\ +@returns set of nonterminals that can be rewriten to a sentence" ); + +auto ProductiveNonterminalsRightRG = registration::AbstractRegister < ProductiveNonterminals, ext::set < DefaultSymbolType >, const grammar::RightRG < > & > ( ProductiveNonterminals::getProductiveNonterminals, "grammar" ).setDocumentation ( +"Retrieves set of nonterminals N = { A : A => T* }\n\ +\n\ +@param grammar the tested grammar\n\ +@returns set of nonterminals that can be rewriten to a sentence" ); } /* namespace properties */ diff --git a/alib2algo/src/grammar/properties/ProductiveNonterminals.h b/alib2algo/src/grammar/properties/ProductiveNonterminals.h index d08868500661d28f0d09bd166859a87bbfffed16..36fdaf3d7c7b6bc8e97d4c96c0535b946a34d2a4 100644 --- a/alib2algo/src/grammar/properties/ProductiveNonterminals.h +++ b/alib2algo/src/grammar/properties/ProductiveNonterminals.h @@ -25,8 +25,16 @@ namespace properties { */ class ProductiveNonterminals { public: - /** - * Implements steps 1 through 3 in Melichar 3.6 + /* + * Retrieves set of nonterminals N = { A : A => T* } + * + * \tparam T the type of the tested grammar + * \tparam TerminalSymbolType the type of terminal symbols in the tested grammar + * \tparam NonterminalSymbolType the type of nonterminal symbols in the tested grammar + * + * \param grammar the tested grammar + * + * \returns set of nonterminals that can be rewriten to a sentence */ template<class T, class TerminalSymbolType = typename grammar::TerminalSymbolTypeOfGrammar < T >, class NonterminalSymbolType = typename grammar::NonterminalSymbolTypeOfGrammar < T > > static ext::set < NonterminalSymbolType > getProductiveNonterminals ( const T & grammar ); diff --git a/alib2algo/src/grammar/properties/RecursiveNonterminal.cpp b/alib2algo/src/grammar/properties/RecursiveNonterminal.cpp index e3595a7f4aed86d4b2ec89dc300bc2ac92657b10..40332f12e5fa94f284be77ef52e99e37a52e1fce 100644 --- a/alib2algo/src/grammar/properties/RecursiveNonterminal.cpp +++ b/alib2algo/src/grammar/properties/RecursiveNonterminal.cpp @@ -22,15 +22,68 @@ namespace grammar { namespace properties { -auto RecursiveNonterminalCFG = registration::AbstractRegister < RecursiveNonterminal, bool, const grammar::CFG < > &, const DefaultSymbolType & > ( RecursiveNonterminal::isNonterminalRecursive ); -auto RecursiveNonterminalEpsilonFreeCFG = registration::AbstractRegister < RecursiveNonterminal, bool, const grammar::EpsilonFreeCFG < > &, const DefaultSymbolType & > ( RecursiveNonterminal::isNonterminalRecursive ); -auto RecursiveNonterminalGNF = registration::AbstractRegister < RecursiveNonterminal, bool, const grammar::GNF < > &, const DefaultSymbolType & > ( RecursiveNonterminal::isNonterminalRecursive ); -auto RecursiveNonterminalCNF = registration::AbstractRegister < RecursiveNonterminal, bool, const grammar::CNF < > &, const DefaultSymbolType & > ( RecursiveNonterminal::isNonterminalRecursive ); -auto RecursiveNonterminalLG = registration::AbstractRegister < RecursiveNonterminal, bool, const grammar::LG < > &, const DefaultSymbolType & > ( RecursiveNonterminal::isNonterminalRecursive ); -auto RecursiveNonterminalLeftLG = registration::AbstractRegister < RecursiveNonterminal, bool, const grammar::LeftLG < > &, const DefaultSymbolType & > ( RecursiveNonterminal::isNonterminalRecursive ); -auto RecursiveNonterminalLeftRG = registration::AbstractRegister < RecursiveNonterminal, bool, const grammar::LeftRG < > &, const DefaultSymbolType & > ( RecursiveNonterminal::isNonterminalRecursive ); -auto RecursiveNonterminalRightLG = registration::AbstractRegister < RecursiveNonterminal, bool, const grammar::RightLG < > &, const DefaultSymbolType & > ( RecursiveNonterminal::isNonterminalRecursive ); -auto RecursiveNonterminalRightRG = registration::AbstractRegister < RecursiveNonterminal, bool, const grammar::RightRG < > &, const DefaultSymbolType & > ( RecursiveNonterminal::isNonterminalRecursive ); +auto RecursiveNonterminalCFG = registration::AbstractRegister < RecursiveNonterminal, bool, const grammar::CFG < > &, const DefaultSymbolType & > ( RecursiveNonterminal::isNonterminalRecursive, "grammar", "nonterminal" ).setDocumentation ( +"Retrieves A \\in { B : A->^+ B \\alpha, where \\alpha \\in (NuT)* } for given grammar and nonterminal\n\ +\n\ +@param grammar the tested grammar\n\ +@param nonterminal the tested nonterminal\n\ +@return bool which denote whether the nonterminal is recursive in the grammar" ); + +auto RecursiveNonterminalEpsilonFreeCFG = registration::AbstractRegister < RecursiveNonterminal, bool, const grammar::EpsilonFreeCFG < > &, const DefaultSymbolType & > ( RecursiveNonterminal::isNonterminalRecursive, "grammar", "nonterminal" ).setDocumentation ( +"Retrieves A \\in { B : A->^+ B \\alpha, where \\alpha \\in (NuT)* } for given grammar and nonterminal\n\ +\n\ +@param grammar the tested grammar\n\ +@param nonterminal the tested nonterminal\n\ +@return bool which denote whether the nonterminal is recursive in the grammar" ); + +auto RecursiveNonterminalGNF = registration::AbstractRegister < RecursiveNonterminal, bool, const grammar::GNF < > &, const DefaultSymbolType & > ( RecursiveNonterminal::isNonterminalRecursive, "grammar", "nonterminal" ).setDocumentation ( +"Retrieves A \\in { B : A->^+ B \\alpha, where \\alpha \\in (NuT)* } for given grammar and nonterminal\n\ +\n\ +@param grammar the tested grammar\n\ +@param nonterminal the tested nonterminal\n\ +@return bool which denote whether the nonterminal is recursive in the grammar" ); + +auto RecursiveNonterminalCNF = registration::AbstractRegister < RecursiveNonterminal, bool, const grammar::CNF < > &, const DefaultSymbolType & > ( RecursiveNonterminal::isNonterminalRecursive, "grammar", "nonterminal" ).setDocumentation ( +"Retrieves A \\in { B : A->^+ B \\alpha, where \\alpha \\in (NuT)* } for given grammar and nonterminal\n\ +\n\ +@param grammar the tested grammar\n\ +@param nonterminal the tested nonterminal\n\ +@return bool which denote whether the nonterminal is recursive in the grammar" ); + +auto RecursiveNonterminalLG = registration::AbstractRegister < RecursiveNonterminal, bool, const grammar::LG < > &, const DefaultSymbolType & > ( RecursiveNonterminal::isNonterminalRecursive, "grammar", "nonterminal" ).setDocumentation ( +"Retrieves A \\in { B : A->^+ B \\alpha, where \\alpha \\in (NuT)* } for given grammar and nonterminal\n\ +\n\ +@param grammar the tested grammar\n\ +@param nonterminal the tested nonterminal\n\ +@return bool which denote whether the nonterminal is recursive in the grammar" ); + +auto RecursiveNonterminalLeftLG = registration::AbstractRegister < RecursiveNonterminal, bool, const grammar::LeftLG < > &, const DefaultSymbolType & > ( RecursiveNonterminal::isNonterminalRecursive, "grammar", "nonterminal" ).setDocumentation ( +"Retrieves A \\in { B : A->^+ B \\alpha, where \\alpha \\in (NuT)* } for given grammar and nonterminal\n\ +\n\ +@param grammar the tested grammar\n\ +@param nonterminal the tested nonterminal\n\ +@return bool which denote whether the nonterminal is recursive in the grammar" ); + +auto RecursiveNonterminalLeftRG = registration::AbstractRegister < RecursiveNonterminal, bool, const grammar::LeftRG < > &, const DefaultSymbolType & > ( RecursiveNonterminal::isNonterminalRecursive, "grammar", "nonterminal" ).setDocumentation ( +"Retrieves A \\in { B : A->^+ B \\alpha, where \\alpha \\in (NuT)* } for given grammar and nonterminal\n\ +\n\ +@param grammar the tested grammar\n\ +@param nonterminal the tested nonterminal\n\ +@return bool which denote whether the nonterminal is recursive in the grammar" ); + +auto RecursiveNonterminalRightLG = registration::AbstractRegister < RecursiveNonterminal, bool, const grammar::RightLG < > &, const DefaultSymbolType & > ( RecursiveNonterminal::isNonterminalRecursive, "grammar", "nonterminal" ).setDocumentation ( +"Retrieves A \\in { B : A->^+ B \\alpha, where \\alpha \\in (NuT)* } for given grammar and nonterminal\n\ +\n\ +@param grammar the tested grammar\n\ +@param nonterminal the tested nonterminal\n\ +@return bool which denote whether the nonterminal is recursive in the grammar" ); + +auto RecursiveNonterminalRightRG = registration::AbstractRegister < RecursiveNonterminal, bool, const grammar::RightRG < > &, const DefaultSymbolType & > ( RecursiveNonterminal::isNonterminalRecursive, "grammar", "nonterminal" ).setDocumentation ( +"Retrieves A \\in { B : A->^+ B \\alpha, where \\alpha \\in (NuT)* } for given grammar and nonterminal\n\ +\n\ +@param grammar the tested grammar\n\ +@param nonterminal the tested nonterminal\n\ +@return bool which denote whether the nonterminal is recursive in the grammar" ); } /* namespace properties */ diff --git a/alib2algo/src/grammar/properties/RecursiveNonterminal.h b/alib2algo/src/grammar/properties/RecursiveNonterminal.h index 3c3ac531e56311f0e8e17ed3b02f4534ab07120b..6e20bcb6787c17cfcd6f6b4741d2408c7a3e79ce 100644 --- a/alib2algo/src/grammar/properties/RecursiveNonterminal.h +++ b/alib2algo/src/grammar/properties/RecursiveNonterminal.h @@ -29,9 +29,14 @@ public: /** * Retrieves A \in { B : A->^+ B \alpha, where \alpha \in (NuT)* } for given grammar and nonterminal * - * @param grammar grammar - * @param nonterminal nonterminal - * @return bool which denote whether the nonterminal is recursive in the grammar + * \tparam T the type of the tested grammar + * \tparam NonterminalSymbolType the type of nonterminals in the tested grammar + * \tparam TerminalSymbolType the type of terminals in the tested grammar + * + * \param grammar the tested grammar + * \param nonterminal the tested nonterminal + * + * \return bool which denote whether the nonterminal is recursive in the grammar */ template < class T, class NonterminalSymbolType, class TerminalSymbolType = typename grammar::TerminalSymbolTypeOfGrammar < T > > static bool isNonterminalRecursive ( const T & grammar, const NonterminalSymbolType & nonterminal );