Beispiel #1
0
        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!");
        }
Beispiel #2
0
 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;
 }
Beispiel #3
0
 public int evaluate(Utilities.IDictionary <string, int> dic)
 {
     return(number);
 }
Beispiel #4
0
 public int evaluate(Utilities.IDictionary <string, int> dic)
 {
     return(dic.getValue(id));
 }