Next() public method

public Next ( ) : CSymbol
return CSymbol
示例#1
0
        public void CheckClosure(ProdItem item)
        {
            CSymbol csymbol = item.Next();

            if (csymbol == null)
            {
                return;
            }
            csymbol.AddStartItems(this, item.FirstOfRest(csymbol.m_parser));
            if (!item.IsReducingAction())
            {
                return;
            }
            this.MaybeAdd(new ProdItem(item.m_prod, item.m_pos + 1));
        }
示例#2
0
 public void AddEntries()
 {
     for (ProdItemList prodItemList = this.m_items; prodItemList.m_pi != null; prodItemList = prodItemList.m_next)
     {
         ProdItem pi1 = prodItemList.m_pi;
         if (!pi1.m_done)
         {
             CSymbol csymbol = pi1.Next();
             if (csymbol != null && !pi1.IsReducingAction())
             {
                 ParseState parseState = new ParseState(this.m_sgen, csymbol);
                 parseState.MaybeAdd(new ProdItem(pi1.m_prod, pi1.m_pos + 1));
                 for (ProdItemList next = prodItemList.m_next; next != null && next.m_pi != null; next = next.m_next)
                 {
                     ProdItem pi2 = next.m_pi;
                     if (csymbol == pi2.Next())
                     {
                         parseState.MaybeAdd(new ProdItem(pi2.m_prod, pi2.m_pos + 1));
                         pi2.m_done = true;
                     }
                 }
                 if (!this.m_items.AtEnd)
                 {
                     if (csymbol.IsAction())
                     {
                         ParseState next = parseState.CheckExists();
                         foreach (CSymbol key in (IEnumerable)csymbol.m_follow.Keys)
                         {
                             if (key != this.m_sgen.m_symbols.EOFSymbol)
                             {
                                 this.GetTransition(key).m_next = new ParserShift((ParserAction)csymbol, next);
                             }
                         }
                     }
                     else
                     {
                         this.GetTransition(csymbol).m_next = new ParserShift((ParserAction)null, parseState.CheckExists());
                     }
                 }
             }
         }
     }
 }
示例#3
0
 public void ReduceStates()
 {
     for (ProdItemList prodItemList = this.m_items; prodItemList.m_pi != null; prodItemList = prodItemList.m_next)
     {
         ProdItem pi = prodItemList.m_pi;
         if (pi.Next() == null)
         {
             Production prod = pi.m_prod;
             if (prod.m_pno != 0)
             {
                 int          count = prod.m_rhs.Count;
                 CSymbol      rh;
                 ParserReduce parserReduce;
                 if (count > 0 && (rh = (CSymbol)prod.m_rhs[count - 1]) != null && rh.IsAction())
                 {
                     ParserAction action = (ParserAction)rh;
                     action.m_len = count;
                     parserReduce = new ParserReduce(action, count - 1, prod);
                 }
                 else
                 {
                     this.m_sgen.m_lexer.yytext = "%" + prod.m_lhs.yytext;
                     this.m_sgen.m_prod         = prod;
                     ParserSimpleAction parserSimpleAction = new ParserSimpleAction(this.m_sgen);
                     parserSimpleAction.m_sym = prod.m_lhs;
                     parserSimpleAction.m_len = count;
                     parserReduce             = new ParserReduce((ParserAction)parserSimpleAction, count, prod);
                 }
                 foreach (CSymbol key in (IEnumerable)pi.m_prod.m_lhs.m_follow.Keys)
                 {
                     this.GetTransition(key).m_reduce[(object)prod] = (object)parserReduce;
                 }
             }
         }
     }
 }
示例#4
0
		public void CheckClosure(ProdItem item) 
		{
			CSymbol ss = item.Next();
			if (ss!=null) 
			{
				ss.AddStartItems(this,item.FirstOfRest(ss.m_parser));
				if (item.IsReducingAction())
					MaybeAdd(new ProdItem(item.m_prod, item.m_pos+1));
			}
		}