[antlr-interest] Bad Feature in 2.7.1: System.exit()
Terence Parr
parrt at jguru.com
Thu Jan 17 10:41:55 PST 2002
If you look in 2.7.2a2 you'll note that I have made a specific call you
can use that avoids the exit(). It has already been extracted and
isolated to the invocation from main. There is a new doEverything()
method you can call :)
let me know if that works...another ANT gentleman asked for this a while
back.
Ter
On Thursday, January 17, 2002, at 10:18 AM, gidadoifiok wrote:
> I'm using ANT, and well the 'antlr' tasks in ANT 1.4 is
> broken (supposed to be fixed in 1.5), but that's now why
> I'm writing. I had to write my own task, that calls
> 'antlr.Tool.main()'. That way I can write 'ant antlr'
> and generate my lexer/parsers. However, I cannot do an
> 'ant antlr test' (i.e. do two targets back to back); the
> reason is that antlr exits using System.exit()! This is
> bad form, as you are not able to integrate antlr into
> other products well.
>
> Here's what I suggest:
> 1. create an new runtime Exception called SYSTEM.EXIT
> with a method 'public int getExitCode()'
> 2. trap this exception in antlr.Tool.main() like so:
>
> try {
> ...
> } catch (SystemExitException see) {
> return see.getExitCode();
> }
>
> This way, you're able able to return control to the calling
> method (i.e. the method that called antlr.Tool.main()) and
> letting the calling method decide what to do. (In the case
> of the JVM making the call, then it will exit as expected
> just as if you had done a System.exit()). This makes the
> code more reusable in my opinion.
>
> - Gidado
>
> Here are all the System.exit()s I found (man, there all
> over the place!) It's even down in the parser! Perhaps
> the panic() method should throw a PanicException, a type
> of RuntimeException....
>
> File: D:\java\ext\antlr-2.7.1\antlr\CharScanner.java
> Pos (226,5): System.exit(1);
> Pos (231,5): System.exit(1);
> File: D:\java\ext\antlr-2.7.1\antlr\CppCodeGenerator.java
> Pos (97,13): System.exit(1);
> File: D:\java\ext\antlr-2.7.1\antlr\debug\LLkDebuggingParser.java
> Pos (220,17): System.exit(1);
> Pos (229,13): System.exit(1);
> File: D:\java\ext\antlr-2.7.1\antlr\debug\misc\ASTFrame.java
> Pos (49,16): // System.exit(0);
> File: D:\java\ext\antlr-2.7.1\antlr\DiagnosticCodeGenerator.java
> Pos (54,21): System.exit(1);
> File: D:\java\ext\antlr-2.7.1\antlr\HTMLCodeGenerator.java
> Pos (58,21): System.exit(1);
> File: D:\java\ext\antlr-2.7.1\antlr\JavaCodeGenerator.java
> Pos (83,9): System.exit(1);
> File: D:\java\ext\antlr-2.7.1\antlr\Parser.java
> Pos (206,5): System.exit(1);
> File: D:\java\ext\antlr-2.7.1\antlr\SatherCodeGenerator.java
> Pos (79,9): System.exit(1);
> File: D:\java\ext\antlr-2.7.1\antlr\Tool.java
> Pos (156,9): System.exit(1);
> Pos (175,9): System.exit(1);
> Pos (208,9): System.exit(1);
> Pos (212,9): System.exit(1);
> Pos (214,5): System.exit(0);
> Pos (334,5): System.exit(0);
> Pos (350,9): System.exit(1);
> Pos (358,5): System.exit(1);
> Pos (366,5): System.exit(1);
> File: D:\java\ext\antlr-2.7.1\antlr\TreeParser.java
> Pos (84,9): System.exit(1);
>
>
>
>
> Your use of Yahoo! Groups is subject to
> http://docs.yahoo.com/info/terms/
>
>
--
Chief Scientist & Co-founder, http://www.jguru.com
Creator, ANTLR Parser Generator: http://www.antlr.org
Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
More information about the antlr-interest
mailing list