public void Execute() { if (Lexemlist == null) { throw new Exception("Oops, lexem list are empty:("); } Translator.Lexem temp = Lexemlist[++counterLexem]; SnapList.Add(new Snap(temp.Substring, Number, Stack.ToList())); Console.WriteLine("#" + Number); try { // State nextState = map[temp.Code]; IMapValue nextIMap = Map[temp.Code]; State nextState; if (nextIMap is MapValue) { MapValue mapValue = nextIMap as MapValue; nextState = mapValue.NextState; Stack.Push(mapValue.InStack); } else { nextState = nextIMap as State; } if (nextState != null) { nextState.Execute(); } else if (Map.Keys.Contains(temp.Code)) { //counterLexem--; if (equal != null) { equal.Invoke(); } else { throw new Exception("the value for this key does not exist"); } } else { throw new Exception("Error"); } } catch (KeyNotFoundException) { counterLexem--; if (notEqual != null) { notEqual.Invoke(); } else { throw new Exception("notEqual is empty"); } } }
public RowMapper(IMapValue valueMapper) { _valueMapper = valueMapper; }
//public State(int number, Action notEqual, Action equal, int code, IState state, IState inStack = null, bool isEnd = true) //{ // this.map = new Dictionary<int, IMapValue>(); // this.number = number; // this.notEqual = notEqual; // this.equal = equal; // this.inStack = (State)inStack; // this.isEnd = isEnd; // AddReference(code, (State)state); //} //public void AddReference(int code, IState state, IState inStack) //{ // map.Add(code, (State)state); //} public void AddReference(int code, IMapValue state) { Map.Add(code, state); }