public int evaluate(Utilities.IDictionary <string, int> dic) { int left = this.left.evaluate(dic); int right = this.right.evaluate(dic); switch (oper) { case "+": return(left + right); case "-": return(left - right); case "*": return(left * right); case "/": if (right == 0) { throw new DivisionByZero("Division by 0 is not allowed!"); } return(left / right); } throw new InvalidOperator("Invalid operator!"); }
public ProgramState(IStack <IStmt> stack, Utilities.IDictionary <string, int> symTable, Utilities.IList <int> list, Utilities.IDictionary <int, StreamReader> file) { this.stack = stack; this.SymTable = symTable; this.list = list; this.FileTable = file; }
public int evaluate(Utilities.IDictionary <string, int> dic) { return(number); }
public int evaluate(Utilities.IDictionary <string, int> dic) { return(dic.getValue(id)); }