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