本文整理汇总了C++中SymbolSet::merge方法的典型用法代码示例。如果您正苦于以下问题:C++ SymbolSet::merge方法的具体用法?C++ SymbolSet::merge怎么用?C++ SymbolSet::merge使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SymbolSet
的用法示例。
在下文中一共展示了SymbolSet::merge方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
// ****************************************************************************
// Method: ConfiguratingSet::GetReduceSymbols
//
// Purpose:
// Get the set of symbols which will cause a reduction.
//
// Programmer: Jeremy Meredith
// Creation: April 5, 2002
//
// ****************************************************************************
SymbolSet
ConfiguratingSet::GetReduceSymbols()
{
SymbolSet reducesymbols;
for (size_t i=0; i<items.size(); i++)
{
if (items[i].CanReduce())
{
reducesymbols.merge(items[i].GetFollow());
}
}
return reducesymbols;
}
示例2:
// ****************************************************************************
// Method: Sequence::GetFirstSet
//
// Purpose:
// Get the first set of this sequence.
//
// Programmer: Jeremy Meredith
// Creation: April 5, 2002
//
// ****************************************************************************
SymbolSet
Sequence::GetFirstSet(const vector<const Rule*> &rules) const
{
SymbolSet first;
for (size_t i=0; i<symbols.size(); i++)
{
if (symbols[i]->IsTerminal())
{
first.insert(symbols[i]);
break;
}
first.merge( symbols[i]->GetFirstSet(rules) );
if (! symbols[i]->IsNullable(rules))
break;
}
return first;
}
示例3:
// ****************************************************************************
// Method: Symbol::GetFirstSet
//
// Purpose:
// Gets the first set for any production of this symbol.
// For terminals, the first set is the identity operation.
//
// Programmer: Jeremy Meredith
// Creation: April 5, 2002
//
// ****************************************************************************
SymbolSet
Symbol::GetFirstSet(const vector<const Rule*> &rules) const
{
SymbolSet first;
if (type == Terminal)
{
first.insert(this);
}
else
{
for (size_t i=0; i<rules.size(); i++)
{
if (rules[i]->GetLHS() == this &&
// Try to avoid infinite recursion -- this should be improved!
(rules[i]->GetRHS().Empty() || rules[i]->GetRHS()[0] != this))
{
first.merge( rules[i]->GetRHS().GetFirstSet(rules) );
}
}
}
return first;
}
示例4:
// ****************************************************************************
// Method: ConfiguratingItem::CreateClosure
//
// Purpose:
// Get the list of configurating items in the closure of the current item.
//
// Programmer: Jeremy Meredith
// Creation: April 5, 2002
//
// ****************************************************************************
ConfiguratingSet
ConfiguratingItem::CreateClosure(const vector<const Rule*> &rules)
{
ConfiguratingSet closure;
Sequence s = rule->GetRHS().GetSubsequence(pos);
if (!s.Empty() && s[0]->IsNonTerminal())
{
Sequence remaining = s.GetSubsequence(1);
SymbolSet closurefollow = remaining.GetFirstSet(rules);
if (remaining.IsNullable(rules))
{
closurefollow.merge(follow);
}
for (size_t i=0; i<rules.size(); i++)
{
if (s[0] == rules[i]->GetLHS())
{
closure.AddItem(ConfiguratingItem(rules[i], closurefollow));
}
}
}
return closure;
}