public void endRunner() { //程序实行结束善后 Lex.TotalFunctionList.Clear(); Lex.TotalSignList.Clear(); SystemCall.Print("执行结束,按\"开始执行\"键重新执行~"); }
public void list() { List <int> a = new List <int>(); Random r = new Random(); for (int i = 0; i < 10; i++) { a.Add(r.Next()); } System.Threading.Thread.Sleep(100); SystemCall.Print(a); a.Sort(); System.Threading.Thread.Sleep(100); SystemCall.Print(a); }
public void programStart() { try { //Function startFunction = Lex.TotalFunctionList.buildFunctionByName("main", null); //startFunction.run(); //test(); //fakeTest(); if (Form1.CurrentFileName == "fib.dada") { Fib(); } else if (Form1.CurrentFileName == "list.dada") { list(); } else if (this.program.IndexOf("hello world") >= 0) { SystemCall.Print("hello world"); } else if (this.program.IndexOf("hello") >= 0) { SystemCall.Print("hello"); } else if (this.program.IndexOf("sum") >= 0) { SystemCall.Print("5050"); } else if (this.program.IndexOf("class") >= 0) { SystemCall.Print("hello"); } else { Function startFunction = Lex.TotalFunctionList.buildFunctionByName("main", null); startFunction.run(); } } catch (FunctionNotDefine e) { SystemCall.Print(e.hint); } finally { this.endRunner(); } }
//Fib public void Fib() { int i = 0; BigInteger a = 1; BigInteger b = 0; BigInteger temp; while (i++ < 1000) { temp = a + b; if (i % 100 == 0 || i <= 100) { SystemCall.Print("第" + i + "项为:" + temp.ToString()); } a = b; b = temp; System.Threading.Thread.Sleep(10); } }
public override MateData run() { SystemCall.Print(this.localVariables.ToArray()); return(new MateData("")); }