Browse Source

Recompile grammar if supergrammar has changed.

PR: 12961


git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@274364 13f79535-47bb-0310-9956-ffa450edef68
master
Stefan Bodewig 22 years ago
parent
commit
13355064e6
3 changed files with 27 additions and 8 deletions
  1. +3
    -0
      WHATSNEW
  2. +12
    -4
      docs/manual/OptionalTasks/antlr.html
  3. +12
    -4
      src/main/org/apache/tools/ant/taskdefs/optional/ANTLR.java

+ 3
- 0
WHATSNEW View File

@@ -76,6 +76,9 @@ Fixed bugs:
* The <stripjavacomments> filter sometimes removed parts of string
constants. Bugzilla Report 17441.

* <antlr> will now recompile your grammar if the supergrammar has
changed. Bugzilla Report 12691.

Other changes:
--------------
* Shipped XML parser is now Xerces 2.4.0


+ 12
- 4
docs/manual/OptionalTasks/antlr.html View File

@@ -21,10 +21,11 @@
the grammar file.
</p>
<p>
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.
</p>
<p>
<p>Antlr 2.7.1 Note:
<i>
To successfully run ANTLR, your best option is probably to build the whole
jar with the provided script <b>mkalljar</b> and drop the resulting jar (about 300KB)
@@ -33,6 +34,13 @@
to your classpath as described in ANTLR <tt>install.html</tt> document.
</i>
</p>
<p>Antlr 2.7.2 Note:
<i>
Instead of the above, you will need antlrall.jar that can be created
by the <b>antlr-all.jar</b> target of the Makefile provided with the
download.
</i>
</p>

<h3>Parameters</h3>
<table border="1" cellpadding="2" cellspacing="0">
@@ -170,7 +178,7 @@ href="../using.html#arg">Command line arguments</a>.</p>
</p>
<hr>

<p align="center">Copyright &copy; 2000-2002 Apache Software Foundation. All rights
<p align="center">Copyright &copy; 2000-2003 Apache Software Foundation. All rights
Reserved.</p>

</body>


+ 12
- 4
src/main/org/apache/tools/ant/taskdefs/optional/ANTLR.java View File

@@ -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());



Loading…
Cancel
Save