private void AddSimpleNext(string actual, string next, List <char> interval)
        {
            AbstractRule <char> roleChar      = new SimpleListIncludeRule <char>(1, interval);
            AbstractRule <char> roleEmpty     = new SimpleIncludeRule <char>(SYMBOLEMPTY, ValueDefaultTransitions);
            AbstractRule <char> roleExclusion = new SimpleListExclusionRule <char>(interval, alphabet.ToList(), ValueDefaultTransitions);

            Automa.AddTransition(actual, next, roleChar);
            Automa.AddTransition(actual, next, roleEmpty);
            Automa.AddTransition(actual, actual, roleExclusion);
            //Automa.AddTransition(actual, actual, roleEmpty);
            Automa.AddTransition(actual, next, roleExclusion);
        }
        public virtual Automa <char> RegexToAutoma()
        {
            Automa = new Automa <char>(GetAlphabet().ToList(), SYMBOLEMPTY);
            var stateInitial = Automa.AddState(NextNameState(), 1, 0);

            if (string.IsNullOrEmpty(RegexFuzzy))
            {
                return(Automa);
            }

            string temp   = string.Empty;
            bool   escape = false;

            for (int i = 0; i < RegexFuzzy.Length; i++)
            {
                if (RegexFuzzy[i] == '\\')
                {
                    //NOTHING
                }
                else if (escape)
                {
                    switch (RegexFuzzy[i])
                    {
                    case 't':
                        temp += '\t';
                        break;

                    case 'n':
                        temp += '\n';
                        break;

                    case 'r':
                        temp += '\r';
                        break;

                    default:
                        temp += RegexFuzzy[i];
                        break;
                    }
                }
                else
                {
                    switch (RegexFuzzy[i])
                    {
                    case '?':
                        temp += "{0,1}";
                        break;

                    case '+':
                        temp += "{1,}";
                        break;

                    case '*':
                        temp += "{0,}";
                        break;

                    default:
                        temp += RegexFuzzy[i];
                        break;
                    }
                }

                if (RegexFuzzy[i] == '\\')
                {
                    escape = true;
                }
                else
                {
                    escape = false;
                }
            }

            RegexFuzzy = temp;//;RegexFuzzy.Replace("?", "{0,1}").Replace("+", "{1,}").Replace("*", "{0,}");

            List <State <char> > lastStates = new List <State <char> >();

            lastStates.Add(stateInitial);

            for (int i = 0; i < RegexFuzzy.Length; i++)
            {
                bool final = (i == RegexFuzzy.Length - 1);

                TypeCharEnum typeActual = GetTypeChar(RegexFuzzy[i]);

                TypeCharEnum typeNext = TypeCharEnum.Final;

                if (!final)
                {
                    typeNext = GetTypeChar(RegexFuzzy[i + 1]);
                }
                if (typeActual == TypeCharEnum.Interval || typeActual == TypeCharEnum.Symbol || (typeActual == TypeCharEnum.Loop && typeNext == TypeCharEnum.Final))
                {
                    var         nextState = Automa.AddState(NextNameState(), 0, Convert.ToInt16(final));
                    List <char> interval  = null;
                    if (ValidateInterval(i))
                    {
                        interval = AddInterval(ref i, nextState, lastStates);

                        typeNext = TypeCharEnum.Final;
                        final    = (i == RegexFuzzy.Length - 1);
                        if (!final)
                        {
                            typeNext = GetTypeChar(RegexFuzzy[i + 1]);
                        }
                    }
                    else //if ()
                    {
                        foreach (var item in lastStates)
                        {
                            AddSimpleNext(item.Name, nextState.Name, RegexFuzzy[i]);
                        }
                    }

                    if (typeNext == TypeCharEnum.Loop)
                    {
                        AddLoop(ref i, lastStates, nextState, final, interval);
                        final = (i == RegexFuzzy.Length - 1);
                    }
                    else
                    {
                        lastStates.Clear();
                        lastStates.Add(nextState);
                    }

                    if (final)
                    {
                        List <char> inclusion = alphabet.ToList();
                        inclusion.Add(SYMBOLEMPTY);
                        AbstractRule <char> roleAlphabet = new SimpleListIncludeRule <char>(ValueDefaultTransitions, inclusion);
                        foreach (var item in lastStates)
                        {
                            item.PertinenceFinal = 1;
                            Automa.FinalStates.Add(item);
                            Automa.AddTransition(item.Name, item.Name, roleAlphabet);
                        }
                    }
                }
            }

            return(Automa);
        }