title: Troubles with boost::spirit::lex & whitespace
body: <p>I try learning to use boost::spirit. To do that, I wanted to create some simple lexer, combine them and then start parsing using spirit. I tried modifying the example, but it doesn't run as expected (the result r isn't true).</p>
  
  <p>Here's the lexer:</p>
  
  <pre><code>#include &lt;boost/spirit/include/lex_lexertl.hpp&gt;
  
  namespace lex = boost::spirit::lex;
  
  template &lt;typename Lexer&gt;
  struct lexer_identifier : lex::lexer&lt;Lexer&gt;
  {
      lexer_identifier()
          : identifier("[a-zA-Z_][a-zA-Z0-9_]*")
          , white_space("[ \\t\\n]+")
      {
          using boost::spirit::lex::_start;
          using boost::spirit::lex::_end;
  
          this-&gt;self = identifier;
          this-&gt;self("WS") = white_space;
      }
      lex::token_def&lt;&gt; identifier;
      lex::token_def&lt;&gt; white_space;
      std::string identifier_name;
  };
  </code></pre>
  
  <p>And this is the example I'm trying to run:</p>
  
  <pre><code>#include "stdafx.h"
  
  #include &lt;boost/spirit/include/lex_lexertl.hpp&gt;
  #include "my_Lexer.h"
  
  namespace lex = boost::spirit::lex;
  
  int _tmain(int argc, _TCHAR* argv[])
  {
      typedef lex::lexertl::token&lt;char const*,lex::omit, boost::mpl::false_&gt; token_type;
      typedef lex::lexertl::lexer&lt;token_type&gt; lexer_type;
  
      typedef lexer_identifier&lt;lexer_type&gt;::iterator_type iterator_type;
  
      lexer_identifier&lt;lexer_type&gt; my_lexer;
  
      std::string test("adedvied das934adf dfklj_03245");
  
      char const* first = test.c_str();
      char const* last = &amp;first[test.size()];
  
      lexer_type::iterator_type iter = my_lexer.begin(first, last);
      lexer_type::iterator_type end = my_lexer.end();
  
      while (iter != end &amp;&amp; token_is_valid(*iter))
      {
          ++iter;
      }
  
      bool r = (iter == end);
  
      return 0;
  }
  </code></pre>
  
  <p>r is true as long as there is only one token inside the string. Why is this the case? </p>
  
  <p>Regards
  Tobias</p>