Exemple #1
0
        public void OneStep(string[] commandsStrings, bool isSuccessMessage = true)
        {
            if (Commands == null)
            {
                if (!RegisterCommands(commandsStrings))
                {
                    return;
                }
            }
            if (CurrentState == "q0")
            {
                if (isSuccessMessage)
                {
                    MessageBox.Show("Program succesfully ended!");
                }
                CurrentState = "q1";
                return;
            }
            var previousSetting = new PreviousSetting(CurrentState, Pointer.Value.Letter);

            if (!Commands.ContainsKey(previousSetting))
            {
                MessageBox.Show($"There is no commands for set ({CurrentState}, {pointer.Value.Letter})");
                CurrentState = "q1";
                return;
            }
            var newSetting = Commands[previousSetting];

            CurrentState         = newSetting.State;
            Pointer.Value.Letter = newSetting.Letter;
            ChangePointer(newSetting.Way);
        }
Exemple #2
0
        private void AddNewCommand(Match match)
        {
            var previousSetting = new PreviousSetting(
                match.Groups[2].Value,
                match.Groups[4].Value[0]);
            var newSetting = new NewSetting(
                match.Groups[8].Value,
                match.Groups[10].Value[0],
                match.Groups[12].Value[0]);

            Commands[previousSetting] = newSetting;
        }