[Boost-users][Spirit] Semantic Action for a Class Member Variable to a Karma Rule

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

[Boost-users][Spirit] Semantic Action for a Class Member Variable to a Karma Rule

Ryan-2
I'm trying to assign a semantic action to a rule and running into issues.  I was able to get this to work with a Qi rule and thought I could just reverse things for the Karma version.  I'm using Boost 1.47 and Spirit 0x2050 (which I believe is 2.50).  Any help on assigning class member variables to a Karma rule would be appreciated.
 
Ryan
 
 
#include <string>
#include <boost/spirit/include/phoenix.hpp>
#include <boost/spirit/include/karma.hpp>
 
class Bob {
  std::string m_Name;
 
public:
std::string const generateMessage(void) const {
    namespace karma = boost::spirit::karma;
    namespace phx   = boost::phoenix;
 
    typedef std::back_insert_iterator<std::string>  iter;
 
    karma::rule<iter, std::string()> value = *karma::char_("a-zA-Z_0-9");
    karma::rule<iter, std::string()> tag = karma::char_("a-zA-Z_") << value;
 
    //Error for this rule.
    karma::rule<iter, std::string()> name = tag[ karma::_1 = phx::bind(&Bob::m_Name, this) ];
 
    std::string output;
    iter  sind(output);
 
    karma::generate(sink, name);
    return output;
  }
};
 
int main(void) {
  Bob bob;
  std::string value = bob.generateMessage();
 
  return 0;
}

------------------------------------------------------------------------------
Download BIRT iHub F-Type - The Free Enterprise-Grade BIRT Server
from Actuate! Instantly Supercharge Your Business Reports and Dashboards
with Interactivity, Sharing, Native Excel Exports, App Integration & more
Get technology previously reserved for billion-dollar corporations, FREE
http://pubads.g.doubleclick.net/gampad/clk?id=157005751&iu=/4140/ostg.clktrk
_______________________________________________
Spirit-general mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/spirit-general