forked from jasder/antlr
Add -long-messages option; only show exceptions with errors when set
This commit is contained in:
parent
4a442562e6
commit
934bea8b12
|
@ -1,5 +1,9 @@
|
|||
ANTLR v4 Honey Badger
|
||||
|
||||
December 11, 2012
|
||||
|
||||
* Add -long-messages option; only show exceptions with errors when set
|
||||
|
||||
December 2, 2012
|
||||
|
||||
* Remove -Xverbose-dfa option
|
||||
|
|
|
@ -131,6 +131,7 @@ public class Tool {
|
|||
public String genPackage = null;
|
||||
public Map<String, String> grammarOptions = null;
|
||||
public boolean warnings_are_errors = false;
|
||||
public boolean longMessages = false;
|
||||
|
||||
public static Option[] optionDefs = {
|
||||
new Option("outputDirectory", "-o", OptionArgType.STRING, "specify output directory where all output is generated"),
|
||||
|
@ -138,6 +139,7 @@ public class Tool {
|
|||
new Option("generate_ATN_dot", "-atn", "generate rule augmented transition network diagrams"),
|
||||
new Option("grammarEncoding", "-encoding", OptionArgType.STRING, "specify grammar file encoding; e.g., euc-jp"),
|
||||
new Option("msgFormat", "-message-format", OptionArgType.STRING, "specify output style for messages in antlr, gnu, vs2005"),
|
||||
new Option("longMessages", "-long-messages", "show exception details when available for errors and warnings"),
|
||||
new Option("gen_listener", "-listener", "generate parse tree listener (default)"),
|
||||
new Option("gen_listener", "-no-listener", "don't generate parse tree listener"),
|
||||
new Option("gen_visitor", "-visitor", "generate parse tree visitor"),
|
||||
|
|
|
@ -101,6 +101,7 @@ public class ErrorManager {
|
|||
ST reportST = getReportFormat(msg.errorType.severity);
|
||||
ST messageFormatST = getMessageFormat();
|
||||
|
||||
messageST.add("verbose", tool.longMessages);
|
||||
if ( msg.args!=null ) { // fill in arg1, arg2, ...
|
||||
for (int i=0; i<msg.args.length; i++) {
|
||||
String attr = "arg";
|
||||
|
@ -109,6 +110,7 @@ public class ErrorManager {
|
|||
}
|
||||
if ( msg.args.length<2 ) messageST.add("arg2", null); // some messages ref arg2
|
||||
}
|
||||
|
||||
if ( msg.getCause()!=null ) {
|
||||
messageST.add("exception", msg.getCause());
|
||||
messageST.add("stackTrace", msg.getCause().getStackTrace());
|
||||
|
|
|
@ -53,13 +53,13 @@ public enum ErrorType {
|
|||
ERROR_READING_TOKENS_FILE(4, "cannot find tokens file <arg>: <arg2>", ErrorSeverity.ERROR),
|
||||
DIR_NOT_FOUND(5, "directory not found: <arg>", ErrorSeverity.ERROR),
|
||||
OUTPUT_DIR_IS_FILE(6, "output directory is a file: <arg>", ErrorSeverity.ERROR),
|
||||
CANNOT_OPEN_FILE(7, "cannot find or open file: <arg><if(exception)>; reason: <exception><endif>", ErrorSeverity.ERROR),
|
||||
CANNOT_OPEN_FILE(7, "cannot find or open file: <arg><if(exception&&verbose)>; reason: <exception><endif>", ErrorSeverity.ERROR),
|
||||
FILE_AND_GRAMMAR_NAME_DIFFER(8, "grammar name <arg> and file name <arg2> differ", ErrorSeverity.ERROR),
|
||||
BAD_OPTION_SET_SYNTAX(9, "invalid -Dname=value syntax: <arg>", ErrorSeverity.ERROR),
|
||||
WARNING_TREATED_AS_ERROR(10, "warning treated as error", ErrorSeverity.ERROR),
|
||||
|
||||
INTERNAL_ERROR(20, "internal error: <arg> <arg2><if(exception)>: <exception><endif>" +
|
||||
"<stackTrace; separator=\"\\n\">", ErrorSeverity.ERROR),
|
||||
INTERNAL_ERROR(20, "internal error: <arg> <arg2><if(exception&&verbose)>: <exception>" +
|
||||
"<stackTrace; separator=\"\\n\"><endif>", ErrorSeverity.ERROR),
|
||||
TOKENS_FILE_SYNTAX_ERROR(21, ".tokens file syntax error <arg>:<arg2>", ErrorSeverity.ERROR),
|
||||
|
||||
// Code generation errors
|
||||
|
|
Loading…
Reference in New Issue