ctype[ch] = 0;
}
void commentChar(int ch)
{
if (ch >= 0 && ch < _COUNT_OF(ctype))
ctype[ch] = CT_COMMENT;
}
void quoteChar(int ch)
{
if (ch >= 0 && ch < _COUNT_OF(ctype))
ctype[ch] = CT_QUOTE;
}
void parseNumbers()
{
for (int i = '0'; i <= '9'; i++)
ctype[i] |= CT_DIGIT;
ctype['.'] |= CT_DIGIT;
ctype['-'] |= CT_DIGIT;
}
/**
* Determines whether or not ends of line are treated as tokens.
* If the flag argument is true, this tokenizer treats end of lines
* as tokens; the nextToken method returns
* TT_EOL and also sets the ttype field to
* this value when an end of line is read.
*
* A line is a sequence of characters ending with either a
* carriage-return character ('\r') or a newline
* character ('\n'). In addition, a carriage-return
* character followed immediately by a newline character is treated
* as a single end-of-line token.
*
* If the flag is false, end-of-line characters are
* treated as white space and serve only to separate tokens.
*
* @param flag true indicates that end-of-line characters
* are separate tokens; false indicates that
* end-of-line characters are white space.
* @see java.io.StreamTokenizer#nextToken()
* @see java.io.StreamTokenizer#ttype
* @see java.io.StreamTokenizer#TT_EOL
*/
void eolIsSignificant(bool flag)
{
eolIsSignificantP = flag;
}
void slashStarComments(bool flag)
{
slashStarCommentsP = flag;
}
void slashSlashComments(bool flag)
{
slashSlashCommentsP = flag;
}
void lowerCaseMode(bool fl)
{
forceLower = fl;
}
/** Read the next character */
private:
int read()
{
return input.get();
}
int nextToken() {
if (pushedBack) {
pushedBack = false;
return ttype;
}
unsigned char* ct = ctype;
int c = peekc;
if (c < 0)
c = NEED_CHAR;
if (c == SKIP_LF) {
c = read();
if (c < 0)
return ttype = TT_EOF;
if (c == '\n')
c = NEED_CHAR;
}
if (c == NEED_CHAR) {
c = read();
if (c < 0)
return ttype = TT_EOF;
}
ttype = c; /* Just to be safe */
/* Set peekc so that the next invocation of nextToken will read
* another character unless peekc is reset in this invocation
*/
peekc = NEED_CHAR;
int ctype = c < 256 ct[c] : CT_ALPHA;
while ((ctype & CT_WHITESPACE) != 0) {