1 package org.python.parser.ast; 3 import org.python.parser.SimpleNode; 4 import java.io.DataOutputStream ; 5 import java.io.IOException ; 6 7 public class BinOp extends exprType implements operatorType { 8 public exprType left; 9 public int op; 10 public exprType right; 11 12 public BinOp(exprType left, int op, exprType right) { 13 this.left = left; 14 this.op = op; 15 this.right = right; 16 } 17 18 public BinOp(exprType left, int op, exprType right, SimpleNode parent) { 19 this(left, op, right); 20 this.beginLine = parent.beginLine; 21 this.beginColumn = parent.beginColumn; 22 } 23 24 public String toString() { 25 StringBuffer sb = new StringBuffer ("BinOp["); 26 sb.append("left="); 27 sb.append(dumpThis(this.left)); 28 sb.append(", "); 29 sb.append("op="); 30 sb.append(dumpThis(this.op, operatorType.operatorTypeNames)); 31 sb.append(", "); 32 sb.append("right="); 33 sb.append(dumpThis(this.right)); 34 sb.append("]"); 35 return sb.toString(); 36 } 37 38 public void pickle(DataOutputStream ostream) throws IOException { 39 pickleThis(29, ostream); 40 pickleThis(this.left, ostream); 41 pickleThis(this.op, ostream); 42 pickleThis(this.right, ostream); 43 } 44 45 public Object accept(VisitorIF visitor) throws Exception { 46 return visitor.visitBinOp(this); 47 } 48 49 public void traverse(VisitorIF visitor) throws Exception { 50 if (left != null) 51 left.accept(visitor); 52 if (right != null) 53 right.accept(visitor); 54 } 55 56 } 57 | Popular Tags |