Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I can't see what's wrong: I've taken the effort to reconstruct your SSCCE.</p> <ul> <li><a href="http://liveworkspace.org/code/1pDtmn%241" rel="nofollow">http://liveworkspace.org/code/1pDtmn$1</a></li> </ul> <p>In the process, it seems I must have removed the problem. I suggest you do the same.</p> <h2>Oh, and this is how I'd write this:</h2> <ul> <li>no more phoenix</li> <li>no more constructors</li> <li>no more qi::locals</li> <li>no more needless copying</li> <li>using expectation points</li> </ul> <p>In short: no more fuss.</p> <pre><code>#include &lt;boost/spirit/include/qi.hpp&gt; #include &lt;boost/fusion/adapted/struct.hpp&gt; #include &lt;cstdint&gt; namespace qi = boost::spirit::qi; namespace chs = boost::spirit::ascii; //qi; typedef std::string::const_iterator StringIterator; struct Color { float r,g,b,a; }; BOOST_FUSION_ADAPT_STRUCT(Color, (float, r)(float, g)(float, b)(float, a)) template &lt;typename ItType, typename Skipper&gt; struct ColorGrammar : public qi::grammar&lt;StringIterator, Color(), Skipper&gt; { ColorGrammar() : ColorGrammar::base_type(rule_color, "color-grammar") { using namespace qi; rule_rgb = lit("rgb") &gt;&gt; '(' &gt; float_ &gt; ',' &gt; float_ &gt; ',' &gt; float_ &gt; attr(1.0f) &gt; ')'; rule_rgba = lit("rgba") &gt;&gt; '(' &gt; float_ &gt; ',' &gt; float_ &gt; ',' &gt; float_ &gt; ',' &gt; float_ &gt; ')'; rule_color = rule_rgb | rule_rgba; } private: qi::uint_parser&lt;uint8_t, 10, 1, 3&gt; number; // unused qi::uint_parser&lt;uint8_t, 16, 1, 1&gt; hexdigit; // unused qi::rule&lt;ItType, Color(), Skipper&gt; rule_rgb, rule_rgba, rule_color; }; int main() { Color out; std::string str = " rgb ( 0.3 , .4 , 0.5 )"; StringIterator begin = str.cbegin(); StringIterator end = str.cend(); ColorGrammar&lt;StringIterator, chs::space_type&gt; color_; bool result = qi::phrase_parse(begin, end, color_, chs::space, out); std::cout &lt;&lt; std::boolalpha &lt;&lt; result &lt;&lt; '\n'; std::cout &lt;&lt; "remains: '" &lt;&lt; std::string(begin, end) &lt;&lt; "'\n"; } </code></pre> <p>Live on <a href="http://liveworkspace.org/code/35htD%243" rel="nofollow">http://liveworkspace.org/code/35htD$3</a></p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload