+
+
+// This is a trivial subclass for java.io.StreamTokenizer which knows
+// about the multi-character tokens "<=", ">=" and "<>", and included
+// a render() method. Used only by CQLParser.
+//
+class CQLLexer extends StreamTokenizer {
+ private static boolean lexdebug;
+
+ CQLLexer(String cql, boolean lexdebug) {
+ super(new StringReader(cql));
+ this.ordinaryChar('=');
+ this.ordinaryChar('<');
+ this.ordinaryChar('>');
+ this.ordinaryChar('/');
+ this.ordinaryChar('(');
+ this.ordinaryChar(')');
+ this.wordChars('\'', '\''); // prevent this from introducing strings
+ this.lexdebug = lexdebug;
+ }
+
+ public int nextToken() throws java.io.IOException {
+ int token = super.nextToken();
+ if (lexdebug)
+ System.out.println("LEXDEBUG: " +
+ "token=" + token + ", " +
+ "nval=" + this.nval + ", " +
+ "sval=" + this.sval);
+
+ return token;
+ }
+
+ String render() {
+ return this.render(this.ttype, null, true);
+ }
+
+ String render(boolean quoteChars) {
+ return this.render(this.ttype, null, quoteChars);
+ }
+
+ String render(int token, String str, boolean quoteChars) {
+ String ret;
+
+ if (token == this.TT_EOF) {
+ return "EOF";
+ } else if (token == this.TT_EOL) {
+ return "EOL";
+ } else if (token == this.TT_NUMBER) {
+ return "number: " + this.nval;
+ } else if (token == this.TT_WORD) {
+ return "word: \"" + this.sval + "\"";
+ } else if (token == '"') {
+ return "string: \"" + this.sval + "\"";
+ }
+
+ String res = String.valueOf((char) token);
+ if (quoteChars) res = "'" + res + "'";
+ return res;
+ }
+}