diff --git a/WHATSNEW b/WHATSNEW index 0860cb681..c0b09c6d2 100644 --- a/WHATSNEW +++ b/WHATSNEW @@ -76,6 +76,9 @@ Fixed bugs: * The filter sometimes removed parts of string constants. Bugzilla Report 17441. +* will now recompile your grammar if the supergrammar has + changed. Bugzilla Report 12691. + Other changes: -------------- * Shipped XML parser is now Xerces 2.4.0 diff --git a/docs/manual/OptionalTasks/antlr.html b/docs/manual/OptionalTasks/antlr.html index fdb20badd..1de0f982f 100644 --- a/docs/manual/OptionalTasks/antlr.html +++ b/docs/manual/OptionalTasks/antlr.html @@ -21,10 +21,11 @@ the grammar file.

- This task only invokes ANTLR if the grammar file is newer than the generated - files. + This task only invokes ANTLR if the grammar file (or the + supergrammar specified by the glib attribute) is newer than the + generated files.

-

+

Antlr 2.7.1 Note: To successfully run ANTLR, your best option is probably to build the whole jar with the provided script mkalljar and drop the resulting jar (about 300KB) @@ -33,6 +34,13 @@ to your classpath as described in ANTLR install.html document.

+

Antlr 2.7.2 Note: + + Instead of the above, you will need antlrall.jar that can be created + by the antlr-all.jar target of the Makefile provided with the + download. + +

Parameters

@@ -170,7 +178,7 @@ href="../using.html#arg">Command line arguments.


-

Copyright © 2000-2002 Apache Software Foundation. All rights +

Copyright © 2000-2003 Apache Software Foundation. All rights Reserved.

diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/ANTLR.java b/src/main/org/apache/tools/ant/taskdefs/optional/ANTLR.java index fc8dd7acf..e513f6a7c 100644 --- a/src/main/org/apache/tools/ant/taskdefs/optional/ANTLR.java +++ b/src/main/org/apache/tools/ant/taskdefs/optional/ANTLR.java @@ -276,10 +276,18 @@ public class ANTLR extends Task { validateAttributes(); //TODO: use ANTLR to parse the grammer file to do this. File generatedFile = getGeneratedFile(); - if (target.lastModified() > generatedFile.lastModified()) { - log("Compiling " + target + " as it is newer than " - + generatedFile, Project.MSG_VERBOSE); - + boolean targetIsOutOfDate = + target.lastModified() > generatedFile.lastModified(); + boolean superGrammarIsOutOfDate = superGrammar != null && + (new File(superGrammar).lastModified() > generatedFile.lastModified()); + if (targetIsOutOfDate || superGrammarIsOutOfDate) { + if (targetIsOutOfDate) { + log("Compiling " + target + " as it is newer than " + + generatedFile, Project.MSG_VERBOSE); + } else if (superGrammarIsOutOfDate) { + log("Compiling " + target + " as " + superGrammar + + " is newer than " + generatedFile, Project.MSG_VERBOSE); + } populateAttributes(); commandline.createArgument().setValue(target.toString());