package cmaj7.tree;
 
public class BinOpExp implements Node {
	static public enum Operator{
		add("+"), sub("-"), mult("*"), div("/"), eq("=="), neq("/="), lt("<"), le("<="), gt(">"), ge(">="), and("&&"), or("||");
        String opSymbol;

		private Operator(String opSymbol) {
			this.opSymbol = opSymbol;
		}

		public Integer calc(int l, int r) {
			switch (this){
			case add: return l+r;
			case sub: return l-r;
			case mult: return l*r;
			case div: return l/r;
			case eq: return l==r?1:0 ;
			}
			return null;
		}
		
	}

	Node lhs;
	Operator op;
	Node rhs;
	public BinOpExp(Node lhs, Operator op, Node rhs) {
		super();
		this.lhs = lhs;
		this.op = op;
		this.rhs = rhs;
	}
	@Override
	public <R> R welcome(Visitor<R> vs) {
		return vs.visit(this);
	}

}
