/// <summary> /// 添加一个到特定状态的转移。 /// </summary> /// <param name="state">要转移到的状态。</param> /// <param name="charClass">转移的字符类。</param> public void Add(NfaState state, string charClass) { if (!RegexCharClass.IsEmpty(charClass)) { charClassTransition = Nfa.GetCharClass(charClass); CharClassTarget = state; } }
/// <summary> /// Simple optimization. If a set is a singleton, an inverse singleton, /// or empty, it's transformed accordingly. /// </summary> internal RegexNode ReduceSet() { // Extract empty-set, one and not-one case as special if (RegexCharClass.IsEmpty(_str)) { _type = Nothing; _str = null; } else if (RegexCharClass.IsSingleton(_str)) { _ch = RegexCharClass.SingletonChar(_str); _str = null; _type += (One - Set); } else if (RegexCharClass.IsSingletonInverse(_str)) { _ch = RegexCharClass.SingletonChar(_str); _str = null; _type += (Notone - Set); } return(this); }
/// <summary> /// Simple optimization. If a set is a singleton, an inverse singleton, /// or empty, it's transformed accordingly. /// </summary> private RegexNode ReduceSet() { // Extract empty-set, one and not-one case as special if (RegexCharClass.IsEmpty(Str)) { NType = Nothing; Str = null; } else if (RegexCharClass.IsSingleton(Str)) { Ch = RegexCharClass.SingletonChar(Str); Str = null; NType += (One - Set); } else if (RegexCharClass.IsSingletonInverse(Str)) { Ch = RegexCharClass.SingletonChar(Str); Str = null; NType += (Notone - Set); } return(this); }