/** Opération binaire, Exp char Exp. */ public class ExpOpBin extends Exp { public Exp e1, e2; public char op; public ExpOpBin(Exp e1, char op, Exp e2) { super(e1, e2); this.e1 = e1; this.op = op; this.e2 = e2; } public String toString() { return super.toString() + "(" + op + ")"; } public Integer eval() { int i1 = e1.eval(); int i2 = e2.eval(); switch (op) { case '+' : return i1+i2; case '-' : return i1-i2; case '*' : return i1*i2; case '/' : return i1/i2; case '%' : return i1%i2; } return 0; } public void accept(AstVisitor v) { v.visit(this); } }