1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183
|
<!--
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<project name="queryparser" default="default">
<description>
Query parsers and parsing framework
</description>
<import file="../module-build.xml"/>
<path id="classpath">
<pathelement path="${queries.jar}"/>
<pathelement path="${sandbox.jar}"/>
<path refid="base.classpath"/>
</path>
<target name="compile-core" depends="jar-queries,jar-sandbox,common.compile-core"/>
<target name="javadocs" depends="javadocs-queries,javadocs-sandbox,compile-core,check-javadocs-uptodate"
unless="javadocs-uptodate-${name}">
<invoke-module-javadoc>
<links>
<link href="../queries"/>
<link href="../sandbox"/>
</links>
</invoke-module-javadoc>
</target>
<target name="javacc" depends="javacc-QueryParser,javacc-surround,javacc-flexible"/>
<macrodef name="generalReplaces">
<attribute name="dir"/>
<sequential>
<!-- StringBuffer -> StringBuilder -->
<replace token="StringBuffer" value="StringBuilder" encoding="UTF-8">
<fileset dir="@{dir}" includes="ParseException.java TokenMgrError.java"/>
</replace>
<!-- Remove debug stream (violates forbidden-apis) -->
<replaceregexp match="/\*\* Debug.*debugStream\s*=\s*ds;\s*}" replace="" flags="s" encoding="UTF-8">
<fileset dir="@{dir}" includes="*TokenManager.java"/>
</replaceregexp>
<!-- Add warnings supression -->
<replaceregexp match="^\Qpublic class\E" replace="@SuppressWarnings("cast")${line.separator}\0" flags="m" encoding="UTF-8">
<fileset dir="@{dir}" includes="*TokenManager.java"/>
</replaceregexp>
</sequential>
</macrodef>
<target name="javacc-QueryParser" depends="resolve-javacc">
<sequential>
<invoke-javacc target="src/java/org/apache/lucene/queryparser/classic/QueryParser.jj"
outputDir="src/java/org/apache/lucene/queryparser/classic"/>
<!-- Change the incorrect public ctors for QueryParser to be protected instead -->
<replaceregexp file="src/java/org/apache/lucene/queryparser/classic/QueryParser.java"
byline="true"
match="public QueryParser\(CharStream "
replace="protected QueryParser(CharStream "/>
<replaceregexp file="src/java/org/apache/lucene/queryparser/classic/QueryParser.java"
byline="true"
match="public QueryParser\(QueryParserTokenManager "
replace="protected QueryParser(QueryParserTokenManager "/>
<!-- change an exception used for signaling to be static -->
<replaceregexp file="src/java/org/apache/lucene/queryparser/classic/QueryParser.java"
byline="true"
match="final private LookaheadSuccess jj_ls ="
replace="static final private LookaheadSuccess jj_ls =" />
<generalReplaces dir="src/java/org/apache/lucene/queryparser/classic"/>
</sequential>
</target>
<target name="javacc-surround" depends="resolve-javacc" description="generate surround query parser">
<invoke-javacc target="src/java/org/apache/lucene/queryparser/surround/parser/QueryParser.jj"
outputDir="src/java/org/apache/lucene/queryparser/surround/parser"
/>
<generalReplaces dir="src/java/org/apache/lucene/queryparser/surround/parser"/>
</target>
<target name="javacc-flexible" depends="resolve-javacc">
<invoke-javacc target="src/java/org/apache/lucene/queryparser/flexible/standard/parser/StandardSyntaxParser.jj"
outputDir="src/java/org/apache/lucene/queryparser/flexible/standard/parser"
/>
<replaceregexp file="src/java/org/apache/lucene/queryparser/flexible/standard/parser/ParseException.java"
match="public class ParseException extends Exception"
replace="public class ParseException extends QueryNodeParseException"
flags="g"
byline="false"/>
<replaceregexp file="src/java/org/apache/lucene/queryparser/flexible/standard/parser/ParseException.java"
match="package org.apache.lucene.queryparser.flexible.standard.parser;"
replace="package org.apache.lucene.queryparser.flexible.standard.parser;${line.separator}
${line.separator}
import org.apache.lucene.queryparser.flexible.messages.Message;${line.separator}
import org.apache.lucene.queryparser.flexible.messages.MessageImpl;${line.separator}
import org.apache.lucene.queryparser.flexible.core.*;${line.separator}
import org.apache.lucene.queryparser.flexible.core.messages.*;"
flags="g"
byline="false"/>
<replaceregexp file="src/java/org/apache/lucene/queryparser/flexible/standard/parser/ParseException.java"
match="^ public ParseException\(Token currentTokenVal.*$(\s\s[^}].*\n)* \}"
replace=" public ParseException(Token currentTokenVal,${line.separator}
int[][] expectedTokenSequencesVal, String[] tokenImageVal) {${line.separator}
super(new MessageImpl(QueryParserMessages.INVALID_SYNTAX, initialise(${line.separator}
currentTokenVal, expectedTokenSequencesVal, tokenImageVal)));${line.separator}
this.currentToken = currentTokenVal;${line.separator}
this.expectedTokenSequences = expectedTokenSequencesVal;${line.separator}
this.tokenImage = tokenImageVal;${line.separator}
}"
flags="gm"
byline="false"/>
<replaceregexp file="src/java/org/apache/lucene/queryparser/flexible/standard/parser/ParseException.java"
match="^ public ParseException\(String message.*$(\s\s[^}].*\n)* \}"
replace=" public ParseException(Message message) {${line.separator}
super(message);${line.separator}
}"
flags="gm"
byline="false"/>
<replaceregexp file="src/java/org/apache/lucene/queryparser/flexible/standard/parser/ParseException.java"
match="^ public ParseException\(\).*$(\s\s[^}].*\n)* \}"
replace=" public ParseException() {${line.separator}
super(new MessageImpl(QueryParserMessages.INVALID_SYNTAX, "Error"));${line.separator}
}"
flags="gm"
byline="false"/>
<replaceregexp file="src/java/org/apache/lucene/queryparser/flexible/standard/parser/ParseException.java"
match="^ public String getMessage\(\).*$(\s\s\s\s[^}].*\n)* \}"
replace=" private static String initialise(Token currentToken, int[][] expectedTokenSequences, String[] tokenImage) {${line.separator}
String eol = System.getProperty("line.separator", "\n");"
flags="gm"
byline="false"/>
<replaceregexp file="src/java/org/apache/lucene/queryparser/flexible/standard/parser/ParseException.java"
match="\s*protected String add_escapes.*"
replace=" static private String add_escapes(String str) {"
flags="g"
byline="true"/>
<generalReplaces dir="src/java/org/apache/lucene/queryparser/flexible/standard/parser"/>
</target>
<target name="resolve-javacc" xmlns:ivy="antlib:org.apache.ivy.ant">
<!-- setup a "fake" JavaCC distribution folder in ${build.dir} to make JavaCC ANT task happy: -->
<ivy:retrieve organisation="net.java.dev.javacc" module="javacc" revision="5.0" symlink="${ivy.symlink}"
inline="true" conf="default" transitive="false" type="jar" sync="true"
pattern="${build.dir}/javacc/bin/lib/[artifact].[ext]"/>
</target>
<macrodef name="invoke-javacc">
<attribute name="target"/>
<attribute name="outputDir"/>
<sequential>
<mkdir dir="@{outputDir}"/>
<delete>
<fileset dir="@{outputDir}" includes="*.java">
<containsregexp expression="Generated.*By.*JavaCC"/>
</fileset>
</delete>
<javacc
target="@{target}"
outputDirectory="@{outputDir}"
javacchome="${build.dir}/javacc"
jdkversion="1.${javac.release}"
/>
<fixcrlf srcdir="@{outputDir}" includes="*.java" encoding="UTF-8">
<containsregexp expression="Generated.*By.*JavaCC"/>
</fixcrlf>
</sequential>
</macrodef>
<target name="regenerate" depends="javacc"/>
</project>
|