In order to call a member function of an object you need to provide two things:
- the address of the member function, as said before you can get that by writing
&my_class::my_member
- the pointer (or a reference) to the instance of the object you want the member function be invoked for
Spirit semantic actions expect you to provide a function or function object exposing a certain interface. In your case the expected interface is:
void func(Iterator first, Iterator Last);
where Iterator is the iterator type used to call the parse function (accessible through typename ScannerT::iterator_t
). What you need to do is to create a function object exposing the mentioned interface while still calling your member function. While this can be done manually, doing so is tedious at best. The simplest way to create a function object is by using Boost.Bind:
prog = (alpha_p >> *alnum_p)
[
boost::bind(&ParserActions::do_prog, self.action)
];
which will create the required function object for you, binding and wrapping your member function.
All this assumes your member function does not take any arguments. If you need to pass the pair of iterators the semantic action will be invoked with to your function the construct needs to be written as:
prog = (alpha_p >> *alnum_p)
[
boost::bind(&ParserActions::do_prog, self.action, _1, _2)
];
instructing the function object to forward its first and second parameter to the bound function.