+ debug("in matchSymbol()");
+ if (lexer.ttype == lexer.TT_WORD ||
+ lexer.ttype == lexer.TT_NUMBER ||
+ lexer.ttype == '"' ||
+ // 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_PROX ||
+ lexer.ttype == lexer.TT_ANY ||
+ lexer.ttype == lexer.TT_ALL ||
+ lexer.ttype == lexer.TT_EXACT ||
+ lexer.ttype == lexer.TT_pWORD ||
+ lexer.ttype == lexer.TT_SENTENCE ||
+ lexer.ttype == lexer.TT_PARAGRAPH ||
+ lexer.ttype == lexer.TT_ELEMENT ||
+ lexer.ttype == lexer.TT_ORDERED ||
+ lexer.ttype == lexer.TT_UNORDERED ||
+ lexer.ttype == lexer.TT_RELEVANT ||
+ lexer.ttype == lexer.TT_FUZZY ||
+ lexer.ttype == lexer.TT_STEM ||
+ lexer.ttype == lexer.TT_SCR ||
+ lexer.ttype == lexer.TT_PHONETIC) {
+ String symbol = (lexer.ttype == lexer.TT_NUMBER) ?
+ lexer.render() : lexer.sval;
+ match(lexer.ttype);
+ return symbol;
+ }
+
+ throw new CQLParseException("expected " + expected + ", " +
+ "got " + lexer.render());
+ }
+
+
+ /**
+ * Simple test-harness for the CQLParser class.
+ * <P>
+ * Reads a CQL query either from its command-line argument, if
+ * there is one, or standard input otherwise. So these two
+ * invocations are equivalent:
+ * <PRE>
+ * CQLParser 'au=(Kerninghan or Ritchie) and ti=Unix'
+ * echo au=(Kerninghan or Ritchie) and ti=Unix | CQLParser
+ * </PRE>
+ * The test-harness parses the supplied query and renders is as
+ * XCQL, so that both of the invocations above produce the
+ * following output:
+ * <PRE>
+ * <triple>
+ * <boolean>
+ * <value>and</value>
+ * </boolean>
+ * <triple>
+ * <boolean>
+ * <value>or</value>
+ * </boolean>
+ * <searchClause>
+ * <index>au</index>
+ * <relation>
+ * <value>=</value>
+ * </relation>
+ * <term>Kerninghan</term>
+ * </searchClause>
+ * <searchClause>
+ * <index>au</index>
+ * <relation>
+ * <value>=</value>
+ * </relation>
+ * <term>Ritchie</term>
+ * </searchClause>
+ * </triple>
+ * <searchClause>
+ * <index>ti</index>
+ * <relation>
+ * <value>=</value>
+ * </relation>
+ * <term>Unix</term>
+ * </searchClause>
+ * </triple>
+ * </PRE>
+ * <P>
+ * @param -c
+ * Causes the output to be written in CQL rather than XCQL - that
+ * is, a query equivalent to that which was input, is output. In
+ * effect, the test harness acts as a query canonicaliser.
+ * @return
+ * The input query, either as XCQL [default] or CQL [if the
+ * <TT>-c</TT> option is supplied].
+ */