| 131 | } |
| 132 | |
| 133 | void cParserHelper::Finit(cGenreSpecListVector* pPolicy) |
| 134 | { |
| 135 | // |
| 136 | // don't build spec list if just checking syntax |
| 137 | // |
| 138 | if (!pPolicy) |
| 139 | { |
| 140 | CleanUp(); |
| 141 | return; |
| 142 | } |
| 143 | |
| 144 | int nRulesInPolicy = 0; |
| 145 | |
| 146 | GenreContainer::iterator i; |
| 147 | for (i = mAph.begin(); i != mAph.end(); ++i) |
| 148 | { |
| 149 | cGenreSpecListPair slp; |
| 150 | cGenre::Genre g = i->first; |
| 151 | cGenreParseInfo* pgpi = i->second; |
| 152 | |
| 153 | // |
| 154 | // create the specs from rules |
| 155 | // |
| 156 | cParserUtil::CreateFCOSpecs(g, pgpi, slp.GetSpecList()); |
| 157 | slp.SetGenre(g); |
| 158 | |
| 159 | // |
| 160 | // get rule count for section |
| 161 | // |
| 162 | int nRulesInSection = slp.GetSpecList().Size(); |
| 163 | if (0 == nRulesInSection) |
| 164 | { |
| 165 | TSTRING str = TSS_GetString(cTWParser, twparser::STR_ERR2_PARSER_NO_RULES_IN_SECTION); |
| 166 | str.append(cGenreSwitcher::GetInstance()->GenreToString(slp.GetGenre(), true)); |
| 167 | |
| 168 | eParserNoRulesInSection e(str); |
| 169 | e.SetFatality(false); |
| 170 | cParserHelper::GetErrorBucket()->AddError(e); |
| 171 | } |
| 172 | |
| 173 | // |
| 174 | // increment rule count for policy file |
| 175 | // |
| 176 | nRulesInPolicy += slp.GetSpecList().Size(); |
| 177 | |
| 178 | // |
| 179 | // add to policy |
| 180 | // |
| 181 | pPolicy->push_back(slp); |
| 182 | } |
| 183 | |
| 184 | CleanUp(); |
| 185 | |
| 186 | // |
| 187 | // check that we have some rules |
| 188 | // |
| 189 | if (0 == nRulesInPolicy) |
| 190 | throw eParserNoRules(_T(""), eParserHelper::NO_LINE); |