private void ComputeGoto(State state)
        {
            foreach (ProductionItem item in state.all_items)
            {
                if (!item.expanded && !item.isReduction())
                {
                    item.expanded = true;
                    Symbol s1 = item.production.rhs[item.pos];

                    // Create itemset for new state ...
                    List <ProductionItem> itemSet = new List <ProductionItem>();
                    itemSet.Add(new ProductionItem(item.production, item.pos + 1));

                    foreach (ProductionItem item2 in state.all_items)
                    {
                        if (!item2.expanded && !item2.isReduction())
                        {
                            Symbol s2 = item2.production.rhs[item2.pos];

                            if (s1 == s2)
                            {
                                item2.expanded = true;
                                itemSet.Add(new ProductionItem(item2.production, item2.pos + 1));
                            }
                        }
                    }

                    State existingState = FindExistingState(s1, itemSet);

                    if (existingState == null)
                    {
                        State newState = new State(itemSet);
                        state.AddGoto(s1, newState);
                        ExpandState(s1, newState);
                    }
                    else
                    {
                        state.AddGoto(s1, existingState);
                    }
                }
            }
        }
Beispiel #2
0
 private void ComputeGoto(State state)
 {
     foreach (ProductionItem current in state.all_items)
     {
         if (!current.expanded && !current.isReduction())
         {
             current.expanded = true;
             Symbol symbol = current.production.rhs[current.pos];
             List <ProductionItem> list = new List <ProductionItem>();
             list.Add(new ProductionItem(current.production, current.pos + 1));
             foreach (ProductionItem current2 in state.all_items)
             {
                 if (!current2.expanded && !current2.isReduction())
                 {
                     Symbol symbol2 = current2.production.rhs[current2.pos];
                     if (symbol == symbol2)
                     {
                         current2.expanded = true;
                         list.Add(new ProductionItem(current2.production, current2.pos + 1));
                     }
                 }
             }
             State state2 = this.FindExistingState(symbol, list);
             if (state2 == null)
             {
                 State state3 = new State(list);
                 state.AddGoto(symbol, state3);
                 this.ExpandState(symbol, state3);
             }
             else
             {
                 state.AddGoto(symbol, state2);
             }
         }
     }
 }
Beispiel #3
0
		private void ComputeGoto(State state)
		{
			foreach (ProductionItem current in state.all_items)
			{
				if (!current.expanded && !current.isReduction())
				{
					current.expanded = true;
					Symbol symbol = current.production.rhs[current.pos];
					List<ProductionItem> list = new List<ProductionItem>();
					list.Add(new ProductionItem(current.production, current.pos + 1));
					foreach (ProductionItem current2 in state.all_items)
					{
						if (!current2.expanded && !current2.isReduction())
						{
							Symbol symbol2 = current2.production.rhs[current2.pos];
							if (symbol == symbol2)
							{
								current2.expanded = true;
								list.Add(new ProductionItem(current2.production, current2.pos + 1));
							}
						}
					}
					State state2 = this.FindExistingState(symbol, list);
					if (state2 == null)
					{
						State state3 = new State(list);
						state.AddGoto(symbol, state3);
						this.ExpandState(symbol, state3);
					}
					else
					{
						state.AddGoto(symbol, state2);
					}
				}
			}
		}
Beispiel #4
0
        private void ComputeGoto(State state)
        {
            foreach (ProductionItem item in state.all_items)
                if (!item.expanded && !item.isReduction())
                {
                    item.expanded = true;
                    Symbol s1 = item.production.rhs[item.pos];

                    // Create itemset for new state ...
                    List<ProductionItem> itemSet = new List<ProductionItem>();
                    itemSet.Add(new ProductionItem(item.production, item.pos+1));

                    foreach (ProductionItem item2 in state.all_items)
                        if (!item2.expanded && !item2.isReduction())
                        {
                            Symbol s2 = item2.production.rhs[item2.pos];

                            if (s1 == s2)
                            {
                                item2.expanded = true;
                                itemSet.Add(new ProductionItem(item2.production, item2.pos+1));
                            }
                        }

                    State existingState = FindExistingState(s1, itemSet);

                    if (existingState == null)
                    {
                        State newState = new State(itemSet);
                        state.AddGoto(s1, newState);
                        ExpandState(s1, newState);
                    }
                    else
                        state.AddGoto(s1, existingState);
                }
        }