|
Boost Users : |
Subject: [Boost-users] [xpressive] Calling a function with captured text as a parameter from a rule action
From: Ami Ganguli (ami.ganguli_at_[hidden])
Date: 2009-10-01 03:29:10
Hi all,
I've been trying to wrap my head around xpressive. I've got a rule
that captures some text, calls a function as part of the action. The
function call works, but as soon as I try to pass my captured text as
a parameter to the function, I run into a rather long and
incomprehensible compilation error.
Are there working examples somewhere that do this? (There are
examples on calling functions and examples on using captured text in
the docs, but nothing that does both)
Here's the important bits of my code:
My function object:
struct append_element_impl
{
typedef void result_type;
void operator()(std::string& text) const
{
std::cout << "appending " << text;
}
};
function<append_element_impl>::type const append_element = {{}};
The part of the parser that calls the function:
h1 = "=" >> +blank >> * (s1= ~_ln) >> eol
[append_element(as<std::string>(s1))];
I've tried various variations on this (the "as<std::string>" is a
recent addition, and doesn't seem to make much difference). If I get
rid of the s1 parameter in both the function and the call, then
everything works as expected.
The last part of the error message (the part that I sort of understand) is:
/usr/local/include/boost/proto/context/default.hpp:357: error: no
match for call to (const append_element_impl(std::basic_string<char,
std::char_traits<char>, std::allocator<char> >)
/home/ganguli/acms/plug-ins/wikitext/wikitext.C:27: note:
candidates are: void append_element_impl::operator((std::string&)
const
/usr/local/include/boost/proto/context/default.hpp:357: error:
return-statement with a value, in function returning 'void'
I'd really appreciate any pointers on this, or just some examples on
how to do something similar.
Cheers,
Ami.
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net