made a better error message when they target was not available and also I bail out of the code generation process.

This commit is contained in:
Terence Parr 2012-09-06 17:09:47 -07:00
parent 1504c2f8f3
commit c5ade128fd
4 changed files with 7 additions and 3 deletions

View File

@ -79,7 +79,7 @@ import java.util.Map;
import java.util.concurrent.CopyOnWriteArrayList;
public class Tool {
public String VERSION = "4.0b1";
public static final String VERSION = "4.0b1";
public static final String GRAMMAR_EXTENSION = ".g4";
public static final String LEGACY_GRAMMAR_EXTENSION = ".g";

View File

@ -42,6 +42,8 @@ public class CodeGenPipeline {
public void process() {
CodeGenerator gen = new CodeGenerator(g);
if ( gen.templates==null ) return;
if ( g.isLexer() ) {
ST lexer = gen.generateLexer();
if ( g.tool.launch_ST_inspector ) lexer.inspect();

View File

@ -118,7 +118,7 @@ public class CodeGenerator {
}
catch (IllegalArgumentException iae) {
tool.errMgr.toolError(ErrorType.CANNOT_CREATE_TARGET_GENERATOR,
iae,
null,
language);
}
}

View File

@ -28,6 +28,8 @@
*/
package org.antlr.v4.tool;
import org.antlr.v4.Tool;
/**
* A complex enumeration of all the error messages that the tool can issue.
*
@ -61,7 +63,7 @@ public enum ErrorType {
// Code generation errors
MISSING_CODE_GEN_TEMPLATES(30, "can't find code generation templates: <arg>", ErrorSeverity.ERROR),
CANNOT_CREATE_TARGET_GENERATOR(31, "cannot create target <arg> code generator: <exception>", ErrorSeverity.ERROR),
CANNOT_CREATE_TARGET_GENERATOR(31, "ANTLR cannot generate <arg> code as of version "+ Tool.VERSION, ErrorSeverity.ERROR),
CODE_TEMPLATE_ARG_ISSUE(32, "code generation template <arg> has missing, misnamed, or incomplete arg list; missing <arg2>", ErrorSeverity.ERROR),
CODE_GEN_TEMPLATES_INCOMPLETE(33, "missing code generation template <arg>", ErrorSeverity.ERROR),
NO_MODEL_TO_TEMPLATE_MAPPING(34, "no mapping to template name for output model class <arg>", ErrorSeverity.ERROR),