21 std::set<Nonterminal> rSet;
23 GrammarSymbolVector::const_iterator wit;
24 std::set<Nonterminal>::const_iterator ntit;
26 for(wit = w.begin(); wit != w.end(); wit++){
32 ntit = symbolSet.find(*nt);
35 if(ntit != symbolSet.end()){
47 std::set<Nonterminal>
Rnpp1(
const Grammar& gr,
const std::set<Nonterminal>& ntSet){
50 std::set<Nonterminal> rSet, filterSet;
54 std::set<GrammarProduction>::const_iterator pit;
64 if(std::includes(ntSet.begin(), ntSet.end(), filterSet.begin(), filterSet.end())){
66 rSet.insert(pit->Lhs());
75 std::set<Nonterminal>
Rnppl(
const Grammar& gr,
const std::set<Nonterminal>& ntSet){
78 std::set<Nonterminal> rSet =
Rnpp1(gr,ntSet);
82 rSet =
Rnppl(gr,rSet);
96 std::set<Nonterminal> removableNts =
Rnppl(gr,std::set<Nonterminal>());
98 std::set<GrammarProduction> productions;
101 if(removableNts.find(gr.
StartSymbol()) != removableNts.end()){
103 std::set<GrammarProduction>::const_iterator gpit;
111 symbols.push_back(aPtr);
113 std::set<Nonterminal> filteredSet;
118 if(std::includes(removableNts.begin(), removableNts.end(), filteredSet.begin(), filteredSet.end())){
119 productions.insert(*gpit);
128 rGr.InsNonterminals(removableNts);
131 rGr.InsGrammarProductions(productions);
143 StateSet::Iterator stateit1, stateit2;
144 EventSet::Iterator eventit;
146 StackSymbolSet::Iterator ssit;
147 PopPushSet::const_iterator ppit;
148 std::vector<Idx> ssVector, pop, push;
149 std::vector<Idx>::const_iterator popit, pushit;
168 ssVector.push_back(*ssit);
178 ssVector.push_back(*ssit);
195 std::vector<Idx> b = pop;
197 Idx qi = transit->X1;
198 Idx qj = transit->X2;
212 rhs.push_back(ntRhsPtr);
226 rhs.push_back(ntRhsPtr);
245 else if(push.size() == 2){
248 c.push_back(push.front());
255 rhs.push_back(ntRhsPtr);
270 rhs.push_back(ntRhs1Ptr);
271 rhs.push_back(ntRhs2Ptr);
286 rhs.push_back(ntRhs1Ptr);
287 rhs.push_back(ntRhs2Ptr);
304 ssVector.push_back(*ssit);
325 StateSet::Iterator stateit1, stateit2;
326 EventSet::Iterator eventit;
328 StackSymbolSet::Iterator ssit;
329 PopPushSet::const_iterator ppit;
330 std::vector<Idx> ssVector, pop, push;
331 std::vector<Idx>::const_iterator popit, pushit;
354 ssVector.push_back(*ssit);
384 std::vector<Idx> b = pop;
386 Idx qi = transit->X1;
387 Idx qj = transit->X2;
408 rhs.push_back(ntRhsPtr);
431 rhs.push_back(ntRhsPtr);
456 else if(push.size() == 2){
459 c.push_back(push.front());
473 rhs.push_back(ntRhsPtr);
498 rhs.push_back(ntRhs1Ptr);
499 rhs.push_back(ntRhs2Ptr);
524 rhs.push_back(ntRhs1Ptr);
525 rhs.push_back(ntRhs2Ptr);
551 std::set<GrammarProduction> todoProductions, reachableProductions;
552 std::set<GrammarProduction>::const_iterator gpit;
553 std::set<Nonterminal> usedNonterminals;
561 todoProductions.insert(*gpit);
566 while(!todoProductions.empty()){
570 todoProductions.erase(currentGp);
573 reachableProductions.insert(currentGp);
577 usedNonterminals.insert(filtered.begin(), filtered.end());
583 if(usedNonterminals.find(gpit->Lhs()) != usedNonterminals.end()){
584 todoProductions.insert(*gpit);
590 for(gpit = reachableProductions.begin(); gpit != reachableProductions.end(); gpit++){
591 todoProductions.erase(*gpit);