public static void Main(string[] args) { IExeStack <IStatement> stack = new ExeStack <IStatement>(); Utils.IDictionary <string, int> dict = new MyDictionary <string, int>(); IMyList <int> output = new MyList <int>(); FileTable <int, FileData> fileTable = new FileTable <int, FileData>(); IStatement s1 = new OpenRFile("var_f", "C:\\Users\\Emy\\RiderProjects\\lab7\\text1.txt"); IStatement s2 = new ReadFile(new VarExp("var_f"), "var_c"); IStatement thenS1 = new ReadFile(new VarExp("var_f"), "var_c"); IStatement thenS2 = new PrintStmt(new VarExp("var_c")); IStatement thenS = new CompStmt(thenS1, thenS2); IStatement elseS = new PrintStmt(new ConstExp(0)); IStatement s3 = new IfStmt(new VarExp("var_c"), thenS, elseS); IStatement s4 = new CloseRFile(new VarExp("var_f")); IStatement s5 = new CompStmt(s1, s2); IStatement s6 = new CompStmt(s3, s4); IStatement s7 = new CompStmt(s5, s6); stack.push(s7); PrgState state = new PrgState(dict, stack, output, fileTable); Controller.Controller ctrl = new Controller.Controller(state); TextMenu menu = new TextMenu(); menu.addCommand(new ExitCommand("0", "exit")); menu.addCommand(new RunExample("1", "example_1", ctrl)); menu.show(); }
public static void Main(string[] args) { IMyStack <IStatement> stack1 = new MyStack <IStatement>(); IMyDict <string, int> dict1 = new MyDict <string, int>(); IMyList <int> output1 = new MyList <int>(); FileTable <int, FileData> fileTable1 = new FileTable <int, FileData>(); IStatement i1 = new OpenRFile("var_f", "../../../intrare.txt"); IStatement i2 = new ReadFile(new VarExpression("var_f"), "var_c"); IStatement i3 = new ReadFile(new VarExpression("var_f"), "var_c"); IStatement i4 = new PrintStatement(new VarExpression("var_c")); IStatement i5 = new CompStatement(i3, i4); IStatement i6 = new PrintStatement(new ConstExpression(0)); IStatement i7 = new IfStatement(new VarExpression("var_c"), i5, i6); IStatement i8 = new CloseRFile(new VarExpression("var_f")); IStatement i9 = new CompStatement(i1, i2); IStatement i10 = new CompStatement(i7, i8); IStatement i11 = new CompStatement(i9, i10); stack1.Push(i11); PrgState state1 = new PrgState(dict1, stack1, output1, fileTable1); IRepository repo1 = new Repository.Repository(); repo1.AddProg(state1); Controller.Controller ctrl1 = new Controller.Controller(repo1); /*Exemplu 111111111111111111111111111111111111111111111*/ IMyStack <IStatement> stack2 = new MyStack <IStatement>(); IMyDict <string, int> dict2 = new MyDict <string, int>(); IMyList <int> output2 = new MyList <int>(); FileTable <int, FileData> fileTable2 = new FileTable <int, FileData>(); IStatement j1 = new OpenRFile("a", "../../../intrare.txt"); IStatement j2 = new CompStatement(new ReadFile(new VarExpression("a"), "p"), new PrintStatement(new VarExpression("p"))); IStatement j3 = new IfStatement(new VarExpression("p"), new CompStatement(new ReadFile(new VarExpression("a"), "q"), new PrintStatement(new VarExpression("q"))), new PrintStatement(new ConstExpression(0))); IStatement j4 = new CloseRFile(new VarExpression("a")); IStatement j5 = new CompStatement(j2, new CompStatement(j3, j4)); IStatement j6 = new CompStatement(j1, j5); stack2.Push(j6); PrgState state2 = new PrgState(dict2, stack2, output2, fileTable2); IRepository repo2 = new Repository.Repository(); repo2.AddProg(state2); Controller.Controller ctrl2 = new Controller.Controller(repo2); /*Exemplu 222222222222222222222222222222222222222222222*/ TextMenu menu = new TextMenu(); menu.AddCommand(new ExitCommand("0", "exit \n")); menu.AddCommand(new RunCommand("1", "\t" + i11.ToString() + "\n", ctrl1)); menu.AddCommand(new RunCommand("2", "\t" + j6.ToString() + "\n", ctrl2)); menu.Show(); }