1 22 package org.jboss.annotation.factory.ast; 23 24 25 26 public class AnnotationParserTester implements AnnotationParserVisitor 27 { 28 private int indent = 0; 29 30 private String indentString() 31 { 32 StringBuffer sb = new StringBuffer (); 33 for (int i = 0; i < indent; ++i) 34 { 35 sb.append(" "); 36 } 37 return sb.toString(); 38 } 39 40 public Object visit(ASTSingleMemberValue node, Object data) 41 { 42 System.out.println(indentString() + node); 43 ++indent; 44 data = node.childrenAccept(this, data); 45 --indent; 46 return data; 47 } 48 49 public Object visit(SimpleNode node, Object data) 50 { 51 System.out.println(indentString() + node + 52 ": acceptor not unimplemented in subclass?"); 53 ++indent; 54 data = node.childrenAccept(this, data); 55 --indent; 56 return data; 57 } 58 59 public Object visit(ASTStart node, Object data) 60 { 61 System.out.println(indentString() + node); 62 ++indent; 63 data = node.childrenAccept(this, data); 64 --indent; 65 return data; 66 } 67 68 public Object visit(ASTAnnotation node, Object data) 69 { 70 System.out.println(indentString() + node); 71 ++indent; 72 data = node.childrenAccept(this, data); 73 --indent; 74 return data; 75 } 76 77 public Object visit(ASTMemberValuePairs node, Object data) 78 { 79 System.out.println(indentString() + node); 80 ++indent; 81 data = node.childrenAccept(this, data); 82 --indent; 83 return data; 84 } 85 86 public Object visit(ASTMemberValuePair node, Object data) 87 { 88 System.out.println(indentString() + node); 89 ++indent; 90 data = node.childrenAccept(this, data); 91 --indent; 92 return data; 93 } 94 95 public Object visit(ASTMemberValueArrayInitializer node, Object data) 96 { 97 System.out.println(indentString() + node); 98 ++indent; 99 data = node.childrenAccept(this, data); 100 --indent; 101 return data; 102 } 103 104 public Object visit(ASTIdentifier node, Object data) 105 { 106 System.out.println(indentString() + node); 107 ++indent; 108 data = node.childrenAccept(this, data); 109 --indent; 110 return data; 111 } 112 113 public Object visit(ASTString node, Object data) 114 { 115 System.out.println(indentString() + node); 116 ++indent; 117 data = node.childrenAccept(this, data); 118 --indent; 119 return data; 120 } 121 122 public Object visit(ASTChar node, Object data) 123 { 124 System.out.println(indentString() + node); 125 ++indent; 126 data = node.childrenAccept(this, data); 127 --indent; 128 return data; 129 } 130 131 public static void main(String args[]) 132 { 133 System.out.println("Reading from stdin"); 136 AnnotationParser t = new AnnotationParser(System.in); 137 try 139 { 140 ASTStart n = t.Start(); 141 AnnotationParserVisitor v = new AnnotationParserTester(); 142 n.jjtAccept(v, null); 143 } 144 catch (Exception e) 145 { 146 System.out.println("Oops."); 147 System.out.println(e.getMessage()); 148 e.printStackTrace(); 149 } 150 } 151 } 152 153 154 | Popular Tags |