Ejemplo n.º 1
0
        public override IDerivation Visit(Terminal aSymbol, DerivationContext aContext)
        {
            CyclesDetectContext context = aContext as CyclesDetectContext;

            aSymbol.Parent = context.Parent;
            return(null);
        }
Ejemplo n.º 2
0
 public CyclesDetectContext(CyclesDetectContext aCyclesDetectContext)
     : base(aCyclesDetectContext.Grammar)
 {
     NotTerminals = new Dictionary <string, NonTerminal>(aCyclesDetectContext.NotTerminals);
     Visitor      = aCyclesDetectContext.Visitor;
     //BuildingGraph = aCyclesDetectContext.BuildingGraph;
 }
Ejemplo n.º 3
0
        protected override DerivationContext NewContext(IPhrase aPhrase, DerivationContext aContext)
        {
            CyclesDetectContext newContext = new CyclesDetectContext(aContext as CyclesDetectContext);

            newContext.Parent = aPhrase;
            return(newContext);
        }
Ejemplo n.º 4
0
        public override IDerivation Visit(IPhrase aPhr, DerivationContext aContext)
        {
            CyclesDetectContext context = aContext as CyclesDetectContext;

            aPhr.Parent = context.Parent;
            CyclesDetectContext newContext = new CyclesDetectContext(aContext as CyclesDetectContext);

            newContext.Parent = aPhr;
            return(base.Visit(aPhr, newContext));
        }
Ejemplo n.º 5
0
        public override IDerivation Visit(PlaceHolderPhrase aPlaceHolderPhrase, DerivationContext aContext)
        {
            CyclesDetectContext context = aContext as CyclesDetectContext;

            aPlaceHolderPhrase.Parent = context.Parent;
            CyclesDetectContext newContext = new CyclesDetectContext(aContext as CyclesDetectContext);

            newContext.Parent = aPlaceHolderPhrase;
            return(base.Visit(aPlaceHolderPhrase, newContext));
        }
Ejemplo n.º 6
0
        public override IDerivation Visit(TransCallPhrase aTransCallPhrase, DerivationContext aContext)
        {
            CyclesDetectContext context = aContext as CyclesDetectContext;

            aTransCallPhrase.Parent = context.Parent;
            CyclesDetectContext newContext = new CyclesDetectContext(aContext as CyclesDetectContext);

            newContext.Parent = aTransCallPhrase;
            return(base.Visit(aTransCallPhrase, newContext));
        }
Ejemplo n.º 7
0
        public override IDerivation Visit(QuantifiedPhrase aQuantifiedPhrase, DerivationContext aContext)
        {
            CyclesDetectContext context = aContext as CyclesDetectContext;

            aQuantifiedPhrase.Parent = context.Parent;
            CyclesDetectContext newContext = new CyclesDetectContext(aContext as CyclesDetectContext);

            newContext.Parent = aQuantifiedPhrase;
            return(base.Visit(aQuantifiedPhrase, newContext));
        }
Ejemplo n.º 8
0
        public override IDerivation Visit(ExprOp aExprOp, DerivationContext aContext)
        {
            CyclesDetectContext context = aContext as CyclesDetectContext;

            aExprOp.Parent = context.Parent;
            CyclesDetectContext newContext = new CyclesDetectContext(aContext as CyclesDetectContext);

            newContext.Parent = aExprOp;
            return(base.Visit(aExprOp, newContext));
        }
Ejemplo n.º 9
0
        public override IDerivation Visit(AccessArray aAccessArray, DerivationContext aContext)
        {
            CyclesDetectContext context = aContext as CyclesDetectContext;

            aAccessArray.Parent = context.Parent;
            CyclesDetectContext newContext = new CyclesDetectContext(aContext as CyclesDetectContext);

            newContext.Parent = aAccessArray;
            return(base.Visit(aAccessArray, newContext));
        }
Ejemplo n.º 10
0
        public override IDerivation Visit(NonTerminal aSymbol, DerivationContext aContext)
        {
            CyclesDetectContext context = aContext as CyclesDetectContext;

            aSymbol.Parent = context.Parent;
            if (context.NotTerminals.ContainsKey(aSymbol.Text))
            {
                aSymbol.CycicKind         = CycicKind.CyclicOrigin;
                aSymbol.CyclicToOccurence = context.NotTerminals[aSymbol.Text].CounterName;
                aSymbol.PropagateCycle();
                //aContext.Grammar.AllCyclicSymbolOccurs.Add(aSymbol);
            }
            else
            {
                bool isAlreadyUsed = mAlreadyUsedSymbols.Contains(aSymbol.Text);
                mAlreadyUsedSymbols.Add(aSymbol.Text);

                if (!isAlreadyUsed)
                {
                    // Add current symbol to derivation path so that we can track cycles
                    (aContext as CyclesDetectContext).NotTerminals.Add(aSymbol.Text, aSymbol);
                    //взали правило
                    Rule lRule = aSymbol.FindItsRule();

                    //Раскрываем правую часть правила
                    CyclesDetectContext newContext = new CyclesDetectContext(aContext as CyclesDetectContext);
                    newContext.Parent = aSymbol;
                    lRule.Expand(newContext);
                }
                else
                {
                    aSymbol.CycicKind |= CycicKind.SkippedAsSeen;
                }
            }
            return(null);
        }