Now creates the plugins directory (if not already existing) on exit.
[weka.git] / parsers.xml
blobb5da3607140c7cabf8466a7bffd21a4a7cd09dcb
1 <?xml version="1.0" encoding="UTF-8"?>
3 <!--
4   ANT file for generating JFlex/CUP parsers.
6   If you want to add a new parser, you basically only need to do the
7   following two things:
8   - write JFlex and CUP files, i.e., Parser.cup and Scanner.jflex, for your 
9     parser and place them in a separated sub-package
10   - add an "antcall" to the "parsers" target, with the sub-package as parameter
11     (the sub-package your parser files reside in)
13   For an example, please refer to the "weka.core.mathematicalexpression" parser.
15   URLs:
16   - JFlex
17     http://jflex.de/
18   - CUP
19     http://www2.cs.tum.edu/projects/cup/
21   Author:  FracPete (fracpete at waikato dot ac dot nz)
22   Version: $Revision: 1.2 $
23 -->
25 <project name="weka-parsers" default="compile" basedir=".">
26    <property name="build.compiler" value="modern" />
27    <property name="debug"          value="on" />
28    <property name="deprecation"    value="off" />
29    <property name="optimization"   value="off" />
30    <property name="build"          value="build"/>
31    <property name="lib"            value="lib"/>
32    <property name="parserpkg"      value="" />
33    <property name="src"            value="src/main/java" />
35    <path id="project.class.path">
36      <fileset dir="${lib}">
37        <include name="*.jar"/>
38        <include name="*.zip"/>
39      </fileset>
40      <pathelement location="${build}/classes"/>
41      <pathelement path="${java.class.path}" />
42    </path>
44    <target name="init" description="Initializes the build environment.">
45       <!-- initialize Weka -->
46       <ant antfile="build.xml" target="init_compile"/>
47    </target>
49    <target name="compile" depends="init" description="Compiles Weka.">
50       <!-- compile Weka -->
51       <ant antfile="build.xml" target="compile"/>
52       <!-- generate parsers -->
53       <antcall target="parsers"/>
54       <!-- recompile Weka -->
55       <ant antfile="build.xml" target="compile"/>
56    </target>
57    
58    <!-- central target for calling the parser targets -->
59    <target name="parsers" depends="init" description="Generates all the parsers subsequently.">
60       <antcall target="parser">
61          <param name="parserpkg" value="weka/core/mathematicalexpression"/>
62       </antcall>
63       <antcall target="parser">
64          <param name="parserpkg" value="weka/filters/unsupervised/instance/subsetbyexpression"/>
65       </antcall>
66       <antcall target="parser">
67          <param name="parserpkg" value="weka/core/json"/>
68       </antcall>
69       <!-- add calls for more parsers here -->
70    </target>
72    <!-- generates a parser situated in the ${parserpkg} sub-package 
73         (using Parser.cup and Scanner.jflex). -->
74    <target name="parser" description="Generates the parser ${parserpkg}.">
75       <echo message="Generating lexer (${parserpkg})."/>
76       <java classname="JFlex.Main">
77          <classpath refid="project.class.path"/>
78          <arg value="--jlex"/>
79          <arg value="--quiet"/>
80          <arg value="--nobak"/>
81          <arg value="--outdir"/>
82          <arg value="${src}/${parserpkg}"/>
83          <arg value="${src}/${parserpkg}/Scanner.jflex"/>
84       </java>
85       <echo message="Generating parser (${parserpkg})."/>
86       <java classname="java_cup.Main">
87          <classpath refid="project.class.path"/>
88          <arg value="-parser"/>
89          <arg value="Parser"/>
90          <arg value="-interface"/>
91          <arg value="-destdir"/>
92          <arg value="${src}/${parserpkg}"/>
93          <arg value="${src}/${parserpkg}/Parser.cup"/>
94       </java>
95    </target>
96 </project>