Note that there are some explanatory texts on larger screens.

plurals
  1. POBoost Spirit Rule's assignment operator
    primarykey
    data
    text
    <p>this is my first time asking a question here. It has already taken me a lot of time and research to get this working and I can't. I really hope you can help me with it. I am a newbie using Spirit, I do not fully understand all the terms; however, even after reading tons of articles and posts I do not know what am I missing.</p> <p>So, I have the following struct and class in a header file.</p> <pre><code>typedef std::string::const_iterator iterator_type; struct GrammarRules { qi::rule&lt;iterator_type, ascii::space_type&gt; create_char; }; class Parser { public: Parser(); bool parse(std::string const&amp; to_parse); private: GrammarRules rules_; gtor::World * world_; }; </code></pre> <p>Then I have the following in the .cpp file:</p> <pre><code>Parser::Parser() : rules_() , world_(nullptr) { world_ = new gtor::World(); qi::rule&lt;iterator_type, std::string(), ascii::space_type&gt; qg_string; qg_string %= qi::lexeme[ +(ascii::alnum) ]; rules_.create_char = ( qi::lit("CreateChar") &gt;&gt; '(' &gt;&gt; qg_string &gt;&gt; ',' &gt;&gt; qg_string &gt;&gt; ',' &gt;&gt; qi::int_ &gt;&gt; ')' ) [ phx::bind(&amp;gtor::World::createCharacter, world_, qi::_1, qi::_2, qi::_3) ] ; } ... bool Parser::parse(std::string const&amp; to_parse) { iterator_type it = to_parse.begin(); iterator_type end = to_parse.end(); bool success = qi::phrase_parse(it, end, rules_.create_char, ascii::space); /*qi::rule&lt;iterator_type, std::string(), ascii::space_type&gt; qg_string; qg_string %= qi::lexeme[ +(ascii::alnum) ]; qi::rule&lt;iterator_type, ascii::space_type&gt; create_char1 = ( qi::lit("CreateChar") &gt;&gt; '(' &gt;&gt; qg_string &gt;&gt; ',' &gt;&gt; qg_string &gt;&gt; ',' &gt;&gt; qi::int_ &gt;&gt; ')' ) [ phx::bind(&amp;gtor::World::createCharacter, world_, qi::_1, qi::_2, qi::_3) ] ; bool success = qi::phrase_parse(it, end, create_char1, ascii::space);*/ if (success &amp;&amp; it == end) return true; return false; } </code></pre> <p>The code which is not commented on the <code>parse()</code> method doesn't work, I get an <code>Access Violation</code> as soon as the parser gets to the <code>qg_string</code> rule. However, the code that is commented works perfectly. It looks exactly the same to me, except for the obvious differences. Maybe I am missing something very obvious, but I am unable to find it.</p> <p>It already took me a lot to find that my code worked if I used everything as local variables. And still can't find the problem.</p> <p>Thank you in advance for any help. Sorry if there are any mistakes in the post (5AM).</p>
    singulars
    1. This table or related slice is empty.
    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