unread(ch);
return GT;
}
case '?':
CharBuffer cb = CharBuffer.allocate();
int index = 0;
for (ch = read(); ch >= '0' && ch <= '9'; ch = read()) {
cb.append((char) ch);
index = 10 * index + ch - '0';
}
unread(ch);
_lexeme = cb.close();
if (_lexeme.length() == 0) {
_lexeme = String.valueOf(++_parameterCount);
}
else if (index <= 0)
throw error(L.l("`{0}' must refer to a positive argument",
"?" + _lexeme));
return ARG;
case ':':
if (Character.isJavaIdentifierStart((char) (ch = read()))) {
cb = CharBuffer.allocate();
for (; ch > 0 && Character.isJavaIdentifierPart((char) ch); ch = read())
cb.append((char) ch);
unread(ch);
_lexeme = cb.close();
_parameterCount++;
}
else
throw error(L.l("`{0}' must be a valid parameter identifier",
":" + ((char) ch)));
return NAMED_ARG;
case '|':
if ((ch = read()) == '|')
return CONCAT_OP;
else
throw error(L.l("unexpected char at {0}", String.valueOf((char) ch)));
// @@ is useless?
case '@':
if ((ch = read()) != '@')
throw error(L.l("`@' expected at {0}", charName(ch)));
return scanToken();
}
if (Character.isJavaIdentifierStart((char) ch)) {
CharBuffer cb = CharBuffer.allocate();
for (; ch > 0 && Character.isJavaIdentifierPart((char) ch); ch = read())
cb.append((char) ch);
unread(ch);
_lexeme = cb.close();
String lower = _lexeme.toLowerCase(Locale.ENGLISH);
int token = _reserved.get(lower);
if (token > 0)
return token;
else
return IDENTIFIER;
}
else if (ch >= '0' && ch <= '9') {
CharBuffer cb = CharBuffer.allocate();
int type = INTEGER;
if (sign < 0)
cb.append('-');
for (; ch >= '0' && ch <= '9'; ch = read())
cb.append((char) ch);
if (ch == '.') {
type = DOUBLE;
cb.append('.');
for (ch = read(); ch >= '0' && ch <= '9'; ch = read())
cb.append((char) ch);
}
if (ch == 'e' || ch == 'E') {
type = DOUBLE;
cb.append('e');
if ((ch = read()) == '+' || ch == '-') {
cb.append((char) ch);
ch = read();
}
if (! (ch >= '0' && ch <= '9'))
throw error(L.l("exponent needs digits at {0}",
charName(ch)));
for (; ch >= '0' && ch <= '9'; ch = read())
cb.append((char) ch);
}
if (ch == 'F' || ch == 'D')
type = DOUBLE;
else if (ch == 'L') {
type = LONG;
}
else
unread(ch);
_lexeme = cb.close();
return type;
}
else if (ch == '\'') {
CharBuffer cb = CharBuffer.allocate();
cb.append("'");
for (ch = read(); ch >= 0; ch = read()) {
if (ch == '\'') {
if ((ch = read()) == '\'')
cb.append("''");
else {
unread(ch);
break;
}
}
else
cb.append((char) ch);
}
cb.append("'");
_lexeme = cb.close();
return STRING;
}
throw error(L.l("unexpected char at {0}", "" + (char) ch));