001package enumeration2; 002 003public class ExprFactory { 004 private ExprFactory() {} 005 static public Expr newConst(int v) { 006 return new Const(v); 007 } 008 static public Expr newPlus(Expr l, Expr r) { 009 return new BinOp(l, Op.ADD, r); 010 } 011 static public Expr newMinus(Expr l, Expr r) { 012 return new BinOp(l, Op.SUB, r); 013 } 014 static public Expr newMult(Expr l, Expr r) { 015 return new BinOp(l, Op.MUL, r); 016 } 017 static public Expr newQuot(Expr l, Expr r) { 018 return new BinOp(l, Op.DIV, r); 019 } 020}