本文整理汇总了C#中StringSet.AddRange方法的典型用法代码示例。如果您正苦于以下问题:C# StringSet.AddRange方法的具体用法?C# StringSet.AddRange怎么用?C# StringSet.AddRange使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类StringSet
的用法示例。
在下文中一共展示了StringSet.AddRange方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetCurrentExpectedSymbols
private StringList GetCurrentExpectedSymbols()
{
BnfTermList inputElements = new BnfTermList();
StringSet inputKeys = new StringSet();
inputKeys.AddRange(_currentState.Actions.Keys);
//First check all NonTerminals
foreach (NonTerminal nt in Data.NonTerminals) {
if (!inputKeys.Contains(nt.Key)) continue;
//nt is one of our available inputs; check if it has an alias. If not, don't add it to element list;
// and we have already all its "Firsts" keys in the list.
// If yes, add nt to element list and remove
// all its "fists" symbols from the list. These removed symbols will be represented by single nt alias.
if (string.IsNullOrEmpty(nt.DisplayName))
inputKeys.Remove(nt.Key);
else {
inputElements.Add(nt);
foreach(string first in nt.Firsts)
inputKeys.Remove(first);
}
}
//Now terminals
foreach (Terminal term in Data.Terminals) {
if (inputKeys.Contains(term.Key))
inputElements.Add(term);
}
StringList result = new StringList();
foreach(BnfTerm term in inputElements)
result.Add(string.IsNullOrEmpty(term.DisplayName)? term.Name : term.DisplayName);
result.Sort();
return result;
}
示例2: CalculateTailFirsts
private void CalculateTailFirsts()
{
foreach (Production prod in _data.Productions)
{
StringSet accumulatedFirsts = new StringSet();
bool allNullable = true;
for (int i = prod.LR0Items.Count - 1; i >= 0; i--)
{
LR0Item item = prod.LR0Items[i];
if (i >= prod.LR0Items.Count - 2)
{
item.TailIsNullable = true;
item.TailFirsts.Clear();
continue;
}
GrammarTerm term = prod.RValues[item.Position + 1];
NonTerminal ntElem = term as NonTerminal;
if (ntElem == null || !ntElem.Nullable)
{
accumulatedFirsts.Clear();
allNullable = false;
item.TailIsNullable = false;
if (ntElem == null)
{
item.TailFirsts.Add(term.Key);
accumulatedFirsts.Add(term.Key);
}
else
{
item.TailFirsts.AddRange(ntElem.Firsts);
accumulatedFirsts.AddRange(ntElem.Firsts);
}
continue;
}
accumulatedFirsts.AddRange(ntElem.Firsts);
item.TailFirsts.AddRange(accumulatedFirsts);
item.TailIsNullable = allNullable;
}
}
}