/// <summary> /// 识别算符和界符 /// </summary> /// <param name="input">输入内容</param> /// <param name="index">位置索引</param> /// <param name="builder">临时存储变量</param> /// <param name="result">返回结果</param> private static bool identifyOperatorsOrSeparators(string input, ref int index, StringBuilder builder, List <KeyValuePair <string, int> > result) { bool returnValue = false; while (Tools.IsBelongToSeparatorsOrOperators(input, index)) { builder.Append(input[index]); if (input[index] == '>' || input[index] == '<' || input[index] == '!' || input[index] == '=') { if (input[index + 1] == '=') { builder.Append(input[index + 1]); index = index + 1; } } else if (input[index] == '|') { if (input[index + 1] == '|') { builder.Append(input[index + 1]); index = index + 1; } } else if (input[index] == '&') { if (input[index + 1] == '&') { builder.Append(input[index + 1]); index = index + 1; } } if (input[index] == '*') { if (input[index + 1] == '/') { builder.Append(input[index + 1]); index = index + 1; } } else if (input[index] == '/') { if (input[index + 1] == '*') { builder.Append(input[index + 1]); index = index + 1; } } string str = builder.ToString(); builder.Clear(); index++; returnValue = true; if (Operators.ContainsKey(str)) { int value; Operators.TryGetValue(str, out value); result.Add(new KeyValuePair <string, int>(str, value));//返回关键字的种别编码 } if (Separators.ContainsKey(str)) { int value; Separators.TryGetValue(str, out value); result.Add(new KeyValuePair <string, int>(str, value));//返回关键字的种别编码 } } return(returnValue); }