Esempio n. 1
0
 public int evaluate(ISymbolTable <string, int> s)
 {
     if (s.contains(this.name))
     {
         return(s.getValue(this.name));
     }
     else
     {
         throw new IException("no such variable " + this.name);
     }
 }
Esempio n. 2
0
        public PrgState execute(PrgState p)
        {
            ISymbolTable <string, int> t = p.getSymbolTable();
            int resExpr = this.expr.evaluate(t);

            if (t.contains(var))
            {
                t.setValue(var, resExpr);
            }
            else
            {
                t.add(var, resExpr);
            }

            return(p);
        }