public static NumMatch Match(string input, int start) { var nm = new NumMatch(); var typeCache = NumType.unknown; if (string.IsNullOrEmpty(input) || start < 0) { return(nm); } DFAState cur = _start; DFAState pre = null; for (int i = start; i < input.Length; i++) { pre = cur; cur = cur.Process(input[i]); if (cur == null) { if (!pre.IsTerminal) // 上一个状态非终止状态 { nm.Length--; } return(nm); } if (cur.Type == NumType.signed) { nm.IsSigned = true; } nm.Length++; if (cur.IsTerminal) { if (typeCache > nm.Type) { nm.Type = typeCache; } } if (cur.Type > nm.Type) { if (cur.IsTerminal) { nm.Type = cur.Type; } else { typeCache = cur.Type; } } } return(nm); }