Merge branch 'warnings-as-errors' of git://github.com/sharwell/antlr4

This commit is contained in:
Terence Parr 2012-10-29 11:27:46 -07:00
commit a115490d5e
5 changed files with 17 additions and 4 deletions

View File

@ -1,5 +1,10 @@
ANTLR v4 Honey Badger
October 29, 2012
* Sam fixes nongreedy more.
* -Werror added.
October 20, 2012
* Merged Sam's fix for nongreedy lexer/parser. lots of unit tests. A fix in

View File

@ -67,7 +67,7 @@ public class LexerATNConfig extends ATNConfig {
@NotNull SemanticContext semanticContext) {
super(c, state, c.context, semanticContext);
this.lexerActionIndex = c.lexerActionIndex;
this._passedThroughNonGreedyDecision = checkNonGreedyDecision(c, state);
this.passedThroughNonGreedyDecision = checkNonGreedyDecision(c, state);
}
public LexerATNConfig(@NotNull LexerATNConfig c, @NotNull ATNState state,

View File

@ -132,6 +132,7 @@ public class Tool {
public boolean gen_dependencies = false;
public String genPackage = null;
public Map<String, String> grammarOptions = null;
public boolean warnings_are_errors = false;
public static Option[] optionDefs = {
new Option("outputDirectory", "-o", OptionArgType.STRING, "specify output directory where all output is generated"),
@ -152,7 +153,7 @@ public class Tool {
new Option("genPackage", "-package", OptionArgType.STRING, "specify a package/namespace for the generated code"),
new Option("gen_dependencies", "-depend", "generate file dependencies"),
new Option("", "-D<option>=value", "set/override a grammar-level option"),
new Option("warnings_are_errors", "-Werror", "treat warnings as errors"),
new Option("saveLexer", "-Xsave-lexer", "save temp lexer file created for combined grammars"),
new Option("launch_ST_inspector", "-XdbgST", "launch StringTemplate visualizer on generated code"),
new Option("force_atn", "-Xforce-atn", "use the ATN simulator for all predictions"),
@ -757,9 +758,14 @@ public class Tool {
public void warning(ANTLRMessage msg) {
if ( listeners.isEmpty() ) {
defaultListener.warning(msg);
return;
}
for (ANTLRToolListener l : listeners) l.warning(msg);
else {
for (ANTLRToolListener l : listeners) l.warning(msg);
}
if (warnings_are_errors) {
errMgr.emit(ErrorType.WARNING_TREATED_AS_ERROR, new ANTLRMessage(ErrorType.WARNING_TREATED_AS_ERROR));
}
}
public void version() {

View File

@ -55,6 +55,7 @@ public enum ErrorType {
CANNOT_OPEN_FILE(7, "cannot find or open file: <arg><if(exception)>; 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>\n" +
"<stackTrace; separator=\"\\n\">", ErrorSeverity.ERROR),

View File

@ -426,6 +426,7 @@ public class TestPerformance extends BaseTest {
String body = load(sourceName, null);
@SuppressWarnings({"ConstantConditions"})
List<String> extraOptions = new ArrayList<String>();
extraOptions.add("-Werror");
if (FORCE_ATN) {
extraOptions.add("-Xforce-atn");
}