Note that there are some explanatory texts on larger screens.

plurals
  1. PODetecting the parameter types in a Spirit semantic action
    primarykey
    data
    text
    <p>General case: I can't figure out why my Spirit grammar/semantics actions aren't compiling. </p> <p>Sometimes, the compiler will complain about assignment or type incompatibilities and I have no clue what's wrong. The problem occurs in two main areas:</p> <ul> <li>predicting the type of synthesized attributes for a rule/expression <ul> <li>consequently, predicting what types of attributes can be legally defined as the exposed attribute for the rule (relying in builting conversions, fusion adaptors or Spirit customization points)</li> </ul></li> <li>matching the argument types for my semantic action so that <ul> <li>the compiler will be able to compile the function invocation</li> <li>the invocation will not invoke unnecessary implicit conversions in the process</li> </ul></li> </ul> <p>The compiler error is not exactly tractable, and either the documentation is wrong, or I misunderstood it. </p> <p><strong>Is there a way to find out <em>exactly</em> what Spirit passes into my semantic action, anyway?</strong></p> <h3>Example code:</h3> <pre><code>struct mybase { int a,b; }; struct myderived : mybase { int c,d; }; BOOST_FUSION_ADAPT_STRUCT(mybase, (int,a)(int,b)); BOOST_FUSION_ADAPT_STRUCT(myderived, (int,a)(int,b)(int,c)(int,d)); auto base_expr = int_ &gt;&gt; int_; // avoids assigning to struct attribute rule&lt;decltype(f), mybase() , space_type&gt; base_ = int_ &gt;&gt; int_; rule&lt;decltype(f), myderived(), space_type&gt; derived_ = base_ &gt;&gt; int_ &gt;&gt; int_; myderived data; bool ok = phrase_parse(f,l,derived_,space,data); </code></pre> <p>This code won't compile, with a huge amount of impenetrable errors.</p> <p>(<em>loosely adapted from a posting on the <a href="http://boost.2283326.n4.nabble.com/struct-derived-struct-fusion-adapted-and-the-sequence-operator-tc4259090.html" rel="noreferrer">spirit-general</a> list</em>)</p>
    singulars
    1. This table or related slice is empty.
    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.
 

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