40 using namespace reranker;
44 main(
int argc,
char **argv) {
45 cerr <<
"Testing StreamTokenizer with string arg constructor:" << endl;
46 string test_string =
"foo(bar, baz(34), bleh(\"fleh with spaces\"))";
52 cout <<
"token: \"" << st1.
Next() <<
"\""
54 <<
"; start=" << start
55 <<
"; line=" << line_number
57 cout <<
"chars so far: '" << st1.
str() <<
"'" << endl;
59 cerr <<
"Done." << endl;
61 cerr <<
"\nTesting Putback:" << endl;
67 cout <<
"token: \"" << st1.
Next() <<
"\""
69 <<
"; start=" << start
70 <<
"; line=" << line_number
72 cout <<
"chars so far: '" << st1.
str() <<
"'" << endl;
75 cerr <<
"\nTesting Rewind(3):" << endl;
81 cout <<
"token: \"" << st1.
Next() <<
"\""
83 <<
"; start=" << start
84 <<
"; line=" << line_number
86 cout <<
"chars so far: '" << st1.
str() <<
"'" << endl;
89 cerr <<
"Testing Rewind():" << endl;
95 cout <<
"token: \"" << st1.
Next() <<
"\""
97 <<
"; start=" << start
98 <<
"; line=" << line_number
100 cout <<
"chars so far: '" << st1.
str() <<
"'" << endl;
103 cerr <<
"\nReading from stdin until EOF:" << endl;
108 cout <<
"token: \"" << st2.
Next() <<
"\""
A simple class for tokenizing a stream of tokens for the formally specified language used to construc...
string str()
Returns the entire sequence of characters read so far by this stream tokenizer as a newly constructed...
size_t PeekTokenStart() const
Returns the next token’s start position, or the byte position of the underlying byte stream if there ...
static const char * TypeName(TokenType token_type)
Returns a string type name for the specified TokenType constant.
bool HasNext() const
Returns whether there is another token in the token stream.
Provides the StreamTokenizer class.
string Next()
Returns the next token in the token stream.
void Rewind()
Rewinds this token stream to the beginning.
size_t PeekTokenLineNumber() const
Returns the line number of the first byte of the next token, or the current line number of the underl...
TokenType
The set of types of tokens read by this stream tokenizer.
int main(int argc, char **argv)
void Putback()
A synonym for Rewind(1).
TokenType PeekTokenType() const
Returns the type of the next token, or EOF_TYPE if there is no next token.