<?xml version="1.0" encoding="UTF-8"?>
<!--
    Copyright (c) 2004, 2018 IBM Corporation and others.
    This program and the accompanying materials
    are made available under the terms of the Eclipse Public License 2.0
    which accompanies this distribution, and is available at
    https://www.eclipse.org/legal/epl-2.0/

    SPDX-License-Identifier: EPL-2.0

    Contributors:
        IBM Corporation - initial API and implementation
 -->

<project name="tokenizer" default="CSSTokenizer">
	<target name="init" depends="properties">
		<property name="workspace.dir" value="../.."/>
		<property name="jflex.jar" value="/DevTimeSupport/JFlex/lib/sed-jflex.jar"/>
		<property name="jflex.maxmemory" value="470000000"/>
		<property name="jflex.opt" value="-skel SedModel/HTMLTokenizer/devel/skeleton.sse"/>
	</target>

	<target name="properties" if="eclipse.running">
		<property name="build.compiler" value="org.eclipse.jdt.core.JDTCompilerAdapter"/>
	</target>

	<target name="CSSTokenizer" depends="init">
		<property name="src.dir" value="SedModel/CSSTokenizer/devel"/>
		<property name="src.file" value="CSSTokenizer.jflex"/>			
		<property name="dest.dir" value="org.eclipse.wst.sse.core.css/src/com/ibm/sse/model/css/internal/parser"/>
		<property name="finaldest.dir" value="org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/parser"/>
		<antcall target="build-tokenizer">
			<param name="jflex.opt" value=""/>
		</antcall>
	</target>

	<target name="XMLTokenizer" depends="init">
		<property name="src.dir" value="SedModel/HTMLTokenizer/devel"/>
		<property name="src.file" value="XMLTokenizer"/>			
		<property name="dest.dir" value="org.eclipse.wst.sse.core.xml/src/com/ibm/sse/model/xml/internal/parser"/>
		<antcall target="build-tokenizer"/>
	</target>

	<target name="JSPTokenizer" depends="init">
		<property name="src.dir" value="SedModel/HTMLTokenizer/devel"/>
		<property name="src.file" value="JSPTokenizer.jflex"/>			
		<property name="dest.dir" value="org.eclipse.wst.sse.core.jsp/src/com/ibm/sse/model/jsp/parser/internal"/>
		<antcall target="build-tokenizer"/>
	</target>

	<target name="build-tokenizer" depends="init">
		<antcall target="run-jflex"/>
		<antcall target="copy"/>
		<antcall target="clean"/>
	</target>

	<target name="run-jflex" depends="init">
		<java classname="JFlex.Main" maxmemory="${jflex.maxmemory}" fork="yes" >
			<arg line="${src.dir}/${src.file} ${jflex.opt}"/>
			<classpath>
				<pathelement location="${jflex.jar}"/>
			</classpath>
		</java>
	</target>
	
	<target name="copy" depends="init">
		<copy todir="${workspace.dir}/${dest.dir}" overwrite="true" verbose="true">
			<fileset dir="${src.dir}">
				<include name="*.java"/>
			</fileset>
		</copy>
		<copy todir="${workspace.dir}/${finaldest.dir}" overwrite="true" verbose="true">
			<fileset dir="${src.dir}">
				<include name="*.java"/>
			</fileset>
		</copy>
	</target>
	
	<target name="clean" depends="init">
		<delete verbose="true">
			<fileset dir="${src.dir}" defaultexcludes="no">
				<include name="*~"/>
			</fileset>
		</delete>
	</target>
	

</project>