-// $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;
/**
* 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 <A href="http://zing.z3950.org/cql/index.html"
* >http://zing.z3950.org/cql/index.html</A>
*/
* data structure) or, more often, simply rendered out in the
* desired form using one of the back-ends. <TT>toCQL()</TT>
* returns a decompiled CQL query equivalent to the one that was
- * compiled in the first place; and <TT>toXCQL()</TT> returns an
- * XML snippet representing the query.
+ * compiled in the first place; <TT>toXCQL()</TT> returns an
+ * XML snippet representing the query; and <TT>toPQF()</TT>
+ * 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
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());
name = identifier;
identifier = matchSymbol("prefix-identifer");
}
- CQLNode term = parseTerm(qualifier, relation);
+ CQLNode term = parseQuery(qualifier, relation);
return new CQLPrefixNode(name, identifier, term);
}
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() + ")");
// 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 ||
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);