Skip to content
Snippets Groups Projects
Commit 2165059b authored by Jan Trávníček's avatar Jan Trávníček
Browse files

user documentation of some grammar properties algos

parent 9bc7da1f
No related branches found
No related tags found
1 merge request!57Dev
Showing
with 443 additions and 77 deletions
......@@ -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 */
 
......
......@@ -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 );
......
......@@ -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 */
 
......
......@@ -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 );
......
......@@ -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 */
 
......
......@@ -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;
}
 
......
......@@ -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 */
 
......
......@@ -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 );
......
......@@ -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 */
 
......
......@@ -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 );
......
......@@ -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 */
 
......
......@@ -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 );
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment