|
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
{
private:
//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*);
public:
MYParser(void);
//distuttore
Í MYParser();
};
MYParser::MYParser()
{
//(SQLParser::*ptrAnnounceComment)();// = &SQLParser::AnnounceComment;
//AnnounceComment is my Member functions
ptrAnnounceComment=&SQLParser::AnnounceComment;
//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 =
boost::spirit::anychar_parser](((const
boost::spirit::parser<boost::spirit::anychar_parser>&)((const
boost::spirit::parser<boost::spirit::anychar_parser>*)(&
boost::spirit::anychar_p))))[((SQLParser*)this)->*((SQLParser*)this)->SQLParser::ptrAnnounceComment]ââ
on the line:
rComment = str_p("#") >> (*anychar_p)[ this->*ptrAnnounceComment ];
But..why?
I have only a little experience with C++ and spirit :-(
Ciao
Claudio
-- View this message in context: http://www.nabble.com/Spirit%2C-semantic-actions-and-C%2B%2B-classes-tp22267555p22267555.html Sent from the Boost - Dev mailing list archive at Nabble.com.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk