1 9 10 24 25 package org.nfunk.jep; 26 27 public class ParserDumpVisitor implements ParserVisitor 28 { 29 private int indent = 0; 30 31 private String indentString() { 32 StringBuffer sb = new StringBuffer (); 33 for (int i = 0; i < indent; ++i) { 34 sb.append(" "); 35 } 36 return sb.toString(); 37 } 38 39 public Object visit(SimpleNode node, Object data) throws ParseException { 40 System.out.println(indentString() + node + 41 ": acceptor not unimplemented in subclass?"); 42 ++indent; 43 data = node.childrenAccept(this, data); 44 --indent; 45 return data; 46 } 47 48 public Object visit(ASTStart node, Object data) throws ParseException { 49 System.out.println(indentString() + node); 50 ++indent; 51 data = node.childrenAccept(this, data); 52 --indent; 53 return data; 54 } 55 56 public Object visit(ASTFunNode node, Object data) throws ParseException { 57 System.out.println(indentString() + node); 58 ++indent; 59 data = node.childrenAccept(this, data); 60 --indent; 61 return data; 62 } 63 64 public Object visit(ASTVarNode node, Object data) throws ParseException { 65 System.out.println(indentString() + node); 66 ++indent; 67 data = node.childrenAccept(this, data); 68 --indent; 69 return data; 70 } 71 72 public Object visit(ASTConstant node, Object data) throws ParseException { 73 System.out.println(indentString() + node); 74 ++indent; 75 data = node.childrenAccept(this, data); 76 --indent; 77 return data; 78 } 79 } 80 81 82 | Popular Tags |