-import java.io.StreamTokenizer;
-import java.io.StringReader;
-import java.util.Hashtable;
-
-
-// This is a semi-trivial subclass for java.io.StreamTokenizer that:
-// * Has a halfDecentPushBack() method that actually works
-// * Includes a render() method
-// * Knows about the multi-character tokens "<=", ">=" and "<>"
-// * Recognises a set of keywords as tokens in their own right
-// * Includes some primitive debugging-output facilities
-// It's used only by CQLParser.
-//
-class CQLLexer extends StreamTokenizer {
- // New publicly visible token-types
- public final static int TT_LE = 1000; // The "<=" relation
- public final static int TT_GE = 1001; // The ">=" relation
- public final static int TT_NE = 1002; // The "<>" relation
- public final static int TT_EQEQ = 1003; // The "==" relation
- public final static int TT_AND = 1004; // The "and" boolean
- public final static int TT_OR = 1005; // The "or" boolean
- public final static int TT_NOT = 1006; // The "not" boolean
- public final static int TT_PROX = 1007; // The "prox" boolean
- public final static int TT_SORTBY = 1008; // The "sortby" operator
-
- // Support for keywords. It would be nice to compile this linear
- // list into a Hashtable, but it's hard to store ints as hash
- // values, and next to impossible to use them as hash keys. So
- // we'll just scan the (very short) list every time we need to do
- // a lookup.
- private class Keyword {
- int token;
- String keyword;
- Keyword(int token, String keyword) {
- this.token = token;
- this.keyword = keyword;
- }
- }
- // This should logically be static, but Java won't allow it :-P
- private Keyword[] keywords = {
- new Keyword(TT_AND, "and"),
- new Keyword(TT_OR, "or"),
- new Keyword(TT_NOT, "not"),
- new Keyword(TT_PROX, "prox"),
- new Keyword(TT_SORTBY, "sortby"),
- };
-
- // For halfDecentPushBack() and the code at the top of nextToken()
- private static int TT_UNDEFINED = -1000;
- private int saved_ttype = TT_UNDEFINED;
- private double saved_nval;
- private String saved_sval;