title: Why does this boost::spirit::qi rule not match the input?
body: <p>I tried to continue to work on my previous example and expand the rules. My problem is, that rules that use ID_IDENTIFIER do not work - although I know that the lexer is working (using unit tests).</p>
  
  <p>Here's the example:</p>
  
  <pre><code>#include &lt;boost/spirit/include/qi.hpp&gt;
  #include &lt;boost/spirit/include/lex_lexertl.hpp&gt;
  
  namespace qi  = boost::spirit::qi;
  namespace lex = boost::spirit::lex;
  
  enum LexerIDs { ID_IDENTIFIER, ID_WHITESPACE, ID_INTEGER, ID_FLOAT, ID_PUNCTUATOR };
  
  template &lt;typename Lexer&gt;
  struct custom_lexer : lex::lexer&lt;Lexer&gt;
  {
      custom_lexer()
          : identifier    ("[a-zA-Z_][a-zA-Z0-9_]*")
          , white_space   ("[ \\t\\n]+")
          , integer_value ("[1-9][0-9]*")
          , hex_value     ("0[xX][0-9a-fA-F]+")
          , float_value   ("[0-9]*\\.[0-9]+([eE][+-]?[0-9]+)?")
          , float_value2  ("[0-9]+\\.([eE][+-]?[0-9]+)?")
          , punctuator    ("\\[|\\]|\\(|\\)|\\.|&amp;&gt;|\\*\\*|\\*|\\+|-|~|!|\\/|%|&lt;&lt;|&gt;&gt;|&lt;|&gt;|&lt;=|&gt;=|==|!=|\\^|&amp;|\\||\\^\\^|&amp;&amp;|\\|\\||\\?|:|,")// [ ] ( ) . &amp;&gt; ** * + - ~ ! / % &lt;&lt; &gt;&gt; &lt; &gt; &lt;= &gt;= == != ^ &amp; | ^^ &amp;&amp; || ? : ,
      {
          using boost::spirit::lex::_start;
          using boost::spirit::lex::_end;
  
          this-&gt;self.add
              (identifier   , ID_IDENTIFIER)
              /*(white_space  , ID_WHITESPACE)*/
              (integer_value, ID_INTEGER)
              (hex_value    , ID_INTEGER)
              (float_value  , ID_FLOAT)
              (float_value2 , ID_FLOAT)
              (punctuator   , ID_PUNCTUATOR);
  
          this-&gt;self("WS") = white_space;
      }
      lex::token_def&lt;std::string&gt; identifier;
      lex::token_def&lt;lex::omit&gt;   white_space;
      lex::token_def&lt;int&gt;         integer_value;
      lex::token_def&lt;int&gt;         hex_value;
      lex::token_def&lt;double&gt;      float_value;
      lex::token_def&lt;double&gt;      float_value2;
      lex::token_def&lt;&gt;            punctuator;
  };
  
  template&lt; typename Iterator, typename Skipper&gt;
  struct custom_grammar : qi::grammar&lt;Iterator, Skipper&gt;
  {
  
      template&lt; typename TokenDef &gt;
      custom_grammar(const TokenDef&amp; tok) : custom_grammar::base_type(ges)
      {
          ges = qi::token(ID_IDENTIFIER);
          BOOST_SPIRIT_DEBUG_NODE(ges);
      }
      qi::rule&lt;Iterator, Skipper &gt; ges;
  };
  
  int main(int argc, _TCHAR* argv[])
  {
      std::string test("testidentifier");
  
      typedef char const* Iterator;
      typedef lex::lexertl::token&lt;Iterator, lex::omit, boost::mpl::true_&gt; token_type;
      typedef lex::lexertl::lexer&lt;token_type&gt; lexer_type;
      typedef qi::in_state_skipper&lt;custom_lexer&lt;lexer_type&gt;::lexer_def&gt; skipper_type;
  
      typedef custom_lexer&lt;lexer_type&gt;::iterator_type iterator_type;
  
      custom_lexer&lt;lexer_type&gt; my_lexer; 
      custom_grammar&lt;iterator_type, skipper_type&gt; my_grammar(my_lexer);
  
      Iterator first = test.c_str();
      Iterator last = &amp;first[test.size()];
  
      bool r = lex::tokenize_and_phrase_parse(first,last,my_lexer,my_grammar,qi::in_state( "WS" )[ my_lexer.self ]);
  
      std::cout &lt;&lt; std::boolalpha &lt;&lt; r &lt;&lt; "\n";
      std::cout &lt;&lt; "Remaining unparsed: '" &lt;&lt; std::string(first,last) &lt;&lt; "'\n";
      return 0;
  }
  </code></pre>
  
  <p>a similar rule with ID_INTEGER matches fine for "1234"</p>