| <!-- | |
| /******************************************************************************* | |
| * Copyright (c) 2011 IBM Corporation. | |
| * All rights reserved. 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="parser"> | |
| <description> | |
| Generates java files from jj grammar file using javacc | |
| </description> | |
| <target name="pre" description="Sets the temporary directory for java files built by javacc"> | |
| <property name="temp.dir" value="src/org/eclipse/mat/parser/internal/oql/parser/tmp" /> | |
| </target> | |
| <target name="clean_java" description="Removes java files generated by javacc"> | |
| <delete> | |
| <fileset dir="src/org/eclipse/mat/parser/internal/oql/parser" includes="**/*"> | |
| <filename name="**/*.java"/> | |
| <filename name="package-info.java" negate="true"/> | |
| </fileset> | |
| </delete> | |
| </target> | |
| <target name="javacc" depends="pre" description="Generates java files using javacc. Requires javacc.jar (from javacc-4.1.jar or javacc-5.0.jar) to be added to project root."> | |
| <mkdir dir="${temp.dir}" /> | |
| <javacc target="src/org/eclipse/mat/parser/internal/oql/parser/OQLParser.jj" javacchome="." outputdirectory="${temp.dir}" /> | |
| <copy toDir="src/org/eclipse/mat/parser/internal/oql/parser"> | |
| <fileset dir="${temp.dir}"> | |
| <include name="*.java" /> | |
| </fileset> | |
| <filterchain> | |
| <!-- javacc converts backslash to a unicode escape, which works but looks messy, so reverse it --> | |
| <replaceregex pattern="u005c" replace="" flags="g" /> | |
| <!-- avoid problems with the Turkish locale with toUpperCase --> | |
| <replaceregex pattern="toUpperCase\(\)" replace="toUpperCase\(Locale.ENGLISH\)" flags="g" /> | |
| <!-- internationalize the missing return message --> | |
| <replaceregex pattern='"Missing return statement in function"' replace="Messages.OQLParser_Missing_return_statement_in_function" flags="g" /> | |
| <!-- avoid warnings by adding suppressWarnings --> | |
| <replaceregex pattern="public class OQLParser" replace='@SuppressWarnings("nls") \0' /> | |
| <!-- remove semicolon on its own --> | |
| <replaceregex pattern="^\s*;$" replace="" /> | |
| </filterchain> | |
| </copy> | |
| <echo>Organize imports and reformat java source code to make code conform to project standards.</echo> | |
| </target> | |
| <target name="javacc_doc"> | |
| <property name="grammar.out" location="src/org/eclipse/mat/parser/internal/oql/parser/OQL.html"/> | |
| <jjdoc | |
| target="src/org/eclipse/mat/parser/internal/oql/parser/OQLParser.jj" | |
| outputfile="${grammar.out}" | |
| javacchome="." | |
| /> | |
| </target> | |
| <target name="clean_tmp" depends="pre" description="Removes temporary java files generated using javacc"> | |
| <delete dir="${temp.dir}"/> | |
| </target> | |
| <target name="clean_build" depends="clean_java,javacc,javacc_doc,clean_tmp" description="Builds all the javacc files and tidies up"> | |
| </target> | |
| </project> |