Ejemplo n.º 1
0
 public static Lr0State Closure(Lr0State theState, List<GrammarRule> theGrammar)
 {
     Lr0State ResultState = new Lr0State(theState.itemSet);
     bool hasChanged = false;
     do
     {
         hasChanged = false;
         List<Item> forwardItems = theState.GetForwardItems();
         foreach (Item theItem in forwardItems)
         {
             Symbol currentSymbol = theItem.getCurrentSymbol();
             List<Item> theProductions = Lr0GenerationHelper.getItemsById(currentSymbol.id, theGrammar);
             foreach (var item in theProductions)
             {
                 hasChanged = theState.Add(item) || hasChanged;
             }
         }
     } while (hasChanged);
     return ResultState;
 }