<project name="lab2" default="build" basedir=".">

   <!--  Change the "YourToolPath" value below to the folder or directory
         where you have installed the CUP and JFlex jar file s-->
   
   <property 
       name="toolpath" 
       value="YourToolPath"
   />

   <!-- 
     The following  property causes Eclipse to use its own compiler 
     (rather than javac) from this build file.  
     If  you're not using Eclipse you should delete
     the following property from this file.
     -->
   <property 
       name="build.compiler" 
       value="org.eclipse.jdt.core.JDTCompilerAdapter"/>
     

   <!-- You should not need to change anything below this line -->

   <property 
       name="cup.path" 
       value="${toolpath}"/> 
   <property 
       name="jflex.path" 
       value="${toolpath}"/>
  

   <taskdef 
     description="Translate a JFlex specification into Yylex.java"
     name="jflex" 
     classname="JFlex.anttask.JFlexTask" 
     classpath="${jflex.path}/JFlex.jar"
   />

   <taskdef 
     description="Translate a CUP specification into a parser and symbol file"
     name="cup" 
     classname="java_cup.anttask.CUPTask" 
     classpath="${cup.path}/java-cup-11a.jar"
   />

<target name="build" depends="genScanner,genParser,symUpdate1,symUpdate2">
  <javac nowarn="true" srcdir="." destdir="." classpath=".:${cup.path}/java-cup-11a.jar:"/>
</target>

   <target name="symUpdate1" depends="sym1.check" unless="sym1.valid">
      <touch file="Yylex.java"/>
   </target>

      <target name="sym1.check">
         <uptodate property="sym1.valid" targetfile="Yylex.java" srcfile="sym.java"/>
      </target>

   <target name="symUpdate2" depends="sym2.check" unless="sym2.valid">
      <touch file="RecursiveDescent.java"/>
   </target>

      <target name="sym2.check">
         <uptodate property="sym2.valid" targetfile="RecursiveDescent.java" srcfile="sym.java"/>
      </target>


<target name="genParser">
 <cup srcfile="${basedir}/addhaque.cup"
      destdir="${basedir}"
      parser="Parser"
     quiet="true"
 />
</target>

<target name="genScanner" depends="genParser">
   <jflex file="scanner.jflex"
          destdir="."
          nobak="true"
   />
</target>

<target name="clean">
  <delete>
    <fileset dir="." includes="**/*.class"/>
  </delete>
  <delete file="sym.java"/>
  <delete file="Parser.java"/>
  <delete file="Yylex.java"/>
</target>

</project>

