Boost logo

Boost :

Subject: [boost] Spirit, semantic actions and C++ classes
From: Claudio La Rosa (clros_at_[hidden])
Date: 2009-03-01 01:31:55

I am writing a class that implements a simple parser.

In the costructor I created the rule and the parser...and I recall the
functions for the semantic actions.
I have implemented this function as member funcions and, for recalled it, I
use a pointer to my member function in this manner:

#include <boost/spirit.hpp>
using namespace boost::spirit;

class MYParser
  //main rules
  rule<const char*> rLine, rComment;
  //This are the “semantic action”
  void AnnounceComment(char const*, char const*);

  // ...and this is the pointer to my “semantic action”
  void (SQLParser::*ptrAnnounceComment)(char const*, char const*);

  Í  MYParser();

  //(SQLParser::*ptrAnnounceComment)();// = &SQLParser::AnnounceComment;
  //AnnounceComment is my Member functions

  //make the parser
  rLine = rComment;

 rSpazi = *space_p;
 rTerminal = !ch_p(';');
 //commento SQL fino a fine riga
 rComment = str_p("#") >> (*anychar_p)[ this->*ptrAnnounceComment ];

I obtain an error:

“no match for ‘operator[]’ in ‘boost::spirit::operator* [with S =

on the line:

rComment = str_p("#") >> (*anychar_p)[ this->*ptrAnnounceComment ];


I have only a little experience with C++ and spirit :-(


View this message in context:
Sent from the Boost - Dev mailing list archive at

Boost list run by bdawes at, gregod at, cpdaniel at, john at