public FunctionContext(string param_, int no_, long funcno_, ColumnDataGenerator gen) : base(param_, no_) { string eval = gen.funcsDict[funcno_]; //this.Funcname = funcName_; //関数名 Regex regex = new System.Text.RegularExpressions.Regex(@"([a-zA-Z0-9]+)[\(].*[\)]"); MatchCollection matchCol = regex.Matches(eval); if (matchCol.Count > 0 && matchCol[0].Groups.Count > 1) { this.Funcname = matchCol[0].Groups[1].Value; //MessageBox.Show("Func:" + this.Funcname); MyLogSingleton.getIncetance().DoLogWithDate(TraceEventType.Verbose, 1,"Func:"+this.Funcname); //this.InnerGen = new ContextColumnDataGenerator(this.Funcname, this.innerCol); } ArgSelector asel = new ArgSelector(); this.Args = asel.SelectArgs(eval.Substring(this.Funcname.Length),1); foreach (string arg in this.Args) { //MessageBox.Show("Arg:"+arg); MyLogSingleton.getIncetance().DoLogWithDate(TraceEventType.Verbose, 1, "Arg:" + arg); } //引数部取得 string inner = eval.Replace(this.Funcname + "(", ""); inner = inner.Substring(0, inner.Length - 1); //引数部 /* Regex regex2 = new System.Text.RegularExpressions.Regex(@"([a-zA-Z0-9]+[\(][^\)]*[\)])"); MatchCollection matchCol2 = regex2.Matches(inner); string proccessedParam = inner; long funcNo = 1; if (matchCol2.Count > 0 && matchCol2[0].Groups.Count > 1) { foreach (Match m in matchCol2) { //this.innerCol = matchCol2[0].Groups[1].Value; MessageBox.Show("innerFunc:" + m.Groups[1].Value); string func = m.Groups[1].Value; string funcID = ContextMaxFunctionDataGenerator.funcHeader + funcNo.ToString(); proccessedParam = proccessedParam.Replace(func, funcID); this.funcsDict.Add(funcNo, func); funcNo++; } } */ //Regex regexMin = new System.Text.RegularExpressions.Regex(@"([a-zA-Z0-9]+[\(][^\)]*[\)])+"); //MatchCollection matchColMin = regexMin.Matches(inner); FunctionSelector sel = new FunctionSelector(); List<string> funcs = sel.SelectFunctions(inner, 1); //if (matchColMin.Count > 0 && matchColMin[0].Groups.Count > 1) if( funcs.Count > 0 ) { //MessageBox.Show("min"); MyLogSingleton.getIncetance().DoLogWithDate(TraceEventType.Verbose, 1, "min:"); this.InnerMinGen = new ContextMinFunctionDataGenerator("", inner); } else { //MessageBox.Show("max"); MyLogSingleton.getIncetance().DoLogWithDate(TraceEventType.Verbose, 1, "max:"); this.InnerMaxGen = new ContextMaxFunctionDataGenerator("", inner); } /* if (this.Funcname != null && this.innerCol != null) { this.InnerGen = new ContextMinFunctionDataGenerator(this.Funcname, this.innerCol); } */ }
protected override List<Context> ParseParam(string inner) { //Regex regex2 = new System.Text.RegularExpressions.Regex(@"([a-zA-Z0-9]+[\(][^\)]*[\)])"); //MatchCollection matchCol2 = regex2.Matches(inner); FunctionSelector sel = new FunctionSelector(); List<string> funcs = sel.SelectFunctions(inner, 1); /* MessageBox.Show("FNNum-FNLine:" + inner); MessageBox.Show("FNNum:"+funcs.Count.ToString()); foreach (string func in funcs) { MessageBox.Show(func); } */ string proccessedParam = inner; long funcNo = 1; //if (matchCol2.Count > 0 && matchCol2[0].Groups.Count > 1) if( funcs.Count > 0 ) { //foreach (Match m in matchCol2) foreach(string func in funcs ) { //this.innerCol = matchCol2[0].Groups[1].Value; //MessageBox.Show("InnerFunc:" + m.Groups[1].Value); //string func = m.Groups[1].Value; string funcID = ContextMaxFunctionDataGenerator.funcHeader + funcNo.ToString(); proccessedParam = proccessedParam.Replace(func, funcID); this.funcsDict.Add(funcNo, func); funcNo++; } } /* Regex regex = new System.Text.RegularExpressions.Regex(@"([a-zA-Z0-9]+[\(].*[\)])+"); MatchCollection matchCol = regex.Matches(param); List<string> lstAtoms = new List<string>(); string proccessedParam = param; long funcNo = 1; //Dictionary<long, string> funcs = new Dictionary<long, string>(); for (int i = 0; i < matchCol.Count; i++) { string func = matchCol[i].Value; string funcID = ContextMaxFunctionDataGenerator.funcHeader + funcNo.ToString(); MessageBox.Show("Func0:" + func); proccessedParam = proccessedParam.Replace(func, funcID); this.funcsDict.Add(funcNo, func); funcNo++; } */ /* StringBuilder collineSb = new StringBuilder(); foreach (string col in lstAtoms) { collineSb.Append(col); } */ string colline = proccessedParam; //MessageBox.Show("LineMin:"+colline); MyLogSingleton.getIncetance().DoLogWithDate(TraceEventType.Verbose, 1, "LineMin:" + colline); string param = colline; char[] sep = { '|' }; string[] atoms = param.Split(sep); //string[] atoms = { "" }; //lstAtoms.ToArray<string>(); int no = 0; List<Context> cxts = new List<Context>(); ContextFactory fac = new ContextFactory(); Context cxt = null; no = 1; foreach (string atom in atoms) { if (string.IsNullOrEmpty(atom)) { continue; } if (atom.Contains(ContextMaxFunctionDataGenerator.funcHeader)) { Regex regex3 = new System.Text.RegularExpressions.Regex(@"("+ContextMaxFunctionDataGenerator.funcHeader+"[a-zA-Z0-9]+)"); MatchCollection matchCol3 = regex3.Matches(atom); if (matchCol3.Count > 0) { string num = matchCol3[0].Value.Replace(ContextMaxFunctionDataGenerator.funcHeader, ""); long funcNo_ = 0; long.TryParse(num, out funcNo_); string func = this.FuncsDict[funcNo_]; cxt = fac.Create(atom, no, funcNo_, this); } } else { cxt = fac.Create(atom, no); } no++; cxts.Add(cxt); } return cxts; }