Example #1
0
        public IDerivation Expand(DerivationContext aContext)
        {
            TLog.Write("R", TLog.IndentStr() + Name);
            TLog.Indent += 2;
            IDerivation lDeriv = RightSide.Accept(aContext);

            TLog.Indent -= 2;
            ListDerivation lListDer = lDeriv as ListDerivation;

            if (lListDer != null && mSeparator != null)
            {
                lListDer.Separator = mSeparator;
            }
            return(lDeriv);
        }
Example #2
0
        public override IDerivation Visit(AlternativeSet aAlternativeSet, DerivationContext aContext)
        {
            for (int i = 0; i < aAlternativeSet.Count; i++)
            {
                IPhrase phr = aAlternativeSet.Phrases[i];
                if (OmmitTerminals && phr is Terminal)
                {
                    continue;
                }
                tEdge edge = addEdge(aContext, phr, aAlternativeSet.Parent);
                edge.CustomAttributes = phr.IsCyclic ? GrammarGraphEdgeAttrs.IsCyclic : GrammarGraphEdgeAttrs.None;

                phr.Accept(NewContext(aAlternativeSet, aContext));
            }
            return(null);
        }
Example #3
0
        public override IDerivation Visit(Seqence aSeqence, DerivationContext aContext)
        {
            for (int i = 0; i < aSeqence.Count; i++)
            {
                IPhrase phr = aSeqence.Phrases[i];
                if (OmmitTerminals && phr is Terminal)
                {
                    continue;
                }
                tEdge edge = addEdge(aContext, phr, aSeqence.Parent);
                edge.CustomAttributes = GrammarGraphEdgeAttrs.IsSequence
                                        | (phr.IsCyclic ? GrammarGraphEdgeAttrs.IsCyclic : GrammarGraphEdgeAttrs.None);

                phr.Accept(NewContext(aSeqence, aContext));
            }
            return(null);
        }
Example #4
0
        public virtual IDerivation Visit(Seqence aSeqence, DerivationContext aContext)
        {
            DictionaryDerivation lList = new DictionaryDerivation(aSeqence.InsertSpace, aContext);
            int lExprCnt = 1;

            for (int i = 0; i < aSeqence.Count; i++)
            {
                IPhrase          lPhr = aSeqence.Phrases[i];
                IDerivation      lRes = lPhr.Accept(aContext);
                string           lKeyName;
                NonTerminal      lCurrentSymbol = lPhr as NonTerminal;
                QuantifiedPhrase lCurQuantPhr   = lPhr as QuantifiedPhrase;
                if (null != lCurQuantPhr)
                {
                    lCurrentSymbol = lCurQuantPhr.Phrase as NonTerminal;
                }
                if (lCurrentSymbol != null)
                {
                    //to del lCurrentSymbol.OccurenceInSeq = i;
                    lKeyName = lCurrentSymbol.Text;
                    //взять протокол вывода этого правила
                    //TODO: aContext.RuleSeqProtocol.Add(lCurrentSymbol.Text, lRes);
                    //добавить в его протокол вывода последовательности имя lCurrentSymbol.Text и результат lRes
                }
                else
                {
                    lKeyName = string.Format("Expr{0}", lExprCnt++);
                }
                if (!string.IsNullOrEmpty(lPhr.Alias))
                {
                    lKeyName = lPhr.Alias;
                }
                lList.Add(lKeyName, lRes, aContext);
            }
            return(lList);
        }