* date literal is otherwise not of the proper form:
* date 'longLiteral-longLiteral-longLiteral'.
*/
private Token dateLiteral(String alreadyConsumed) throws InvalidCharException {
StringBuffer sb = new StringBuffer(alreadyConsumed);
char curChar = getChar();
try {
curChar = _queryString.charAt(_pos);
curChar = consumeWhiteSpace(curChar);
if ( curChar != '\'' )
throw (new InvalidCharException("The date keyword must be followed by a single quote. Position: " + _pos));
sb.append(" '");
_pos++;
curChar = _queryString.charAt(_pos);
curChar = consumeWhiteSpace(curChar);
if ( ! isDigit(curChar) )
throw (new InvalidCharException("Digit expected in date literal. Position: " + _pos));
while ( isDigit(curChar) ) {
sb.append(curChar);
_pos++;
curChar = _queryString.charAt(_pos);
}
curChar = consumeWhiteSpace(curChar);
if ( curChar != '-' )
throw (new InvalidCharException("- expected. Fields in date literal must be separated by a dash. Position: " + _pos));
sb.append(curChar);
_pos++;
curChar = _queryString.charAt(_pos);
curChar = consumeWhiteSpace(curChar);
if ( ! isDigit(curChar) )
throw (new InvalidCharException("Digit expected in date literal. Position: " + _pos));
while ( isDigit(curChar) ) {
sb.append(curChar);
_pos++;
curChar = _queryString.charAt(_pos);
}
curChar = consumeWhiteSpace(curChar);
if ( curChar != '-' )
throw (new InvalidCharException("- expected. Fields in date literal must be separated by a dash. Position: " + _pos));
sb.append(curChar);
_pos++;
curChar = _queryString.charAt(_pos);
curChar = consumeWhiteSpace(curChar);
if ( ! isDigit(curChar) )
throw (new InvalidCharException("Digit expected in date literal. Position: " + _pos));
while ( isDigit(curChar) ) {
sb.append(curChar);
_pos++;
curChar = _queryString.charAt(_pos);
}
curChar = consumeWhiteSpace(curChar);
if ( curChar != '\'' )
throw (new InvalidCharException("' expected. Date literal must be enclosed by a single quotes. Position: " + _pos));
sb.append(curChar);
_pos++;
return (new Token( DATE_LITERAL, sb.toString() ));
}
catch (IndexOutOfBoundsException e) {
throw (new InvalidCharException("End of query encountered in the middle of date literal."));