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:
parent
1504c2f8f3
commit
c5ade128fd
|
@ -79,7 +79,7 @@ import java.util.Map;
|
||||||
import java.util.concurrent.CopyOnWriteArrayList;
|
import java.util.concurrent.CopyOnWriteArrayList;
|
||||||
|
|
||||||
public class Tool {
|
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 GRAMMAR_EXTENSION = ".g4";
|
||||||
public static final String LEGACY_GRAMMAR_EXTENSION = ".g";
|
public static final String LEGACY_GRAMMAR_EXTENSION = ".g";
|
||||||
|
|
|
@ -42,6 +42,8 @@ public class CodeGenPipeline {
|
||||||
public void process() {
|
public void process() {
|
||||||
CodeGenerator gen = new CodeGenerator(g);
|
CodeGenerator gen = new CodeGenerator(g);
|
||||||
|
|
||||||
|
if ( gen.templates==null ) return;
|
||||||
|
|
||||||
if ( g.isLexer() ) {
|
if ( g.isLexer() ) {
|
||||||
ST lexer = gen.generateLexer();
|
ST lexer = gen.generateLexer();
|
||||||
if ( g.tool.launch_ST_inspector ) lexer.inspect();
|
if ( g.tool.launch_ST_inspector ) lexer.inspect();
|
||||||
|
|
|
@ -118,7 +118,7 @@ public class CodeGenerator {
|
||||||
}
|
}
|
||||||
catch (IllegalArgumentException iae) {
|
catch (IllegalArgumentException iae) {
|
||||||
tool.errMgr.toolError(ErrorType.CANNOT_CREATE_TARGET_GENERATOR,
|
tool.errMgr.toolError(ErrorType.CANNOT_CREATE_TARGET_GENERATOR,
|
||||||
iae,
|
null,
|
||||||
language);
|
language);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,6 +28,8 @@
|
||||||
*/
|
*/
|
||||||
package org.antlr.v4.tool;
|
package org.antlr.v4.tool;
|
||||||
|
|
||||||
|
import org.antlr.v4.Tool;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A complex enumeration of all the error messages that the tool can issue.
|
* A complex enumeration of all the error messages that the tool can issue.
|
||||||
*
|
*
|
||||||
|
@ -61,7 +63,7 @@ public enum ErrorType {
|
||||||
|
|
||||||
// Code generation errors
|
// Code generation errors
|
||||||
MISSING_CODE_GEN_TEMPLATES(30, "can't find code generation templates: <arg>", ErrorSeverity.ERROR),
|
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_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),
|
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),
|
NO_MODEL_TO_TEMPLATE_MAPPING(34, "no mapping to template name for output model class <arg>", ErrorSeverity.ERROR),
|
||||||
|
|
Loading…
Reference in New Issue