8#include <ext/algorithm>
37 template <
class TerminalSymbolType,
class NonterminalSymbolType >
39 template <
class TerminalSymbolType,
class NonterminalSymbolType >
53 template <
class TerminalSymbolType,
class NonterminalSymbolType >
66 template <
class TerminalSymbolType,
class NonterminalSymbolType >
79 template <
class TerminalSymbolType,
class NonterminalSymbolType >
92 template <
class TerminalSymbolType,
class NonterminalSymbolType >
105 template <
class TerminalSymbolType,
class NonterminalSymbolType >
118 template <
class TerminalSymbolType,
class NonterminalSymbolType >
131 template <
class TerminalSymbolType,
class NonterminalSymbolType >
144 template <
class TerminalSymbolType,
class NonterminalSymbolType >
157 template <
class TerminalSymbolType,
class NonterminalSymbolType >
161template <
class TerminalSymbolType,
class NonterminalSymbolType >
164 res.setNonterminalAlphabet(
grammar.getNonterminalAlphabet());
165 res.setTerminalAlphabet(
grammar.getTerminalAlphabet());
166 res.setGeneratesEpsilon(
grammar.getGeneratesEpsilon());
170 if(
res.getTerminalAlphabet().count(singleRHS[0])) {
171 res.addRule(rule.first, singleRHS);
175 if(
grammar.getRules().find(secondLHS) ==
grammar.getRules().end()) {
182 newRHS.insert(newRHS.end(), singleRHS.begin() + 1, singleRHS.end());
183 res.addRule(rule.first, newRHS);
190template <
class TerminalSymbolType,
class NonterminalSymbolType >
196 if(step == nextStep)
break;
197 step = std::move(nextStep);
201 res.setTerminalAlphabet(step.getTerminalAlphabet());
202 for (
const NonterminalSymbolType & nonterminal : step.getNonterminalAlphabet ( ) )
204 res.setGeneratesEpsilon(step.getGeneratesEpsilon());
206 for (
const TerminalSymbolType & terminal : step.getTerminalAlphabet ( ) ) {
209 res.addNonterminalSymbol(primed);
212 for(
const auto& rule : step.getRules()) {
213 for(
const auto& rhs : rule.second) {
222 if(
res.getNonterminalAlphabet().count(rhsSymbol))
223 convertedNonterminals.push_back(rhsSymbol);
225 convertedNonterminals.push_back(terminalToPrimed.find(rhsSymbol)->second);
227 res.addRule(rule.first,
ext::make_pair(rhs[0].template get < TerminalSymbolType > ( ), std::move(convertedNonterminals)));
233template <
class TerminalSymbolType,
class NonterminalSymbolType >
238template <
class TerminalSymbolType,
class NonterminalSymbolType >
243template <
class TerminalSymbolType,
class NonterminalSymbolType >
248template <
class TerminalSymbolType,
class NonterminalSymbolType >
253template <
class TerminalSymbolType,
class NonterminalSymbolType >
258template <
class TerminalSymbolType,
class NonterminalSymbolType >
263template <
class TerminalSymbolType,
class NonterminalSymbolType >
268template <
class TerminalSymbolType,
class NonterminalSymbolType >
273template <
class TerminalSymbolType,
class NonterminalSymbolType >
Class extending the map class from the standard library. Original reason is to allow printing of the ...
Definition: map.hpp:48
std::pair< iterator, bool > insert(const T &key, const R &value)
Insert variant with explicit key and value parameters.
Definition: map.hpp:118
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
Chomsky normal form of a context free grammar in Chomsky hierarchy or type 2 in Chomsky hierarchy....
Definition: CNF.h:66
Context free grammar without epsilon rules in Chomsky hierarchy or type 2 in Chomsky hierarchy....
Definition: EpsilonFreeCFG.h:65
Greibach normal form of a context free grammar in Chomsky hierarchy or type 2 in Chomsky hierarchy....
Definition: GNF.h:65
Context free grammar in Chomsky hierarchy or type 2 in Chomsky hierarchy. Generates context free lang...
Definition: LG.h:67
Left linear grammar in Chomsky hierarchy or type 3 in Chomsky hierarchy. Generates regular languages.
Definition: LeftLG.h:66
Left regular grammar in Chomsky hierarchy or type 3 in Chomsky hierarchy. Generates regular languages...
Definition: LeftRG.h:70
Right linear grammar in Chomsky hierarchy or type 3 in Chomsky hierarchy. Generates regular languages...
Definition: RightLG.h:65
Right regular grammar in Chomsky hierarchy or type 3 in Chomsky hierarchy. Generates regular language...
Definition: RightRG.h:70
static grammar::RightRG< TerminalSymbolType, NonterminalSymbolType > convert(const grammar::LeftRG< TerminalSymbolType, NonterminalSymbolType > &grammar)
Definition: ToGrammarRightRG.h:37
static grammar::EpsilonFreeCFG< TerminalSymbolType, NonterminalSymbolType > remove(const grammar::CFG< TerminalSymbolType, NonterminalSymbolType > &grammar)
Definition: EpsilonRemover.h:202
static grammar::EpsilonFreeCFG< TerminalSymbolType, NonterminalSymbolType > remove(const grammar::EpsilonFreeCFG< TerminalSymbolType, NonterminalSymbolType > &grammar)
Definition: LeftRecursionRemover.h:225
static grammar::CFG< TerminalSymbolType, NonterminalSymbolType > remove(const grammar::CFG< TerminalSymbolType, NonterminalSymbolType > &grammar)
Definition: SimpleRulesRemover.h:181
static grammar::GNF< TerminalSymbolType, ext::variant< TerminalSymbolType, NonterminalSymbolType > > convert(const grammar::CFG< TerminalSymbolType, NonterminalSymbolType > &grammar)
Definition: ToGNF.h:234
return grammar
Definition: ToGrammarLeftRG.h:99
return res
Definition: MinimizeByPartitioning.h:145
T createUnique(T object, const Alphabets &... alphabets)
Definition: createUnique.hpp:46
constexpr auto make_pair(T1 &&x, T2 &&y)
Definition: pair.hpp:79
Definition: ToAutomaton.h:24