Fix broken QueryParser.jj and generated code. Removed inadvertent debugging <echo> from build.xml.

Added (currently failing) test cases for new PrecedenceQueryParser as a target for enhancement.



git-svn-id: https://svn.apache.org/repos/asf/lucene/java/trunk@156449 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Erik Hatcher 2005-03-07 21:46:39 +00:00
parent 4f84a76e7b
commit 27614d6a39
4 changed files with 12 additions and 7 deletions

View File

@ -97,7 +97,6 @@
<srcfiles dir="src" includes="**/*.jj" />
<mapper type="glob" from="*.jj" to="*.java"/>
</uptodate>
<echo>${javacc.files.uptodate}</echo>
</target>
<target name="javacc-notice" unless="javacc.files.uptodate">

View File

@ -524,6 +524,7 @@ public class QueryParser implements QueryParserConstants {
protected Query getBooleanQuery(Vector clauses) throws ParseException {
return getBooleanQuery(clauses, false);
}
/**
* Factory method for generating query, given a set of clauses.
* By default creates a boolean query composed of clauses passed in.

View File

@ -545,8 +545,9 @@ public class QueryParser {
* @exception ParseException throw in overridden method to disallow
*/
protected Query getBooleanQuery(Vector clauses) throws ParseException {
getBooleanQuery(clauses, false);
return getBooleanQuery(clauses, false);
}
/**
* Factory method for generating query, given a set of clauses.
* By default creates a boolean query composed of clauses passed in.

View File

@ -170,6 +170,8 @@ public class TestPrecedenceQueryParser extends TestCase {
assertQueryEquals("türm term term", null, "türm term term");
assertQueryEquals("ümlaut", null, "ümlaut");
assertQueryEquals("+a", null, "+a");
assertQueryEquals("-a", null, "-a");
assertQueryEquals("a AND b", null, "+a +b");
assertQueryEquals("(a AND b)", null, "+a +b");
assertQueryEquals("c OR (a AND b)", null, "c (+a +b)");
@ -325,6 +327,7 @@ public class TestPrecedenceQueryParser extends TestCase {
assertQueryEquals("term AND NOT phrase term", qpAnalyzer,
"(+term -\"phrase1 phrase2\") term");
assertQueryEquals("stop", qpAnalyzer, "");
assertQueryEquals("stop OR stop AND stop", qpAnalyzer, "");
assertTrue(getQuery("term term term", qpAnalyzer) instanceof BooleanQuery);
assertTrue(getQuery("term +stop", qpAnalyzer) instanceof TermQuery);
}
@ -530,11 +533,9 @@ public class TestPrecedenceQueryParser extends TestCase {
Query query1 = PrecedenceQueryParser.parse("A AND B OR C AND D", "field", new WhitespaceAnalyzer());
Query query2 = PrecedenceQueryParser.parse("(A AND B) OR (C AND D)", "field", new WhitespaceAnalyzer());
assertEquals(query1, query2);
}
public void testPrecedenceWithNot() throws Exception {
Query query1 = PrecedenceQueryParser.parse("A OR B C", "field", new WhitespaceAnalyzer());
Query query2 = PrecedenceQueryParser.parse("A B C", "field", new WhitespaceAnalyzer());
query1 = PrecedenceQueryParser.parse("A OR B C", "field", new WhitespaceAnalyzer());
query2 = PrecedenceQueryParser.parse("A B C", "field", new WhitespaceAnalyzer());
assertEquals(query1, query2);
query1 = PrecedenceQueryParser.parse("A AND B C", "field", new WhitespaceAnalyzer());
@ -548,8 +549,11 @@ public class TestPrecedenceQueryParser extends TestCase {
query1 = PrecedenceQueryParser.parse("A OR NOT B", "field", new WhitespaceAnalyzer());
query2 = PrecedenceQueryParser.parse("A -B", "field", new WhitespaceAnalyzer());
assertEquals(query1, query2);
}
query1 = PrecedenceQueryParser.parse("A OR NOT B AND C", "field", new WhitespaceAnalyzer());
query2 = PrecedenceQueryParser.parse("A (-B +C)", "field", new WhitespaceAnalyzer());
assertEquals(query1, query2);
}
public void tearDown() {