*/
package org.z3950.zing.cql;
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStreamReader;
+
/**
* Implementation of the CQL lexical syntax analyzer
* @author jakub
}
//quoted string
} else if (strchr("\"", c)) { //no single-quotes
- what = '"';
+ what = TT_STRING;
//remember quote char
char mark = c;
qi++;
return "EOF";
case TT_WORD:
return "word: '" + val + "'";
- case '"':
+ case TT_STRING:
return "string: \"" + val + "\"";
case TT_LE:
return "<=";
if (args.length == 1) {
cql = args[0];
} else {
- byte[] bytes = new byte[10000];
+ BufferedReader buff = new BufferedReader(new InputStreamReader(System.in));
try {
- // Read in the whole of standard input in one go
- int nbytes = System.in.read(bytes);
- } catch (java.io.IOException ex) {
+ // read a single line of input
+ cql = buff.readLine();
+ if (cql == null) {
+ System.err.println("Can't read query from stdin");
+ System.exit(2);
+ return;
+ }
+ } catch (IOException ex) {
System.err.println("Can't read query: " + ex.getMessage());
System.exit(2);
+ return;
}
- cql = new String(bytes);
}
CQLTokenizer lexer = new CQLLexer(cql, true);