<project name="lab6" default="test" 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="YourTolPath"
   />

   <!-- 
     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.jar" 
       value="${toolpath}/java-cup-11a.jar"/> 
	
	<property 
       name="jasmin.jar" 
       value="${toolpath}/jasmin-2.3.jar"/> 

   <target name="build" depends="parser">
   	 <javac debug="true" nowarn="true" srcdir="TestClasses" destdir="."/>
     <javac debug="true" nowarn="true" 
            srcdir="." 
            destdir="." 
            classpath=".:${cup.jar}:${toolpath}/coursesolutions.jar:"/>
   </target>

   <target name="parser">
      <ant dir="parser"/>
   </target>

<target name="eric">
	<antcall target="ericrun">
		<param name="run.input" value="good1"/>
	</antcall>
</target>
		
<target name="InternalRunOneTest">
	<fail message="Internal target, cannot be called from outside" unless="run.input"/>
	<echo level="info" message="Compiling: TestFiles/${run.input}"/>
	<java 
		classname="Main" 
		input="TestFiles/${run.input}"
		logError="true"
		output="TestJ/${run.input}.j"
		fork="true" failonerror="true">
		<classpath>
			<pathelement path="."/>
			<pathelement location="${toolpath}/coursesolutions.jar"/>
			<pathelement location="${cup.jar}"/>
		</classpath>
	</java>

	<echo level="info" message="Assembling: ${run.input}.j"/>
	
	<delete file="TestClasses/${run.input}.class"/>
	<java jar="${jasmin.jar}" 
		fork="true" failonerror="true"
		>
		<arg value="TestJ/${run.input}.j"/>
		<arg value="-g"/>
	</java>
	
	<echo level="info" message="JVM interpreting: ${run.input}.class"/>
	<java dir="." classname="TestClasses.${run.input}" fork="true"/>
</target>

<target name="test" description="Run solution on testfiles" depends="build">
	<antcall target="InternalRunOneTest">
			<param name="run.input" value="good1p"/>
	</antcall>
	<antcall target="InternalRunOneTest">
			<param name="run.input" value="good2p"/>
	</antcall>
	<antcall target="InternalRunOneTest">
			<param name="run.input" value="fact"/>
	</antcall>
	<antcall target="InternalRunOneTest">
			<param name="run.input" value="field"/>
	</antcall>
	<antcall target="InternalRunOneTest">
			<param name="run.input" value="short"/>
	</antcall>
</target>

   <target name="clean">
   	 <ant dir="parser" target="clean"/>
     <delete>
		<fileset dir="." includes="**/*.class"/>
 		<fileset dir="TestJ" includes="**/*.j"/>
     </delete>
   </target>

</project>

