/** * Vraci true pokud se stav state jmenuje stejne jako soucasny stav. **/ public bool Equals(AutomatState state) { if (this.name.Equals(state.name)) { return(true); } return(false); }
/** * Inicializuje PushDownAutomat a jeho pomocne struktury. **/ public void inicialize(PSMSchema schema, String XMLFilePath) { XMLDocument = new XmlDocument(); XMLDocument.Load(XMLFilePath); readedNodesStackTrace = new Stack <String>(); schema.Project.PropertyChanged += new System.ComponentModel.PropertyChangedEventHandler(removeFromCache); if (initializationCache.ContainsKey(schema)) { forestStatesTransitions = initializationCache[schema].ForestStatesTransitions; rightSideToLeftSide = initializationCache[schema].RightSideToLeftSide; startState = initializationCache[schema].StartState; finalState = initializationCache[schema].FinalState; wordToState = initializationCache[schema].WordToState; } else { treeStateCount = 0; forestStatesTransitions = new Dictionary <StateWordPair, HashSet <AutomatEdge> >(); rightSideToLeftSide = new Dictionary <string, HashSet <string> >(); startState = new HashSet <AutomatState>(); finalState = new HashSet <AutomatState>(); wordToState = new Dictionary <string, HashSet <AutomatState> >(); associationLeftSideName = new Dictionary <PSMAssociation, string>(); automatUtils = new FiniteAutomatUtils(); inicializedAssociations = new HashSet <PSMAssociation>(); AutomatState forestStartState = new AutomatState("ss1", true, null); AutomatState forestFinalState = new AutomatState("ss2", forestStartState); forestFinalState.exitState = true; startState.Add(forestStartState); finalState.Add(forestFinalState); forestStatesTransitions.Add(new StateWordPair(forestStartState, "T0"), new HashSet <AutomatEdge> { new AutomatEdge(forestFinalState) }); if (schema.PSMSchemaClass.ChildPSMAssociations.Count > 1) { throw new Exception("XML must have root element"); } treeStateCount++; associationLeftSideName.Add(schema.PSMSchemaClass.ChildPSMAssociations[0], leftSideName + (treeStateCount - 1)); inicialize(schema.PSMSchemaClass.ChildPSMAssociations[0], leftSideName + (treeStateCount - 1)); if (!initializationCache.ContainsKey(schema)) { initializationCache.Add(schema, new InitConfig(forestStatesTransitions, rightSideToLeftSide, startState, finalState, wordToState)); } } }
/** * Vytvori kopii stavu originalState a nastavi jmeno na stateName. **/ public AutomatState(String stateName, AutomatState originalState, Object fakeArgument) { this.name = stateName; this.enterState = originalState.enterState; this.exitState = originalState.exitState; this.depth = originalState.depth; this.startState = originalState.startState; this.leftSide = originalState.leftSide; this.automatStateWithoutDepth = this; this.SideCompulsarity = originalState.sideCompulsarity; }
/** * Konstruktor pro tridu AutomatState. * * atribut name udrcuje nazev stavu * atribut enterState urcuje, zda je stav startovnim stavem automatu * atribut startState je odkaz na startovni stav aktualniho automatu **/ public AutomatState(String name, bool enterState, AutomatState startState) { this.name = name; this.enterState = enterState; this.exitState = false; this.depth = 0; this.automatStateWithoutDepth = this; if (startState == null) { this.startState = this; } else { this.startState = startState; } }
/** * Konstruktor pro tridu AutomatState. Vytvori stav do ktereho se dostaneme po prejeti ze stavu previousState po hrane automatEdge. **/ public AutomatState(AutomatState previousState, AutomatEdge automatEdge) { this.name = automatEdge.EndState.name; this.enterState = automatEdge.EndState.enterState; this.exitState = automatEdge.EndState.exitState; this.depth = previousState.depth; this.startState = automatEdge.EndState.startState; this.leftSide = automatEdge.EndState.leftSide; this.automatStateWithoutDepth = automatEdge.EndState.automatStateWithoutDepth; this.sideCompulsarity = automatEdge.EndState.SideCompulsarity; if (automatEdge.EdgeMode == EdgeMode.ADDING) { depth++; } else { if (automatEdge.EdgeMode == EdgeMode.REMOVING) { depth--; } } }
/** * Kontruktor pro tridu AutomatEdge. * * atribut endState urcuje do ktereho stavu prechod vede * atribut mode urcuje, zda pokud po hrane prejdeme, tak dochazi k zanorovani, ci vynorovani * atribut att Type urcuje, jakyho typu je atribut, pro nejz je konstruovana tato hrana **/ public AutomatEdge(AutomatState endState, EdgeMode mode, AttributeType attType) { this.endState = endState; this.edgeMode = mode; this.AttributeType = attType; }
/** * Kontruktor pro tridu AutomatEdge. * * atribut endState urcuje do ktereho stavu prechod vede * atribut mode urcuje, zda pokud po hrane prejdeme, tak dochazi k zanorovani, ci vynorovani **/ public AutomatEdge(AutomatState endState, EdgeMode mode) { this.endState = endState; this.edgeMode = mode; }
/** * Kontruktor pro tridu AutomatEdge. * * atribut endState urcuje do ktereho stavu prechod vede * atribut att Type urcuje, jakyho typu je atribut, pro nejz je konstruovana tato hrana **/ public AutomatEdge(AutomatState endState, AttributeType attType) : this(endState, EdgeMode.NONE) { this.attributeType = attType; }
/** * Kontruktor pro tridu AutomatEdge. * * atribut endState urcuje do ktereho stavu prechod vede **/ public AutomatEdge(AutomatState endState) : this(endState, EdgeMode.NONE) { }
/** * Konstruktor pro tridu AutomatState. * * atribut name udrcuje nazev stavu * atribut startState je odkaz na startovni stav aktualniho automatu **/ public AutomatState(String name, AutomatState startState) : this(name, false, startState) { }
public StateWordPair(AutomatState automatState, String word) { this.automatState = automatState; this.word = word; }
public StateWordPair(AutomatState automatState) : this(automatState, null) { }