From: mike Date: Fri, 29 Jun 2007 15:38:56 +0000 (+0000) Subject: Support for "==" relation (TT_EQEQ) X-Git-Tag: v1.5~66 X-Git-Url: http://jsfdemo.indexdata.com/cgi-bin?a=commitdiff_plain;h=8d4197c069c477cb1285b047b4e4ea5ca22ad79d;p=cql-java-moved-to-github.git Support for "==" relation (TT_EQEQ) --- diff --git a/src/org/z3950/zing/cql/CQLLexer.java b/src/org/z3950/zing/cql/CQLLexer.java index 11c99ea..01cc05d 100644 --- a/src/org/z3950/zing/cql/CQLLexer.java +++ b/src/org/z3950/zing/cql/CQLLexer.java @@ -1,4 +1,4 @@ -// $Id: CQLLexer.java,v 1.12 2007-06-29 12:54:05 mike Exp $ +// $Id: CQLLexer.java,v 1.13 2007-06-29 15:38:56 mike Exp $ package org.z3950.zing.cql; import java.io.StreamTokenizer; @@ -19,10 +19,11 @@ class CQLLexer extends StreamTokenizer { static int TT_LE = 1000; // The "<=" relation static int TT_GE = 1001; // The ">=" relation static int TT_NE = 1002; // The "<>" relation - static int TT_AND = 1003; // The "and" boolean - static int TT_OR = 1004; // The "or" boolean - static int TT_NOT = 1005; // The "not" boolean - static int TT_PROX = 1006; // The "prox" boolean + static int TT_EQEQ = 1003; // The "==" relation + static int TT_AND = 1004; // The "and" boolean + static int TT_OR = 1005; // The "or" boolean + static int TT_NOT = 1006; // The "not" boolean + static int TT_PROX = 1007; // The "prox" boolean // Support for keywords. It would be nice to compile this linear // list into a Hashtable, but it's hard to store ints as hash @@ -126,6 +127,18 @@ class CQLLexer extends StreamTokenizer { ttype = '>'; debug("AFTER: ttype is now " + ttype + " - " + render()); } + } else if (ttype == '=') { + debug("token starts with '=' ..."); + underlyingNextToken(); + if (ttype == '=') { + debug("token continues with '=' - it's '=='"); + ttype = TT_EQEQ; + } else { + debug("next token is " + render() + " (pushed back)"); + halfDecentPushBack(); + ttype = '='; + debug("AFTER: ttype is now " + ttype + " - " + render()); + } } debug("done nextToken(): ttype=" + ttype + ", " + @@ -175,6 +188,8 @@ class CQLLexer extends StreamTokenizer { return ">="; } else if (token == TT_NE) { return "<>"; + } else if (token == TT_EQEQ) { + return "=="; } // Check whether its associated with one of the keywords diff --git a/src/org/z3950/zing/cql/CQLParser.java b/src/org/z3950/zing/cql/CQLParser.java index 59d41d9..b23506c 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.35 2007-06-29 15:24:26 mike Exp $ +// $Id: CQLParser.java,v 1.36 2007-06-29 15:39:09 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.35 2007-06-29 15:24:26 mike Exp $ + * @version $Id: CQLParser.java,v 1.36 2007-06-29 15:39:09 mike Exp $ * @see http://zing.z3950.org/cql/index.html */ @@ -203,7 +203,8 @@ public class CQLParser { lexer.ttype == '=' || lexer.ttype == lexer.TT_LE || lexer.ttype == lexer.TT_GE || - lexer.ttype == lexer.TT_NE); + lexer.ttype == lexer.TT_NE || + lexer.ttype == lexer.TT_EQEQ); } private void match(int token)