1 package polyglot.visit; 2 3 import polyglot.ast.*; 4 import polyglot.frontend.*; 5 import polyglot.util.*; 6 7 import java.io.*; 8 import java.util.*; 9 10 17 public class PrettyPrinter 18 { 19 protected boolean appendSemicolon = true; 20 protected boolean printType = true; 21 22 public PrettyPrinter() { 23 } 24 25 27 public boolean appendSemicolon() { 28 return appendSemicolon; 29 } 30 31 33 public boolean appendSemicolon(boolean a) { 34 boolean old = this.appendSemicolon; 35 this.appendSemicolon = a; 36 return old; 37 } 38 39 41 public boolean printType() { 42 return printType; 43 } 44 45 47 public boolean printType(boolean a) { 48 boolean old = this.printType; 49 this.printType = a; 50 return old; 51 } 52 53 59 public void print(Node parent, Node child, CodeWriter w) { 60 if (child != null) { 61 child.del().prettyPrint(w, this); 62 } 63 } 64 65 67 public void printAst(Node ast, CodeWriter w) { 68 print(null, ast, w); 69 70 try { 71 w.flush(); 72 } 73 catch (IOException e) { 74 } 75 } 76 } 77 | Popular Tags |