39 template <
class TerminalSymbolType,
class NonterminalSymbolType >
45 template <
class TerminalSymbolType,
class NonterminalSymbolType >
51 template <
class TerminalSymbolType,
class NonterminalSymbolType >
57 template <
class TerminalSymbolType,
class NonterminalSymbolType >
63 template <
class TerminalSymbolType,
class NonterminalSymbolType >
69 template <
class TerminalSymbolType,
class NonterminalSymbolType >
75 template <
class TerminalSymbolType,
class NonterminalSymbolType >
81 template <
class TerminalSymbolType,
class NonterminalSymbolType >
87 template <
class TerminalSymbolType,
class NonterminalSymbolType >
91template <
class TerminalSymbolType,
class NonterminalSymbolType >
95 for (
const auto & rule :
grammar.getRules ( ) )
96 for (
const auto & rhs : rule.second ) {
104 tmp.
insert ( tmp.
end ( ), std::get < 0 > ( rhsTuple ).begin ( ), std::get < 0 > ( rhsTuple ).end ( ) );
106 tmp.push_back ( std::get < 1 > ( rhsTuple ) );
108 tmp.
insert ( tmp.
end ( ), std::get < 2 > ( rhsTuple ).begin ( ), std::get < 2 > ( rhsTuple ).end ( ) );
111 res[rule.first].insert ( std::move ( tmp ) );
117template <
class TerminalSymbolType,
class NonterminalSymbolType >
121 for (
const auto & rule :
grammar.getRules ( ) )
122 for (
const auto & rhs : rule.second ) {
124 tmp.push_back ( rhs.first );
126 tmp.
insert ( tmp.
end ( ), rhs.second.begin ( ), rhs.second.end ( ) );
128 res[rule.first].insert ( std::move ( tmp ) );
131 if (
grammar.getGeneratesEpsilon ( ) )
137template <
class TerminalSymbolType,
class NonterminalSymbolType >
141 if (
grammar.getGeneratesEpsilon ( ) )
147template <
class TerminalSymbolType,
class NonterminalSymbolType >
151 for (
const auto & rule :
grammar.getRules ( ) )
152 for (
const auto & rhs : rule.second ) {
153 if ( rhs.template is < TerminalSymbolType > ( ) ) {
155 res[rule.first].insert ( std::move ( tmp ) );
157 const auto & realRHS = rhs.template get < ext::pair < NonterminalSymbolType, NonterminalSymbolType > > ( );
159 res[rule.first].insert ( std::move ( tmp ) );
163 if (
grammar.getGeneratesEpsilon ( ) )
169template <
class TerminalSymbolType,
class NonterminalSymbolType >
174template <
class TerminalSymbolType,
class NonterminalSymbolType >
178 for (
const auto & rule :
grammar.getRules ( ) )
179 for (
const auto & rhs : rule.second ) {
185 const auto & rhsTuple = rhs.template get < ext::pair < NonterminalSymbolType, ext::vector < TerminalSymbolType > > > ( );
187 tmp.push_back ( rhsTuple.first );
188 tmp.
insert ( tmp.
end ( ), rhsTuple.second.begin ( ), rhsTuple.second.end ( ) );
191 res[rule.first].insert ( std::move ( tmp ) );
197template <
class TerminalSymbolType,
class NonterminalSymbolType >
201 for (
const auto & rule :
grammar.getRules ( ) )
202 for (
const auto & rhs : rule.second ) {
203 if ( rhs.template is < TerminalSymbolType > ( ) ) {
205 res[rule.first].insert ( std::move ( tmp ) );
207 const auto & rhsPair = rhs.template get < ext::pair < NonterminalSymbolType, TerminalSymbolType > > ( );
209 res[rule.first].insert ( std::move ( tmp ) );
213 if (
grammar.getGeneratesEpsilon ( ) )
219template <
class TerminalSymbolType,
class NonterminalSymbolType >
223 for (
const auto & rule :
grammar.getRules ( ) )
224 for (
const auto & rhs : rule.second ) {
225 if ( rhs.template is < TerminalSymbolType > ( ) ) {
227 res[rule.first].insert ( std::move ( tmp ) );
229 const auto & rhsPair = rhs.template get < ext::pair < TerminalSymbolType, NonterminalSymbolType > > ( );
231 res[rule.first].insert ( std::move ( tmp ) );
235 if (
grammar.getGeneratesEpsilon ( ) )
241template <
class TerminalSymbolType,
class NonterminalSymbolType >
245 for (
const auto & rule :
grammar.getRules ( ) )
246 for (
const auto & rhs : rule.second ) {
252 const auto & rhsTuple = rhs.template get < ext::pair < ext::vector < TerminalSymbolType >, NonterminalSymbolType > > ( );
254 tmp.
insert ( tmp.
end ( ), rhsTuple.first.begin ( ), rhsTuple.first.end ( ) );
255 tmp.push_back ( rhsTuple.second );
258 res[rule.first].insert ( std::move ( tmp ) );
Class extending the map class from the standard library. Original reason is to allow printing of the ...
Definition: map.hpp:48
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
auto begin() &
Inherited behavior of begin for non-const instance.
Definition: vector.hpp:125
reverse_iterator insert(const_reverse_iterator pos, const T &value)
Inserts the value on position given by iterator pos.
Definition: vector.hpp:229
auto end() &
Inherited behavior of end for non-const instance.
Definition: vector.hpp:155
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
Definition: RawRules.h:27
static ext::map< NonterminalSymbolType, ext::set< ext::vector< ext::variant< TerminalSymbolType, NonterminalSymbolType > > > > getRawRules(const LG< TerminalSymbolType, NonterminalSymbolType > &grammar)
Definition: RawRules.h:92
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
return res
Definition: MinimizeByPartitioning.h:145
Definition: ToAutomaton.h:24
auto & get(ext::ptr_array< Type, N > &tpl)
Specialisation of get function for pointer arrays.
Definition: ptr_array.hpp:693