public override IDerivation Visit(Terminal aSymbol, DerivationContext aContext) { CyclesDetectContext context = aContext as CyclesDetectContext; aSymbol.Parent = context.Parent; return(null); }
public CyclesDetectContext(CyclesDetectContext aCyclesDetectContext) : base(aCyclesDetectContext.Grammar) { NotTerminals = new Dictionary <string, NonTerminal>(aCyclesDetectContext.NotTerminals); Visitor = aCyclesDetectContext.Visitor; //BuildingGraph = aCyclesDetectContext.BuildingGraph; }
protected override DerivationContext NewContext(IPhrase aPhrase, DerivationContext aContext) { CyclesDetectContext newContext = new CyclesDetectContext(aContext as CyclesDetectContext); newContext.Parent = aPhrase; return(newContext); }
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)); }
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)); }
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)); }
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)); }
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)); }
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)); }
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); }