private SortedSet <IDottedRule> GetPredictedStates(DottedRuleSet frame) { var pool = SharedPools.Default <Queue <IDottedRule> >(); var queue = pool.AllocateAndClear(); var closure = new SortedSet <IDottedRule>(); for (int i = 0; i < frame.Data.Count; i++) { var state = frame.Data[i]; if (!IsComplete(state)) { queue.Enqueue(state); } } while (queue.Count > 0) { var state = queue.Dequeue(); if (IsComplete(state)) { continue; } var postDotSymbol = GetPostDotSymbol(state); if (postDotSymbol.SymbolType != SymbolType.NonTerminal) { continue; } var nonTerminalPostDotSymbol = postDotSymbol as INonTerminal; if (Grammar.IsTransativeNullable(nonTerminalPostDotSymbol)) { var preComputedState = GetPreComputedState(state.Production, state.Position + 1); if (!frame.Contains(preComputedState)) { if (closure.Add(preComputedState)) { if (!IsComplete(preComputedState)) { queue.Enqueue(preComputedState); } } } } var predictions = Grammar.RulesFor(nonTerminalPostDotSymbol); for (var p = 0; p < predictions.Count; p++) { var prediction = predictions[p]; var preComputedState = GetPreComputedState(prediction, 0); if (frame.Contains(preComputedState)) { continue; } if (!closure.Add(preComputedState)) { continue; } if (!IsComplete(preComputedState)) { queue.Enqueue(preComputedState); } } } pool.ClearAndFree(queue); return(closure); }