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 Compare extends exprType implements cmpopType { 8 public exprType left; 9 public int[] ops; 10 public exprType[] comparators; 11 12 public Compare(exprType left, int[] ops, exprType[] comparators) { 13 this.left = left; 14 this.ops = ops; 15 this.comparators = comparators; 16 } 17 18 public Compare(exprType left, int[] ops, exprType[] comparators, 19 SimpleNode parent) { 20 this(left, ops, comparators); 21 this.beginLine = parent.beginLine; 22 this.beginColumn = parent.beginColumn; 23 } 24 25 public String toString() { 26 StringBuffer sb = new StringBuffer ("Compare["); 27 sb.append("left="); 28 sb.append(dumpThis(this.left)); 29 sb.append(", "); 30 sb.append("ops="); 31 sb.append(dumpThis(this.ops, cmpopType.cmpopTypeNames)); 32 sb.append(", "); 33 sb.append("comparators="); 34 sb.append(dumpThis(this.comparators)); 35 sb.append("]"); 36 return sb.toString(); 37 } 38 39 public void pickle(DataOutputStream ostream) throws IOException { 40 pickleThis(34, ostream); 41 pickleThis(this.left, ostream); 42 pickleThis(this.ops, ostream); 43 pickleThis(this.comparators, ostream); 44 } 45 46 public Object accept(VisitorIF visitor) throws Exception { 47 return visitor.visitCompare(this); 48 } 49 50 public void traverse(VisitorIF visitor) throws Exception { 51 if (left != null) 52 left.accept(visitor); 53 if (comparators != null) { 54 for (int i = 0; i < comparators.length; i++) { 55 if (comparators[i] != null) 56 comparators[i].accept(visitor); 57 } 58 } 59 } 60 61 } 62 | Popular Tags |