[antlr-interest] exit status from "java antlr.Tool ,,,"

kaberdude at yahoo.com kaberdude at yahoo.com
Thu Nov 15 17:26:40 PST 2001

I'm an off-on Antlr user. I'm trying to write a grammar for Dot 
(ATT's Graphvis), appropriately massaged to be LL(k) (not easy!).  
Anyways, after playing around, I noticed that it is not reliably 
exiting with non-zero status when there is a severe problem in the 
grammar. So, I tried this:

"java antlr.Tool y" where y contains exactly the character "y".
$ java antlr.Tool y

ANTLR Parser Generator   Version 2.7.1   1989-2000 jGuru.com
y:1: unexpected token: y
y: error: rule grammar trapped: y:1: unexpected token: y

$ echo $?

This isn't a correct grammar, so it would be nice if the 
tool would exit() with 1 (error) instead of 0 (ok).

Looking at the source, antlr.CharScanner defines reportError() 
without a System.exit(1), but doesn't record if there was an error 
for later regurgitation. However, a generated lexer for my 
(corrected) grammar defines reportError() as:

    public void reportError(String s) {
which is slightly better.

Am I doing something wrong?


Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/ 

More information about the antlr-interest mailing list