예제 #1
0
        public override IDerivation Visit(Seqence aSeqence, DerivationContext aContext)
        {
            ExtractNotTerminalsContext lContext = aContext as ExtractNotTerminalsContext;

            lContext.Seqences.Add(aSeqence);
            return(base.Visit(aSeqence, aContext));
        }
예제 #2
0
 public override IDerivation VisitInternal(AlternativeSet aAlternativeSet, DerivationContext aContext)
 {
     if (!Twig.IsPassed)
     {
         //Создаем извлекающий символы визитор один раз
         if (null == mExtrSymContext)
         {
             mExtrSymContext         = new ExtractNotTerminalsContext(aContext.Grammar);
             mExtrSymContext.Visitor = new VisitorExtractNTSymbols();
         }
         //Формируем список альтернатив, содержащих желаемый символ
         AlternativeSet lGoodAlts = new AlternativeSet(aContext.Grammar);
         foreach (IPhrase lPhr in aAlternativeSet.Phrases)
         {
             mExtrSymContext.NotTerminals.Clear();
             lPhr.Accept(mExtrSymContext);
             if (mExtrSymContext.NotTerminals.Contains(Twig.WaitingSymbol))
             {
                 lGoodAlts.Phrases.Add(lPhr);
             }
         }
         if (lGoodAlts.Count > 0)
         {
             int i = mRnd.Next(lGoodAlts.Count);
             return(lGoodAlts.GetAlternative(aContext, i));
         }
     }
     return(base.VisitInternal(aAlternativeSet, aContext));
 }
예제 #3
0
        public override IDerivation Visit(NonTerminal aSymbol, DerivationContext aContext)
        {
            ExtractNotTerminalsContext lContext = aContext as ExtractNotTerminalsContext;

            lContext.NotTerminals.Add(aSymbol.Text);
            return(null);
        }