NameSpacepublic class NameSpace extends Object ANTLR Translator Generator
Project led by Terence Parr at http://www.jGuru.com
Software rights: http://www.antlr.org/license.html
Container for a C++ namespace specification. Namespaces can be
nested, so this contains a vector of all the nested names. |
Fields Summary |
---|
private Vector | names | private String | _name |
Constructors Summary |
---|
public NameSpace(String name)
_name = new String(name);
parse(name);
|
Methods Summary |
---|
void | emitClosures(java.io.PrintWriter out)Method to generate the required C++ namespace closures
for (int i = 0; i < names.size(); ++i)
out.println("ANTLR_END_NAMESPACE");
| void | emitDeclarations(java.io.PrintWriter out)Method to generate the required C++ namespace declarations
for (Enumeration n = names.elements(); n.hasMoreElements();) {
String s = (String)n.nextElement();
out.println("ANTLR_BEGIN_NAMESPACE(" + s + ")");
}
| public java.lang.String | getName()
return _name;
| protected void | parse(java.lang.String name)Parse a C++ namespace declaration into seperate names
splitting on :: We could easily parameterize this to make
the delimiter a language-specific parameter, or use subclasses
to support C++ namespaces versus java packages. -DAW
StringTokenizer tok = new StringTokenizer(name, "::");
while (tok.hasMoreTokens())
names.addElement(tok.nextToken());
|
|