
Symons, Greg - SSD wrote:
Hi!
I'm trying to use xpressive with semantic actions that use a placeholder, but I can't quite see the right way to do it. Here's my code:
namespace grammar { using namespace boost::xpressive;
struct ParsedUri { std::string hostname; std::string modelPath; std::string diagramPath; };
static placeholder<ParsedUri> result; <snip>
static sregex pathHost = (host= hostname) >> pathSep >> path [ result.hostname = host ]; static sregex modelPath = pathNoHost | pathHost static sregex uri = "rosert://" >> (model= modelPath) >> '?' >> (diagram= path) [ result.modelPath = model, result.diagramPath = diagram ]; }
What happens is that when I compile the code, I get a compile error for the lines accessing the placeholder saying that the various members of the structure are not members of placeholder<T>, which looking at regex_actions.hpp seems to make sense to me.
Right.
But in the example using placeholder<T> in the docs, it looks like you can use it in the semantic action as if it were a T. Somewhere I'm misunderstanding something, and I don't know what. Can anyone help me here?
Xpressive overloads operators to give the impression that your can use a
placeholder<T> as a T. But xpressive cannot overload operator. to give
the impression of data member access because in C++ you can't overload
operator..
Try this instead...
xpressive::function