本文整理汇总了C++中Grammar::GetCondinates方法的典型用法代码示例。如果您正苦于以下问题:C++ Grammar::GetCondinates方法的具体用法?C++ Grammar::GetCondinates怎么用?C++ Grammar::GetCondinates使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Grammar
的用法示例。
在下文中一共展示了Grammar::GetCondinates方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: CreateFirstSetsOnePass
bool Parser::CreateFirstSetsOnePass() {
bool anySetModified = false;
for (GrammarContainer::const_iterator ite = env_->grammars.begin(); ite != env_->grammars.end(); ++ite) {
Grammar* g = *ite;
const CondinateContainer& conds = g->GetCondinates();
GrammarSymbolSet& firstSet = firstSetContainer_[g->GetLhs()];
for (CondinateContainer::const_iterator ite2 = conds.begin(); ite2 != conds.end(); ++ite2) {
Condinate* c = *ite2;
SymbolVector::iterator ite3 = c->symbols.begin();
for (; ite3 != c->symbols.end(); ++ite3) {
GrammarSymbol& current = *ite3;
anySetModified = MergeNonEpsilonElements(firstSet, firstSetContainer_[current]) || anySetModified;
GrammarSymbolSet& currentFirstSet = firstSetContainer_[current];
if (currentFirstSet.find(NativeSymbols::epsilon) == currentFirstSet.end()) {
break;
}
}
if (ite3 == c->symbols.end()) {
anySetModified = firstSet.insert(NativeSymbols::epsilon).second || anySetModified;
}
}
}
return anySetModified;
}
示例2: CreateFollowSetsOnePass
bool Parser::CreateFollowSetsOnePass() {
bool anySetModified = false;
GrammarSymbolSet gss;
for (GrammarContainer::const_iterator ite = env_->grammars.begin(); ite != env_->grammars.end(); ++ite) {
Grammar* g = *ite;
const CondinateContainer& conds = g->GetCondinates();
for (CondinateContainer::const_iterator ite2 = conds.begin(); ite2 != conds.end(); ++ite2) {
Condinate* current = *ite2;
for (SymbolVector::iterator ite3 = current->symbols.begin(); ite3 != current->symbols.end(); ++ite3) {
GrammarSymbol& symbol = *ite3;
if (symbol.SymbolType() == GrammarSymbolTerminal) {
continue;
}
SymbolVector::iterator ite4 = ite3;
firstSetContainer_.GetFirstSet(gss, ++ite4, current->symbols.end());
anySetModified = MergeNonEpsilonElements(followSetContainer_[symbol], gss) || anySetModified;
if (gss.find(NativeSymbols::epsilon) != gss.end()) {
anySetModified = MergeNonEpsilonElements(followSetContainer_[symbol], followSetContainer_[g->GetLhs()]) || anySetModified;
}
gss.clear();
}
}
}
return anySetModified;
}