}
private static void generateTreeInterface()
{
File file = new File(jjtreeIncludeFile());
OutputFile outputFile = null;
try {
String[] options = new String[] {"MULTI", "NODE_USES_PARSER", "VISITOR", "TRACK_TOKENS", "NODE_PREFIX", "NODE_EXTENDS", "NODE_FACTORY", "SUPPORT_CLASS_VISIBILITY_PUBLIC"};
outputFile = new OutputFile(file, nodeVersion, options);
outputFile.setToolName("JJTree");
if (file.exists() && !outputFile.needToWrite) {
return;
}
Map optionMap = new HashMap(Options.getOptions());
optionMap.put("PARSER_NAME", JJTreeGlobals.parserName);
optionMap.put("VISITOR_RETURN_TYPE", getVisitorReturnType());
optionMap.put("VISITOR_DATA_TYPE", getVisitorArgumentType());
optionMap.put("VISITOR_RETURN_TYPE_VOID", Boolean.valueOf(getVisitorReturnType().equals("void")));
PrintWriter ostr = outputFile.getPrintWriter();
ostr.println("#ifndef " + file.getName().replace('.', '_').toUpperCase());
ostr.println("#define " + file.getName().replace('.', '_').toUpperCase());
generateFile(outputFile, "/templates/cpp/TreeIncludeHeader.template", optionMap, false);
boolean hasNamespace = JJTreeOptions.stringValue("NAMESPACE").length() > 0;
if (hasNamespace) {
ostr.println("namespace " + JJTreeOptions.stringValue("NAMESPACE") + "{");
}
generateFile(outputFile, "/templates/cpp/SimpleNodeInterface.template", optionMap, false);
for (Iterator i = nodesToGenerate.iterator(); i.hasNext(); ) {
String s = (String)i.next();
optionMap.put("NODE_TYPE", s);
generateFile(outputFile, "/templates/cpp/MultiNodeInterface.template", optionMap, false);
}
if (hasNamespace) {
ostr.println("}");
}
ostr.println("#endif ");
} catch (IOException e) {
throw new Error(e.toString());
}
finally {
if (outputFile != null) { try { outputFile.close(); } catch(IOException ioe) {} }
}
}