Hi

Attached please find preliminary work for JavaCC from Metamata
<http://www.metamata.com/>.
JavaCC generates .java files from a grammar file (like lex & yacc and
friends).

The JavaCC task provided still has many options hard coded and compiles
only one file at the time and completly lacks documentation.
I would like to know if someone on th elist is interested in the task
and willing to give some feedback.

Todo:
- Make it a MatchingTask
- Find a way to abort the build if JavaCC fails.

Unless their is interest, I will provide a patch for inclusion when this
task is completed (including docu).

thanks
- tom

--
* Thomas Haas                    <mailto:[EMAIL PROTECTED]>
* SoftWired AG                   <http://www.softwired-inc.com/>
* Technoparkstr. 1  ***  CH-8005 Zurich  ***  +41-1-4452370

--- defaults.properties.orig    Wed Mar 22 05:20:52 2000
+++ defaults.properties Wed Mar 22 22:16:16 2000
@@ -31,6 +31,7 @@
 script=org.apache.tools.ant.taskdefs.optional.Script
 netrexxc=org.apache.tools.ant.taskdefs.optional.NetRexxC
 renameext=org.apache.tools.ant.taskdefs.optional.RenameExtensions
+javacc=org.apache.tools.ant.taskdefs.optional.JavaCC
 
 # deprecated ant tasks (kept for back compatibility)
 javadoc2=org.apache.tools.ant.taskdefs.Javadoc
--- JavaCC.java.orig    Thu Mar 23 14:00:31 2000
+++ JavaCC.java Thu Mar 23 14:00:10 2000
@@ -0,0 +1,145 @@
+/*
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 1999 The Apache Software Foundation.  All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in
+ *    the documentation and/or other materials provided with the
+ *    distribution.
+ *
+ * 3. The end-user documentation included with the redistribution, if
+ *    any, must include the following acknowlegement:
+ *       "This product includes software developed by the
+ *        Apache Software Foundation (http://www.apache.org/)."
+ *    Alternately, this acknowlegement may appear in the software itself,
+ *    if and wherever such third-party acknowlegements normally appear.
+ *
+ * 4. The names "The Jakarta Project", "Tomcat", and "Apache Software
+ *    Foundation" must not be used to endorse or promote products derived
+ *    from this software without prior written permission. For written
+ *    permission, please contact [EMAIL PROTECTED]
+ *
+ * 5. Products derived from this software may not be called "Apache"
+ *    nor may "Apache" appear in their names without prior written
+ *    permission of the Apache Group.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation.  For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ */
+
+package org.apache.tools.ant.taskdefs.optional;
+
+import org.apache.tools.ant.taskdefs.Java;
+import org.apache.tools.ant.BuildException;
+
+public class JavaCC extends Java {
+
+    private String metamatahome = null;
+    private String userclasspath = null;
+    private String workingdir = null;
+    private String srcdir = null;
+
+    public void setMetamatahome(String metamatahome) {
+        this.metamatahome = project.translatePath(metamatahome);
+    }
+
+    public void setWorkingdir(String workingdir) {
+        this.workingdir = project.translatePath(workingdir);
+    }
+
+    public void setSrcdir(String srcdir) {
+        this.srcdir = srcdir;
+    }
+
+    public void setTarget(String testcase) {
+        setArgs(testcase);
+    }
+
+    public void setUserclasspath(String userclasspath) {
+        this.userclasspath = userclasspath;
+    }
+
+    public JavaCC() {
+        setFork("on");
+        setClassname("com.metamata.jj.MParse");
+    }
+
+
+    public void execute() throws BuildException {
+        setClasspath(getMetamataClasspath(metamatahome));
+        setJvmargs("-mx140M -Dmwp=" + getWorkingdir(workingdir) +
+       " -Dmetamata.home=" + metamatahome +
+       " -Dmetamata.java=java" +
+       " -Dmetamata.java.options=-mx140M" +
+       " -Dmetamata.java.options.classpath=-classpath" +
+       " -Dmetamata.java.compiler=javac" +
+       " -Dmetamata.java.compiler.options.0=-J-mx64M" +
+       " -Dmetamata.java.compiler.options.classpath=-classpath" +
+       " -Dmetamata.language=en" +
+       " -Dmetamata.country=US" +
+       " -Dmetamata.classpath=" + getUserclasspath(userclasspath));
+        super.execute();
+    }
+
+    public int run(String command) throws BuildException {
+        int result = super.run(command);
+        if (result != 0) {
+            throw new BuildException("Metamata failed.");
+        }
+        return 0;
+    }
+
+
+    protected String getMetamataClasspath(String home)
+    throws BuildException {
+        if (home == null) {
+            throw new BuildException("Metamatahome not set.");
+        }
+        return home + "/lib/metamatadebug.jar:" +
+            home + "/lib/metamata.jar:" +
+            home + "/lib/JavaCC.zip";
+    }
+
+    protected String getWorkingdir(String workingdir)
+    throws BuildException {
+        if (workingdir == null) {
+            throw new BuildException("Workingdir not set.");
+        }
+        return workingdir;
+    }
+
+    protected String getUserclasspath(String userclasspath)
+    throws BuildException {
+        if (userclasspath == null) {
+            throw new BuildException("Userclasspath not set.");
+        }
+        return userclasspath;
+    }
+
+
+}

Reply via email to