rem: cerr << "usage: test_sieve_lexer [ <string> ]" << endl;
add: cerr << "usage: lexertest [ <string> ]" << endl;
context: int main( int argc, char * argv[]  ) {  if ( argc == 2 ) { // manual test    const char * scursor = argv[1];    const char * const send = argv[1] + qstrlen( argv[1] );    Lexer lexer( scursor, send );    cout << "Begin" << endl;    while ( !lexer.atEnd() ) {      QString result;      Lexer::Token token = lexer.nextToken( result );      if ( lexer.error() ) {	cout << "Error " << token2string( token ) << ": \""	     << lexer.error().asString().latin1() << "\" at ("	     << lexer.error().line() << "," << lexer.error().column()	     << ")" << endl;	break;      } else	cout << "Got " << token2string( token ) << ": \""	     << result.utf8().data() << "\" at ("	     << lexer.line() << "," << lexer.column() << ")" << endl;    }    cout << "End" << endl;  } else if ( argc == 1 ) { // automated test    bool success = true;    for ( int i = 0 ; i < numTestCases ; ++i ) {      bool ok = true;      const TestCase & t = testcases[i];      const char * const send = t.string + qstrlen( t.string );      Lexer lexer( t.string, send, Lexer::IncludeComments );      cerr << t.name << ":";      for ( int j = 0 ; !lexer.atEnd() ; ++j ) {	QString result;	Lexer::Token token = lexer.nextToken( result );	Error error = lexer.error();	if ( t.expected[j].token != token ) {	  ok = false;	  cerr << " expected token " << token2string( t.expected[j].token )	       << ", got " << token2string( token );	}	if ( QString::fromUtf8( t.expected[j].result ) != result ) {	  ok = false;	  if ( t.expected[j].result )	    cerr << " expected string \"" << t.expected[j].result << "\"";	  else	    cerr << " expected null string";	  if ( !result.utf8().isNull() )	    cerr << ", got \"" << result.utf8().data() << "\"";	  else	    cerr << ", got null string";	}	if ( error && error.type() != t.expectedError ) {	  ok = false;	  cerr << " expected error #" << (int)t.expectedError	       << ", got #" << (int)error.type();	}	if ( error && ( error.line() != t.errorLine || error.column() != t.errorCol ) ) {	  ok = false;	  cerr << " expected position (" << t.errorLine << "," << t.errorCol	       << "), got (" << error.line() << "," << error.column() << ")";	}	if ( error )	  goto ErrorOut;	if ( t.expected[j].token == Lexer::None &&	     t.expected[j].result == 0 )	  break;      }      if ( !lexer.atEnd() ) {	ok = false;	cerr << " premature end of expected token list";      }    ErrorOut:      if ( ok )	cerr << " ok";      cerr << endl;      if ( !ok )	success = false;    }    if ( !success )      return 1;  } else { // usage error    cerr << "usage: test_sieve_lexer [ <string> ]" << endl;    exit( 1 );  }  return 0;}