1 package org.jboss.aop.annotation.ast; 2 3 4 5 public class AnnotationParserTester implements AnnotationParserVisitor 6 { 7 private int indent = 0; 8 9 private String indentString() 10 { 11 StringBuffer sb = new StringBuffer (); 12 for (int i = 0; i < indent; ++i) 13 { 14 sb.append(" "); 15 } 16 return sb.toString(); 17 } 18 19 public Object visit(ASTSingleMemberValue node, Object data) 20 { 21 System.out.println(indentString() + node); 22 ++indent; 23 data = node.childrenAccept(this, data); 24 --indent; 25 return data; 26 } 27 28 public Object visit(SimpleNode node, Object data) 29 { 30 System.out.println(indentString() + node + 31 ": acceptor not unimplemented in subclass?"); 32 ++indent; 33 data = node.childrenAccept(this, data); 34 --indent; 35 return data; 36 } 37 38 public Object visit(ASTStart node, Object data) 39 { 40 System.out.println(indentString() + node); 41 ++indent; 42 data = node.childrenAccept(this, data); 43 --indent; 44 return data; 45 } 46 47 public Object visit(ASTAnnotation node, Object data) 48 { 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(ASTMemberValuePairs node, Object data) 57 { 58 System.out.println(indentString() + node); 59 ++indent; 60 data = node.childrenAccept(this, data); 61 --indent; 62 return data; 63 } 64 65 public Object visit(ASTMemberValuePair node, Object data) 66 { 67 System.out.println(indentString() + node); 68 ++indent; 69 data = node.childrenAccept(this, data); 70 --indent; 71 return data; 72 } 73 74 public Object visit(ASTMemberValueArrayInitializer node, Object data) 75 { 76 System.out.println(indentString() + node); 77 ++indent; 78 data = node.childrenAccept(this, data); 79 --indent; 80 return data; 81 } 82 83 public Object visit(ASTIdentifier node, Object data) 84 { 85 System.out.println(indentString() + node); 86 ++indent; 87 data = node.childrenAccept(this, data); 88 --indent; 89 return data; 90 } 91 92 public Object visit(ASTString node, Object data) 93 { 94 System.out.println(indentString() + node); 95 ++indent; 96 data = node.childrenAccept(this, data); 97 --indent; 98 return data; 99 } 100 101 public Object visit(ASTChar node, Object data) 102 { 103 System.out.println(indentString() + node); 104 ++indent; 105 data = node.childrenAccept(this, data); 106 --indent; 107 return data; 108 } 109 110 public static void main(String args[]) 111 { 112 System.out.println("Reading from stdin"); 115 AnnotationParser t = new AnnotationParser(System.in); 116 try 118 { 119 ASTStart n = t.Start(); 120 AnnotationParserVisitor v = new AnnotationParserTester(); 121 n.jjtAccept(v, null); 122 } 123 catch (Exception e) 124 { 125 System.out.println("Oops."); 126 System.out.println(e.getMessage()); 127 e.printStackTrace(); 128 } 129 } 130 } 131 132 133 | Popular Tags |