Update CodeGenPipeline.process to check for errors before writing output files

This commit is contained in:
Sam Harwell 2014-08-09 10:26:21 -05:00
parent 4a57ed6a51
commit 8e69a5b99d
1 changed files with 27 additions and 6 deletions

View File

@ -64,23 +64,44 @@ public class CodeGenPipeline {
}
}
// all templates are generated in memory to report the most complete
// error information possible, but actually writing output files stops
// after the first error is reported
int errorCount = g.tool.errMgr.getNumErrors();
if ( g.isLexer() ) {
ST lexer = gen.generateLexer();
writeRecognizer(lexer, gen);
if (g.tool.errMgr.getNumErrors() == errorCount) {
writeRecognizer(lexer, gen);
}
}
else {
ST parser = gen.generateParser();
writeRecognizer(parser, gen);
if (g.tool.errMgr.getNumErrors() == errorCount) {
writeRecognizer(parser, gen);
}
if ( g.tool.gen_listener ) {
gen.writeListener(gen.generateListener());
ST listener = gen.generateListener();
if (g.tool.errMgr.getNumErrors() == errorCount) {
gen.writeListener(listener);
}
if (gen.getTarget().wantsBaseListener()) {
gen.writeBaseListener(gen.generateBaseListener());
ST baseListener = gen.generateBaseListener();
if (g.tool.errMgr.getNumErrors() == errorCount) {
gen.writeBaseListener(baseListener);
}
}
}
if ( g.tool.gen_visitor ) {
gen.writeVisitor(gen.generateVisitor());
ST visitor = gen.generateVisitor();
if (g.tool.errMgr.getNumErrors() == errorCount) {
gen.writeVisitor(visitor);
}
if (gen.getTarget().wantsBaseVisitor()) {
gen.writeBaseVisitor(gen.generateBaseVisitor());
ST baseVisitor = gen.generateBaseVisitor();
if (g.tool.errMgr.getNumErrors() == errorCount) {
gen.writeBaseVisitor(baseVisitor);
}
}
}
gen.writeHeaderFile();