title: Boost Spirit sequential key value parser
body: <p>Is there a better way of doing this with Spirit? I'm parsing a sequential series of key value pairs, with some line endings and other cruft in between. The format is not so consistent that I can just pull key values pairs out with a single rule. So I've got an adapter and production rules like:</p>
  
  <pre><code>BOOST_FUSION_ADAPT_STRUCT(
    Record,
    ( std::string, messageHeader )
    ( double, field1 )
    ( std::string, field2 )
    ( Type3, field3 )
    // ...
    ( TypeN, fieldN )
  )
  
  template&lt; typename Iterator, typename Skipper &gt;
  class MyGrammar : public qi::grammar&lt; Iterator, Record(), Skipper &gt;
  {
  public:
    MyGrammar() : MyGrammar::base_type{ record }
    {
      record =
        qi::string( "Message header" )
        &gt;&gt; field1 &gt;&gt; field2
        // ...
        &gt;&gt; fieldN;
      field1 = qi::lit( "field 1:" ) &gt;&gt; qi::double_;
      // ...
    }
  
    // field rule declarations...
  };
  </code></pre>
  
  <p>This is a straightforward if tedious way of going about it, and I've already exceeded the compiler's rule complexity threshold once, which forced me to refactor the fields into separate rules. Also if there's an error parsing a message, the parser always shows the error being at the beginning of the string, like the rule doesn't give it enough context to figure out where the problem actually is. I assume this is from the way the <code>&gt;&gt;</code> operator works.</p>
  
  <p>Edit:</p>
  
  <p>In response to sehe's question, I've run into two problems with this approach and the MSVC 15 compiler. The first was a compiler error on my top-level production when it hit somewhere in the vicinity of 80 components separated by <code>&gt;&gt;</code>:</p>
  
  <pre><code>recursive type or function dependency context too complex
  </code></pre>
  
  <p>So I pushed everything I could down into subordinate rules to reduce the complexity. Unfortunately now, after adding still more rules, I'm running into:</p>
  
  <pre><code>fatal error C1060: compiler is out of heap space
  </code></pre>
  
  <p>So I find that I do need some way to further decompose the problem that's not just a long series of concatenated production rules...</p>