public override void AddOperation(int[] prefixTable) { // Add for first symbol in pattern ShiftTable.Add("0", new Dictionary <char, Move> { { Pattern[0], new Move(nextState: "1", symb: Pattern[0], shift: 1) } }); ShiftTable["0"].Add('$', new Move(nextState: "0", symb: '$', shift: 1)); for (int i = 1; i < prefixTable.Length; i++) { string state = i.ToString(); var patChar = Pattern[i]; if (!ShiftTable.ContainsKey(state)) { if (i == prefixTable.Length - 1) { ShiftTable.Add(state, new Dictionary <char, Move> { { patChar, new Move(nextState: "y", symb: patChar, shift: 1) } }); } else { ShiftTable.Add(state, new Dictionary <char, Move> { { patChar, new Move(nextState: (i + 1).ToString(), symb: patChar, shift: 1) } }); } } ShiftTable[state].Add('$', new Move(nextState: prefixTable[i - 1].ToString(), symb: '$', shift: 0)); } }
public override void AddOperation(string state, string character, string[] operation) { var nextState = operation[0]; var symbInstead = operation[1].ToCharArray()[0]; int.TryParse(operation[2], out var shift); Move mv = new Move(nextState: nextState, symb: symbInstead, shift: shift); if (!ShiftTable.ContainsKey(state)) { ShiftTable.Add(state, new Dictionary <char, Move> { { character.ToCharArray()[0], mv } }); } else { ShiftTable[state].Add(character.ToCharArray()[0], mv); } }