<project name="jsweet-candy-generator" basedir="." default="gen-parser">

	<property environment="env" />

	<condition property="maven.bin" value="${env.MAVEN_HOME}\bin\mvn.bat" else="${env.MAVEN_HOME}/bin/mvn">
		<os family="winnt" />
	</condition>

	<property name="maven.repository" value="${env.M2_HOME}/repository" />
	<property name="jflex.jar" value="${maven.repository}/de/jflex/jflex/1.3.5/jflex-1.3.5.jar" />
	<property name="java-cup.jar" value="${maven.repository}/edu/princeton/cup/java-cup/10k/java-cup-10k.jar" />
	<property name="commons-lang3.jar" value="${maven.repository}/org/apache/commons/commons-lang3/3.3.2/commons-lang3-3.3.2.jar" />
	<property name="jsweet-api.jar" value="${maven.repository}/org/jsweet/jsweet-api-bundle-frameworks/0.0.2-SNAPSHOT/jsweet-api-bundle-frameworks-0.0.2-SNAPSHOT.jar" />
	<property name="tools.jar" value="${maven.repository}/com/sun/tools/8/tools-8.jar" />

	<target name="gen-parser">
		<echo>Generating TSDef API parser...</echo>
		<echo message="compile classpath: ${compile_classpath}" />
		<java classname="java_cup.Main" fork="true" failonerror="true" classpath="${compile_classpath}">
			<arg value="-expect" />
			<arg value="0" />
			<arg value="-package" />
			<arg value="org.jsweet.input.typescriptdef.parser" />
			<arg value="-parser" />
			<arg value="TypescriptDefParser" />
			<arg value="src/main/java/org/jsweet/input/typescriptdef/parser/typescriptdef.cup" />
		</java>
		<move file="TypescriptDefParser.java" todir="src/main/java/org/jsweet/input/typescriptdef/parser" overwrite="true">
		</move>
		<move file="sym.java" todir="src/main/java/org/jsweet/input/typescriptdef/parser" overwrite="true">
		</move>
		<echo>Generating TSDef API lexer...</echo>
		<java classname="JFlex.Main" fork="true" failonerror="true" classpath="${compile_classpath}">
			<arg value="src/main/java/org/jsweet/input/typescriptdef/parser/typescriptdef.lex" />
		</java>

	</target>


</project>
