title: C++ scanner (string-fu!)
body: <p>I'm writing a scanner as part of a compiler.</p>
  
  <p>I'm having a major headache trying to write this one portion:</p>
  
  <p>I need to be able to parse a stream of tokens and push them one by one into a vector, ignoring whitespace and tokenizing special symbols (simple case, lets just consider parentheses and braces)</p>
  
  <p>Example:
      <code>int   main(){              }</code></p>
  
  <p>should parse into 6 different tokens:</p>
  
  <ol>
  <li>int </li>
  <li>main </li>
  <li>( </li>
  <li>) </li>
  <li>{ </li>
  <li>}</li>
  </ol>
  
  <p>How would you go about solving this? I'm writing this in C++, but a java/C# solution would be appreciated as well.</p>
  
  <p>Some points:</p>
  
  <ol>
  <li><p>and no, I can't use Boost, I can't guarantee that the libraries will be
  available to  me. (don't ask...)</p></li>
  <li><p>I don't want to use lex, or any other special tools. I've never done
  this before and just want to try this once to say I've done it.</p></li>
  </ol>