public void parse() { bool isStates = false; while (!this.reader.EndOfStream) { string line = reader.ReadLine (); if (line == "states") { isStates = true; continue; } else if (line == "transitions") { isStates = false; continue; } if (isStates) { string[] tokens = line.Split (new char[]{' '}); State state = new State (tokens [0], tokens [1] == "1"); Point point = new Point(int.Parse(tokens[2]), int.Parse(tokens[3])); GUIState guiState = new GUIState (state, point); this.stateGUITable.Add(guiState.getState().StateID, guiState); } else { string[] tokens = line.Split (new char[]{' '}); TapeMoves move = TapeMoves.Down; switch (tokens [4][0]) { case 'l': move = TapeMoves.Left; break; case 'r': move = TapeMoves.Right; break; case 'u': move = TapeMoves.Up; break; case 'd': move = TapeMoves.Down; break; case 's': move = TapeMoves.Stable; break; } Transition transition = new Transition (this.stateGUITable [tokens [0]].getState(), this.stateGUITable [tokens [1]].getState(), tokens [2] [0], tokens [3] [0], move); GUITransition guiTransition; if (tokens.Length == 6) guiTransition = new GUITransition (transition, double.Parse (tokens [5]), transition.From == transition.To); else guiTransition = new GUITransition (transition, 0, false); KeyValuePair<State, char> key = new KeyValuePair<State, char> (guiTransition.getTransition ().From, guiTransition.getTransition ().Read); this.edgeGUITable.Add (key, guiTransition); } } }
public Transition(State from, State to, char read, char write, TapeMoves movement) { this.from = from; this.to = to; this.read = read; this.write = write; this.movement = movement; }
public void parse() { bool isStates = false; while (!this.reader.EndOfStream) { string line = reader.ReadLine (); if (line == "states") { isStates = true; continue; } else if (line == "transitions") { isStates = false; continue; } if (isStates) { string[] tokens = line.Split (new char[]{' '}); State state = new State (tokens [0], tokens [1] == "1"); this.states.Add (state.StateID, state); } else { string[] tokens = line.Split (new char[]{' '}); TapeMoves move = TapeMoves.Down; switch (tokens [4][0]) { case 'l': move = TapeMoves.Left; break; case 'r': move = TapeMoves.Right; break; case 'u': move = TapeMoves.Up; break; case 'd': move = TapeMoves.Down; break; case 's': move = TapeMoves.Stable; break; } Transition transition = new Transition (this.states [tokens [0]], this.states [tokens [1]], tokens [2] [0], tokens [3] [0], move); this.transitions.Add (transition); } } }
private bool searchForDublication(State from, State to, char read) { List<GUITransition> value = new List<GUITransition>(this.edgeGUITable.Values); foreach (GUITransition guiT in value) { Transition t = guiT.getTransition(); if (t.From == from && t.To == to && t.Read != read) return true; else if (t.From == from && t.To == to && t.Read == read) return false; } return false; }
public void reset() { this.currentState = this.startState; }
public void addState(State state) { if (this.startState == null) this.startState = this.currentState = state; this.stateTable.Add (state.StateID, state); }
public GUIState(State state, Point position) { this.state = state; this.position = position; }
public GUIState(string stateID, bool isFinal, Point position) { this.state = new State (stateID, isFinal); this.position = position; }