public ProgState execute(ProgState prog) { MyIDictionary <string, int> dict = prog.getDict(); try { if (dict.isDefined(this.id) == 1) { dict.update(id, exp.eval(dict)); } else { dict.add(id, exp.eval(dict)); } return(prog); } catch (StmtExceptions e) { throw new ControllerException(e); } catch (DivizionByZeroException e) { throw new ControllerException(e); } }
public PrgState execute(PrgState state) { MyIStack <IStmt> stack = state.getStk(); MyIDictionary <string, int> symTable = state.getSymTable(); int val = exp.Eval(symTable); if (symTable.isDefined(id)) { symTable.update(id, val); } else { symTable.put(id, val); } return(null); }
public ProgState execute(ProgState prog) { MyIDictionary <string, int> dict = prog.getDict(); MyIFileTable <Tuple> tpl = prog.getFile(); try { int val = exp.eval(dict); Tuple tup = tpl.get(val); if (tup != null) { string st = tup.getST().ReadLine(); if (st != null) { if (dict.isDefined(name) == 0) { dict.add(name, int.Parse(st)); } else { dict.update(name, int.Parse(st)); } } } else { throw new ControllerException("The file does not exist !!! \n"); } } catch (StmtExceptions e) { throw new ControllerException(e); } catch (IOException e) { Console.WriteLine(e.ToString()); } return(prog); }
public PrgState execute(PrgState state) { MyIDictionary <string, int> symTbl = state.getSymTable(); try { int val = exp.eval(symTbl); if (symTbl.isDefined(id)) { symTbl.update(id, val); } else { symTbl.add(id, val); } } catch (MyException ex) { throw new MyException("" + ex); } return(state); }
public PrgState execute(PrgState state) { MyIDictionary <string, int> symTbl = state.getSymTable(); MyIFileDictionary <int, KeyValuePair <string, StreamReader> > fileTable = state.getFileTable(); try { int val = exp_file_id.eval(symTbl); fileTable.lookup(val); StreamReader br = fileTable.get(val).Value; String line = br.ReadLine(); int value, x; if (line == null) { value = 0; } else { value = int.Parse(line); } if (symTbl.isDefined(var_name)) { symTbl.update(var_name, value); } else { symTbl.add(var_name, value); } } catch (MyException e) { throw new MyException("" + e); } return(state); }