public PrgState Execute(PrgState p) { IMyDictionary <String, int> symbolT = p.SymTable; int id = expFileId.Eval(symbolT); FileData fd; p.FileTable.TryGetValue(id, out fd); StreamReader bf = fd.FileDescriptor; String s = bf.ReadLine(); int number; if (s.Equals("")) { number = 0; } else { Int32.TryParse(s, out number); } if (symbolT.Exists(varName)) { symbolT.Update(varName, number); } else { symbolT.Add(varName, number); } return(p); }
public PrgState Execute(PrgState p) { try { this.Containsp(p); StreamReader fs = new StreamReader("read.txt"); FileData f = new FileData(fileName, fs); int id = IDGenerator.GenerateId(); p.FileTable.Add(id, f); IMyDictionary <String, int> st = p.SymTable; if (st.ContainsKey(var_file_id)) { st.Update(var_file_id, id); } else { st.Add(var_file_id, id); } } catch (NullReferenceException e) { Console.WriteLine(e.StackTrace); } return(p); }
public PrgState Execute(PrgState state) { IMyDictionary <string, int> sym = state.SymTable; IMyStack <IStmt> stk = state.ExeStack; int val = expr.Eval(sym); if (sym.Exists(id)) { sym.Update(id, val); } else { sym.Add(id, val); } return(state); }