Skip to content

Commit

Permalink
Ensure execution stops on failure
Browse files Browse the repository at this point in the history
  • Loading branch information
ethauvin committed Jun 25, 2024
1 parent 2c7f9f9 commit abb52f2
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions src/main/java/rife/bld/extension/Antlr4Operation.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

import org.antlr.v4.Tool;
import rife.bld.operations.AbstractOperation;
import rife.bld.operations.exceptions.ExitStatusException;

import java.io.File;
import java.util.*;
Expand Down Expand Up @@ -51,7 +52,10 @@ public void execute()
}

if (sources.isEmpty()) {
throw new IllegalArgumentException("ERROR: no ANTLR grammars found");
if (!silent()) {
System.out.println("ERROR: no ANTLR grammars found.");
}
throw new ExitStatusException(1);
}

var arguments = new ArrayList<>(arguments_);
Expand Down Expand Up @@ -83,9 +87,14 @@ public void execute()

var argument_array = new String[arguments.size()];
arguments.toArray(argument_array);
new Tool(argument_array).processGrammarsOnCommandLine();
if (!silent()) {
System.out.println("ANTLR4 grammar processed successfully.");
var tool = new Tool(argument_array);
tool.processGrammarsOnCommandLine();
if (tool.getNumErrors() == 0) {
if (!silent()) {
System.out.println("ANTLR4 grammar processed successfully.");
}
} else {
throw new ExitStatusException(1);
}
}

Expand Down

0 comments on commit abb52f2

Please sign in to comment.