X-Git-Url: http://jsfdemo.indexdata.com/?a=blobdiff_plain;f=src%2Forg%2Fz3950%2Fzing%2Fcql%2FCQLParser.java;h=85ee63ba22abc249985f7dab27f939e5f79b8ed2;hb=08b7134bda92b6a33c57c7c6c333dacf1461c7c7;hp=eadedefd8571df176225017f3d5ae0abbd2823fa;hpb=64483d3d31c182adfb96fd75f8be10ff9f374d34;p=cql-java-moved-to-github.git
diff --git a/src/org/z3950/zing/cql/CQLParser.java b/src/org/z3950/zing/cql/CQLParser.java
index eadedef..85ee63b 100644
--- a/src/org/z3950/zing/cql/CQLParser.java
+++ b/src/org/z3950/zing/cql/CQLParser.java
@@ -1,4 +1,4 @@
-// $Id: CQLParser.java,v 1.20 2002-11-14 22:04:16 mike Exp $
+// $Id: CQLParser.java,v 1.22 2002-11-20 01:15:15 mike Exp $
package org.z3950.zing.cql;
import java.io.IOException;
@@ -12,7 +12,7 @@ import java.io.FileNotFoundException;
/**
* Compiles CQL strings into parse trees of CQLNode subtypes.
*
- * @version $Id: CQLParser.java,v 1.20 2002-11-14 22:04:16 mike Exp $
+ * @version $Id: CQLParser.java,v 1.22 2002-11-20 01:15:15 mike Exp $
* @see http://zing.z3950.org/cql/index.html
*/
@@ -34,8 +34,10 @@ public class CQLParser {
* data structure) or, more often, simply rendered out in the
* desired form using one of the back-ends. toCQL()
* returns a decompiled CQL query equivalent to the one that was
- * compiled in the first place; and toXCQL() returns an
- * XML snippet representing the query.
+ * compiled in the first place; toXCQL() returns an
+ * XML snippet representing the query; and toPQF()
+ * returns the query rendered in Index Data's Prefix Query
+ * Format.
*
* @param cql The query
* @return A CQLNode object which is the root of a parse
@@ -119,7 +121,8 @@ public class CQLParser {
match('/');
if (lexer.ttype != lexer.TT_RELEVANT &&
lexer.ttype != lexer.TT_FUZZY &&
- lexer.ttype != lexer.TT_STEM)
+ lexer.ttype != lexer.TT_STEM &&
+ lexer.ttype != lexer.TT_PHONETIC)
throw new CQLParseException("expected relation modifier, "
+ "got " + lexer.render());
relation.addModifier(lexer.sval.toLowerCase());
@@ -146,7 +149,7 @@ public class CQLParser {
name = identifier;
identifier = matchSymbol("prefix-identifer");
}
- CQLNode term = parseTerm(qualifier, relation);
+ CQLNode term = parseQuery(qualifier, relation);
return new CQLPrefixNode(name, identifier, term);
}
@@ -223,6 +226,7 @@ public class CQLParser {
lexer.ttype == lexer.TT_SCR);
}
+ // Checks for a relation that may be used inside a prox operator
private boolean isProxRelation() {
debug("isProxRelation: checking ttype=" + lexer.ttype +
" (" + lexer.render() + ")");
@@ -257,6 +261,8 @@ public class CQLParser {
// The following is a complete list of keywords. Because
// they're listed here, they can be used unquoted as
// qualifiers, terms, prefix names and prefix identifiers.
+ // ### Instead, we should ask the lexer whether what we
+ // have is a keyword, and let the knowledge reside there.
lexer.ttype == lexer.TT_AND ||
lexer.ttype == lexer.TT_OR ||
lexer.ttype == lexer.TT_NOT ||
@@ -273,7 +279,8 @@ public class CQLParser {
lexer.ttype == lexer.TT_RELEVANT ||
lexer.ttype == lexer.TT_FUZZY ||
lexer.ttype == lexer.TT_STEM ||
- lexer.ttype == lexer.TT_SCR) {
+ lexer.ttype == lexer.TT_SCR ||
+ lexer.ttype == lexer.TT_PHONETIC) {
String symbol = (lexer.ttype == lexer.TT_NUMBER) ?
lexer.render() : lexer.sval;
match(lexer.ttype);