ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Hugh Emberson <h...@embertech.com>
Subject [PATCH] Add -glib and -trace arguments to ANTLR taskdef
Date Tue, 09 Oct 2001 04:18:30 GMT
--- src/main/org/apache/tools/ant/taskdefs/optional/ANTLR.java.~1~	Tue Oct  9 13:51:43 2001
+++ src/main/org/apache/tools/ant/taskdefs/optional/ANTLR.java	Tue Oct  9 13:39:57 2001
@@ -60,6 +60,7 @@
 import org.apache.tools.ant.types.*;
 /**
  * @author Erik Meade, emeade@geekfarm.org
+ * @author Hugh Emberson, hugh@embertech.com
  */
 public class ANTLR extends Task {
 
@@ -68,6 +69,8 @@
     private File outputDirectory;
     private boolean fork = false;
     private File dir;
+    private File glib;
+    private boolean trace;
 
     public ANTLR() {
         commandline.setVm("java");
@@ -88,6 +91,15 @@
         this.fork = s;
     }
 
+    public void setGlib(File glib) {
+        log("Setting grammar library to: " + glib.toString(), Project.MSG_VERBOSE);
+	this.glib = glib;
+    }
+
+    public void setTrace(boolean on) {
+	this.trace = on;
+    }
+
     /**
      * The working directory of the process
      */
@@ -100,9 +112,20 @@
         validateAttributes();
 
         //TODO: use ANTLR to parse the grammer file to do this.
-        if (target.lastModified() > getGeneratedFile().lastModified()) {
+	File generatedFile = getGeneratedFile();
+        if (target.lastModified() > generatedFile.lastModified() ||
+	    (glib != null && glib.lastModified() > generatedFile.lastModified())) {
             commandline.createArgument().setValue("-o");
             commandline.createArgument().setValue(outputDirectory.toString());
+
+	    if(trace)
+		commandline.createArgument().setValue("-trace");
+
+	    if(glib != null) {
+		commandline.createArgument().setValue("-glib");
+		commandline.createArgument().setValue(glib.toString());
+	    }
+
             commandline.createArgument().setValue(target.toString());
 
             if (fork) {
--- docs/manual/OptionalTasks/antlr.html.~1~	Mon Sep  3 20:48:23 2001
+++ docs/manual/OptionalTasks/antlr.html	Tue Oct  9 13:54:00 2001
@@ -56,6 +56,16 @@
       fork is disabled)</td>
     <td align="center" valign="top">No</td>
   </tr>
+  <tr>
+    <td valign="top">glib</td>
+    <td valign="top">The location of the super grammar file.</td>
+    <td align="center" valign="top">No</td>
+  </tr>
+  <tr>
+    <td valign="top">trace</td>
+    <td valign="top">Have all rules call traceIn/traceOut</td>
+    <td align="center" valign="top">No, default is &quot;off&quot;</td>
+  </tr>
 </table>
 <h3>Example</h3>
 <blockquote><pre>


Mime
View raw message