// add output vocab file; e.g., T.tokens. This is always generated to
// the base output directory, which will be just . if there is no -o option
//
files.add(new File(tool.getOutputDirectory(), generator.getVocabFileName()));
// are we generating a .h file?
ST headerExtST = null;
ST extST = generator.getTemplates().getInstanceOf("codeFileExtension");
if (generator.getTemplates().isDefined("headerFile")) {
headerExtST = generator.getTemplates().getInstanceOf("headerFileExtension");
String suffix = Grammar.grammarTypeToFileNameSuffix[grammar.type];
String fileName = grammar.name + suffix + headerExtST.render();
files.add(new File(outputDir, fileName));
}
if (grammar.type == Grammar.COMBINED) {
// add autogenerated lexer; e.g., TLexer.java TLexer.h TLexer.tokens
// don't add T__.g (just a temp file)
String suffix = Grammar.grammarTypeToFileNameSuffix[Grammar.LEXER];
String lexer = grammar.name + suffix + extST.render();
files.add(new File(outputDir, lexer));
// TLexer.h
if (headerExtST != null) {
String header = grammar.name + suffix + headerExtST.render();
files.add(new File(outputDir, header));
}
// for combined, don't generate TLexer.tokens
}
// handle generated files for imported grammars
List<Grammar> imports =
grammar.composite.getDelegates(grammar.composite.getRootGrammar());
for (Grammar g : imports) {
outputDir = tool.getOutputDirectory(g.getFileName());
String fname = groomQualifiedFileName(outputDir.toString(), g.getRecognizerName() + extST.render());
files.add(new File(fname));
}
if (files.isEmpty()) {
return null;