10#include <ext/algorithm>
38 template <
class TerminalSymbolType,
class NonterminalSymbolType >
57 template <
class TerminalSymbolType,
class NonterminalSymbolType >
61template <
class TerminalSymbolType,
class NonterminalSymbolType >
65 return RandomGrammarFactory::randomCFG ( nonterminals2, terminals2, density );
68template <
class TerminalSymbolType,
class NonterminalSymbolType >
70 if( terminals.empty ( ) )
73 if( nonterminals.empty ( ) )
78 grammar.setNonterminalAlphabet({nonterminals.
begin(), nonterminals.
end()});
84 while(rules < terminals.size() * nonterminals.size() * density / 100) {
89 int nonterminalsOnRHS = 0;
90 for(
int i = 0;
i < rhsSize;
i++) {
98 rules += nonterminalsOnRHS;
Basic exception from which all other exceptions are derived.
Definition: CommonException.h:21
Class extending the deque class from the standard library. Original reason is to allow printing of th...
Definition: deque.hpp:44
auto begin() &
Inherited behavior of begin for non-const instance.
Definition: deque.hpp:100
auto end() &
Inherited behavior of end for non-const instance.
Definition: deque.hpp:130
static semirandom_device & semirandom
The reference to singleton semirandom device.
Definition: random.hpp:147
auto begin() &
Inherited behavior of begin for non-const instance.
Definition: set.hpp:99
auto end() &
Inherited behavior of end for non-const instance.
Definition: set.hpp:129
Implementation of the variant class allowing to store any type of those listed in the template parame...
Definition: variant.hpp:98
Class extending the vector class from the standard library. Original reason is to allow printing of t...
Definition: vector.hpp:45
Context free grammar in Chomsky hierarchy or type 2 in Chomsky hierarchy. Generates context free lang...
Definition: CFG.h:67
Definition: RandomGrammarFactory.h:24
static grammar::CFG< TerminalSymbolType, NonterminalSymbolType > generateCFG(ext::set< NonterminalSymbolType > nonterminals, ext::set< TerminalSymbolType > terminals, double density)
Definition: RandomGrammarFactory.h:62
return grammar
Definition: ToGrammarLeftRG.h:99
int i
Definition: AllEpsilonClosure.h:118
Definition: ToAutomaton.h:24