private static List <StrSpan> 在_小括号中括号单引号双引号_之外用逗号_Split(char[] chars, int beginIndex, int endIndex) { List <StrSpan> list = new List <StrSpan>(); //StrSpan span = StrUtil.Trim(chars, beginIndex, endIndex, Parser._whiteSpaces); //if (span.isEmpty) //{ // list.Add(span); // return list; //} List <表达式段> list段 = Parser._小括号中括号单引号双引号_分段(chars, beginIndex, endIndex); list段 = Parser.去掉空白段(chars, list段); int p = beginIndex, q; 表达式段 段; for (int i = 0; i < list段.Count; i++) { 段 = list段[i]; if (段.type != 表达式段_Type.普通段) { continue; } p = 段.iLeft; while (true) { q = StrUtil.FindForward(chars, p, 段.iRight, ','); if (q == -1) { break; } list.Add(StrUtil.Trim(chars, p, q - 1, Parser._whiteSpaces)); p = q + 1; } } //if (list.Count == 0) //{ // list.Add(span); // return list; //} list.Add(StrUtil.Trim(chars, p, endIndex, Parser._whiteSpaces)); return(list); }
public static List <表达式段> _小括号中括号单引号双引号_分段(char[] chars, int beginIndex, int endIndex) { char c; List <表达式段> list = new List <表达式段>(); int j; for (int i = beginIndex; i <= endIndex;) { c = chars[i]; if (c == '(') { j = Parser.Find_小括号_右(chars, i + 1, endIndex); if (j == -1) { throw new 语法错误_Exception("未结束的小括号,缺少右小括号 。", chars, i); } list.Add(new 表达式段(i, j, 表达式段_Type.小括号段)); i = j + 1; continue; } if (c == '[') { j = Parser.Find_中括号_右(chars, i + 1, endIndex); if (j == -1) { throw new 语法错误_Exception("未结束的中括号,缺少右中括号 。", chars, i); } list.Add(new 表达式段(i, j, 表达式段_Type.中括号段)); i = j + 1; continue; } if (c == '\'') { j = Parser.Find_单引号_右(chars, i + 1, endIndex); if (j == -1) { throw new 语法错误_Exception("未结束的单括号,缺少右单引号 。", chars, i); } list.Add(new 表达式段(i, j, 表达式段_Type.单引号段)); i = j + 1; continue; } if (c == '"') { j = Parser.Find_双引号_右(chars, i + 1, endIndex); if (j == -1) { throw new 语法错误_Exception("未结束的单括号,缺少右双引号 。", chars, i); } list.Add(new 表达式段(i, j, 表达式段_Type.双引号段)); i = j + 1; continue; } j = StrUtil.FindForward(chars, i + 1, endIndex, _左小括号左中括号单引号双引号); if (j == -1) { list.Add(new 表达式段(i, endIndex, 表达式段_Type.普通段)); break; } list.Add(new 表达式段(i, j - 1, 表达式段_Type.普通段)); i = j; } return(list); }