public void SetFuncString(FuncString funcstring) { this.funcstring = funcstring; if (funcstring.GetFuncName() == "" && funcstring.GetFuncExpress() == "") { funcstring.AnalyseEquation(); } }
public void Run() { Console.WriteLine("Hello World! type: help() to know how to use"); while (InputData != "exit") { GetDataToInput(); // PushToShow("进入run程序"); funstring.SetString(InputData); int Extype = funstring.AnalyseEquation(); if (Extype == 1 || Extype == 4) //没有等号 判断为命令或求值之类 // PushToShow("不是存值"); { AnalyseInputG(Extype); continue; } //保存起来 string funs = funstring.GetFuncName(); CalData caldata = null; switch (Extype) { case 2: DealAssignment da = new DealAssignment(funstring.GetFuncExpress()); if (tdc.CheckName(funs)) { DataType getdt = new DataType(); try { getdt = da.GetDataType(); } catch (ExpError e) { PushToShow(e.Message); continue; } if (getdt == DataType.EXP) { try { ((ExpData)(da.GetCalData())).GetValueFinal(); //防止循环调用SimpleCal--> ReplaceParamers--> GetValueEx-->SimpleCal } catch (AssignedError e) { PushToShow(e.Message); continue; } } } try { caldata = da.GetCalData(); } catch (AssignedError e) { PushToShow(e.Message); continue; } break; case 3: caldata = new FuncData(funstring.GetFuncExpress(), funstring.GetParamers()); break; default: break; } if (CheckDuplicationName(funs)) { tdc.Remove(tdc.FindPosition(funs)); } if (funstring.CheckFunName(funs)) { PushToShow("Variable Name not acceptable!"); continue; } if (tdc.CreateData(funstring.GetFuncName(), caldata)) { PushToShow("数据已保存"); } else { PushToShow("Not accept input!"); } #region 之前写的不好就改了 // int a = funstring.FindOp(0, '='); // int b = funstring.FindOp(0, '('); // if (a != -1) { // // // if (b > a) { // funstring.AnalyseEquation(); //// funstring.ShowParamers(); // if(CheckDuplicationName()) continue; // // tdc.CreateData(funstring.GetFuncName(), funstring.GetFuncExpress(), funstring.GetParamers()); // } else { // funstring.AnalyseVariable(); //// funstring.ShowParamers(); // if(CheckDuplicationName()) continue; // tdc.CreateData(funstring.GetFuncName(), funstring.GetFuncExpress()); // } // } else { // // } #endregion } }