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

add user documentation to grammar generate

parent b5d9021b
No related branches found
No related tags found
1 merge request!57Dev
......@@ -12,7 +12,13 @@ namespace grammar {
 
namespace generate {
 
auto GenerateCFG1 = registration::AbstractRegister < RandomGrammarFactory, grammar::CFG < >, ext::set < DefaultSymbolType >, ext::set < DefaultSymbolType >, double > ( RandomGrammarFactory::generateCFG, abstraction::AlgorithmCategories::AlgorithmCategory::DEFAULT, "nonterminals", "terminals", "density" );
auto GenerateCFG1 = registration::AbstractRegister < RandomGrammarFactory, grammar::CFG < >, ext::set < DefaultSymbolType >, ext::set < DefaultSymbolType >, double > ( RandomGrammarFactory::generateCFG, abstraction::AlgorithmCategories::AlgorithmCategory::DEFAULT, "nonterminals", "terminals", "density" ).setDocumentation (
"Generates a random context free grammar.\n\
\n\
@param nonterminals the nonterminals in the generated grammar\n\
@param terminals the terminals in the generated grammar\n\
@param density density of the rule set of the generated grammar\n\
@return random context free grammar" );
 
grammar::CFG < std::string, std::string > RandomGrammarFactory::generateCFG ( size_t nonterminalsCount, size_t terminalsCount, bool randomizedAlphabet, double density ) {
if(terminalsCount > 26)
......@@ -42,7 +48,15 @@ grammar::CFG < std::string, std::string > RandomGrammarFactory::generateCFG ( si
return RandomGrammarFactory::randomCFG ( nonterminals, terminals, density );
}
 
auto GenerateCFG2 = registration::AbstractRegister < RandomGrammarFactory, grammar::CFG < std::string, std::string >, size_t, size_t, bool, double> ( RandomGrammarFactory::generateCFG, abstraction::AlgorithmCategories::AlgorithmCategory::DEFAULT, "nonterminalsCount", "terminalsCount", "randomizedAlphabet", "density" );
auto GenerateCFG2 = registration::AbstractRegister < RandomGrammarFactory, grammar::CFG < std::string, std::string >, size_t, size_t, bool, double> ( RandomGrammarFactory::generateCFG, abstraction::AlgorithmCategories::AlgorithmCategory::DEFAULT, "nonterminalsCount", "terminalsCount", "randomizedAlphabet", "density" ).setDocumentation (
"Generates a random context free grammar.\n\
\n\
@param nonterminalsCount number of nonterminals in the generated grammar\n\
@param terminalsSize the number of terminals used in the generated grammar\n\
@param randomizedAlphabet selects random symbols from a-z range for terminal and A-Z for nonterminal alphabet if true\n\
@param density density of the rule set of the generated grammar\n\
@return random context free grammar" );
 
} /* namespace generate */
 
......
......@@ -24,8 +24,34 @@ namespace generate {
 
class RandomGrammarFactory {
public:
/**
* Generates a random context free grammar.
*
* \tparam TerminalSymbolType the type of terminal symbols of the random grammar
* \tparam NonterminalSymbolType the type of nonterminal symbols of the random grammar
*
* \param nonterminals the nonterminals in the generated grammar
* \param terminals the terminals in the generated grammar
* \param density density of the rule set of the generated grammar
*
* \return random context free grammar
*/
template < class TerminalSymbolType, class NonterminalSymbolType >
static grammar::CFG < TerminalSymbolType, NonterminalSymbolType > generateCFG ( ext::set < NonterminalSymbolType > nonterminals, ext::set < TerminalSymbolType > terminals, double density );
/**
* Generates a random context free grammar.
*
* \tparam TerminalSymbolType the type of terminal symbols of the random grammar
* \tparam NonterminalSymbolType the type of nonterminal symbols of the random grammar
*
* \param nonterminalsCount number of nonterminals in the generated grammar
* \param terminalsSize the number of terminals used in the generated grammar
* \param randomizedAlphabet selects random symbols from a-z range for terminal and A-Z for nonterminal alphabet if true
* \param density density of the rule set of the generated grammar
*
* \return random context free grammar
*/
static grammar::CFG < std::string, std::string > generateCFG( size_t nonterminalsCount, size_t terminalsSize, bool randomizedAlphabet, double density );
 
private:
......
......@@ -12,11 +12,35 @@ namespace grammar {
 
namespace generate {
 
auto RandomizeGrammarLeftRG = registration::AbstractRegister < RandomizeGrammar, grammar::LeftRG < >, const grammar::LeftRG < > & > ( RandomizeGrammar::randomize );
auto RandomizeGrammarLeftLG = registration::AbstractRegister < RandomizeGrammar, grammar::LeftLG < >, const grammar::LeftLG < > & > ( RandomizeGrammar::randomize );
auto RandomizeGrammarRightRG = registration::AbstractRegister < RandomizeGrammar, grammar::RightRG < >, const grammar::RightRG < > & > ( RandomizeGrammar::randomize );
auto RandomizeGrammarRightLG = registration::AbstractRegister < RandomizeGrammar, grammar::RightLG < >, const grammar::RightLG < > & > ( RandomizeGrammar::randomize );
auto RandomizeGrammarCFG = registration::AbstractRegister < RandomizeGrammar, grammar::CFG < >, const grammar::CFG < > & > ( RandomizeGrammar::randomize );
auto RandomizeGrammarLeftRG = registration::AbstractRegister < RandomizeGrammar, grammar::LeftRG < >, const grammar::LeftRG < > & > ( RandomizeGrammar::randomize, "gram" ).setDocumentation (
"Shuffle the set of nonterminal symbols.\n\
\n\
@param gram the grammar to shuffle\n\
@return grammar with shuffled nonterminal symbols" );
auto RandomizeGrammarLeftLG = registration::AbstractRegister < RandomizeGrammar, grammar::LeftLG < >, const grammar::LeftLG < > & > ( RandomizeGrammar::randomize, "gram" ).setDocumentation (
"Shuffle the set of nonterminal symbols.\n\
\n\
@param gram the grammar to shuffle\n\
@return grammar with shuffled nonterminal symbols" );
auto RandomizeGrammarRightRG = registration::AbstractRegister < RandomizeGrammar, grammar::RightRG < >, const grammar::RightRG < > & > ( RandomizeGrammar::randomize, "gram" ).setDocumentation (
"Shuffle the set of nonterminal symbols.\n\
\n\
@param gram the grammar to shuffle\n\
@return grammar with shuffled nonterminal symbols" );
auto RandomizeGrammarRightLG = registration::AbstractRegister < RandomizeGrammar, grammar::RightLG < >, const grammar::RightLG < > & > ( RandomizeGrammar::randomize, "gram" ).setDocumentation (
"Shuffle the set of nonterminal symbols.\n\
\n\
@param gram the grammar to shuffle\n\
@return grammar with shuffled nonterminal symbols" );
auto RandomizeGrammarCFG = registration::AbstractRegister < RandomizeGrammar, grammar::CFG < >, const grammar::CFG < > & > ( RandomizeGrammar::randomize, "gram" ).setDocumentation (
"Shuffle the set of nonterminal symbols.\n\
\n\
@param gram the grammar to shuffle\n\
@return grammar with shuffled nonterminal symbols" );
 
} /* namespace generate */
 
......
......@@ -22,14 +22,40 @@ namespace generate {
 
class RandomizeGrammar {
public:
/**
* Shuffle the set of nonterminal symbols.
*
* \tparam TerminalSymbolType the type of terminal symbols of the random grammar
* \tparam NonterminalSymbolType the type of nonterminal symbols of the random grammar
*
* \param gram the grammar to shuffle
*
* \return grammar with shuffled nonterminal symbols
*/
template < class TerminalSymbolType, class NonterminalSymbolType >
static grammar::LeftRG < TerminalSymbolType, NonterminalSymbolType > randomize ( const grammar::LeftRG < TerminalSymbolType, NonterminalSymbolType > & gram );
/**
* \override
*/
template < class TerminalSymbolType, class NonterminalSymbolType >
static grammar::LeftLG < TerminalSymbolType, NonterminalSymbolType > randomize ( const grammar::LeftLG < TerminalSymbolType, NonterminalSymbolType > & gram );
/**
* \override
*/
template < class TerminalSymbolType, class NonterminalSymbolType >
static grammar::RightRG < TerminalSymbolType, NonterminalSymbolType > randomize ( const grammar::RightRG < TerminalSymbolType, NonterminalSymbolType > & gram );
/**
* \override
*/
template < class TerminalSymbolType, class NonterminalSymbolType >
static grammar::RightLG < TerminalSymbolType, NonterminalSymbolType > randomize ( const grammar::RightLG < TerminalSymbolType, NonterminalSymbolType > & gram );
/**
* \override
*/
template < class TerminalSymbolType, class NonterminalSymbolType >
static grammar::CFG < TerminalSymbolType, NonterminalSymbolType > randomize ( const grammar::CFG < TerminalSymbolType, NonterminalSymbolType > & gram );
 
......
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