Exemplo n.º 1
0
        RegExpDfaWave GetInitialStates()
        {
            RegExpDfaWave wave = new RegExpDfaWave(this._finalState);

            wave.AddStateWithEmptyTransitionsTargets(this._initialState);
            return(wave);
        }
Exemplo n.º 2
0
 /// <summary>
 ///
 /// </summary>
 /// <returns></returns>
 public RegExpAutoCompleteInfo GetAutoCompleteInfo()
 {
     if (this._autoCompleteInfo == null)
     {
         DfaAutoCompleteType none;
         GetAutoCompleteInfoTransitionsProcessingResult autoCompleteInfoTransitionsProcessing = this.GetAutoCompleteInfoTransitionsProcessing();
         if (autoCompleteInfoTransitionsProcessing._NonExactsFound)
         {
             none = DfaAutoCompleteType.None;
         }
         else if (autoCompleteInfoTransitionsProcessing._ExactCharFound)
         {
             if (!this.Contains(this._finalState))
             {
                 none = DfaAutoCompleteType.ExactChar;
             }
             else
             {
                 GetAutoCompleteInfoTransitionsProcessingResult result2 = autoCompleteInfoTransitionsProcessing;
                 RegExpDfaWave nextWave = this;
                 do
                 {
                     nextWave = nextWave.GetNextWave(result2._ExactChar);
                     result2  = nextWave.GetAutoCompleteInfoTransitionsProcessing();
                 }while ((!result2._NonExactsFound && result2._ExactCharFound) && !nextWave.Contains(this._finalState));
                 if (nextWave.Contains(this._finalState))
                 {
                     if (result2._NonExactsFound)
                     {
                         none = DfaAutoCompleteType.FinalOrExactBeforeFinalOrNone;
                     }
                     else
                     {
                         none = DfaAutoCompleteType.FinalOrExactBeforeFinal;
                     }
                 }
                 else
                 {
                     none = DfaAutoCompleteType.FinalOrExactBeforeNone;
                 }
             }
         }
         else
         {
             none = DfaAutoCompleteType.Final;
         }
         this._autoCompleteInfo = new RegExpAutoCompleteInfo(none, autoCompleteInfoTransitionsProcessing._ExactChar);
     }
     return(this._autoCompleteInfo);
 }
Exemplo n.º 3
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        public RegExpDfaWave GetNextWave(char input)
        {
            RegExpDfaWave wave = new RegExpDfaWave(this._finalState);

            foreach (RegExpState state in this)
            {
                foreach (Transition transition in state.Transitions)
                {
                    if (transition.IsMatch(input))
                    {
                        wave.AddStateWithEmptyTransitionsTargets(transition.Target);
                    }
                }
            }
            return(wave);
        }
Exemplo n.º 4
0
        string ToString(RegExpDfaWave wave)
        {
            ICollection <RegExpState>        allStates  = this.GetAllStates();
            Dictionary <RegExpState, string> dictionary = new Dictionary <RegExpState, string>();
            int num = 0;

            foreach (RegExpState state in allStates)
            {
                string str = string.Empty;
                if (object.ReferenceEquals(this._initialState, state))
                {
                    str = str + 'i';
                }
                if (object.ReferenceEquals(this._finalState, state))
                {
                    str = str + 'f';
                }
                if (str.Length == 0)
                {
                    num++;
                    str = num.ToString();
                }
                dictionary.Add(state, str);
            }
            string str2 = string.Empty;

            if (wave != null)
            {
                str2 = str2 + "Wave:";
                foreach (RegExpState state2 in wave)
                {
                    str2 = str2 + ' ';
                    str2 = str2 + dictionary[state2];
                }
                str2 = str2 + Environment.NewLine;
            }
            str2 = str2 + "Dfa:";
            foreach (RegExpState state3 in allStates)
            {
                foreach (Transition transition in state3.Transitions)
                {
                    string str3 = str2;
                    str2 = str3 + Environment.NewLine + dictionary[state3] + " " + transition.ToString() + " -> " + dictionary[transition.Target];
                }
            }
            return(str2);
        }
Exemplo n.º 5
0
        RegExpStringKey CacheWave(string str, RegExpStringKey next, char symbol, RegExpDfaWave candidateWave)
        {
            RegExpDfaWave wave;

            if (candidateWave.Count == 0)
            {
                return(new RegExpStringKey(str, candidateWave, next, symbol));
            }
            if (!this._statesCache.TryGetValue(candidateWave, out wave))
            {
                wave = candidateWave;
                this._statesCache.Add(wave, wave);
            }
            RegExpStringKey key = new RegExpStringKey(str, wave, next, symbol);

            this._stringsToStatesCache.Add(key);
            return(key);
        }