1 package persistence.antlr; 2 3 14 15 import java.util.Vector ; 16 import java.util.Enumeration ; 17 import java.io.PrintWriter ; 18 import java.util.StringTokenizer ; 19 20 public class NameSpace { 21 private Vector names = new Vector (); 22 private String _name; 23 24 public NameSpace(String name) { 25 _name = new String (name); 26 parse(name); 27 } 28 29 public String getName() 30 { 31 return _name; 32 } 33 34 40 protected void parse(String name) { 41 StringTokenizer tok = new StringTokenizer (name, "::"); 42 while (tok.hasMoreTokens()) 43 names.addElement(tok.nextToken()); 44 } 45 46 49 void emitDeclarations(PrintWriter out) { 50 for (Enumeration n = names.elements(); n.hasMoreElements();) { 51 String s = (String )n.nextElement(); 52 out.println("ANTLR_BEGIN_NAMESPACE(" + s + ")"); 53 } 54 } 55 56 59 void emitClosures(PrintWriter out) { 60 for (int i = 0; i < names.size(); ++i) 61 out.println("ANTLR_END_NAMESPACE"); 62 } 63 } 64 | Popular Tags |