X3: Alternative operator doesn't reduce?
Aaron Graham <[email protected]> Fri, 10 Jul 2020 13:02:46 -0700
| Newsgroups | gmane.comp.parsers.spirit.general |
|---|---|
| Message-ID | <CADXX4PTFa3NQbJyCFoMn01OVuYWL7Pu1NnEn6Hja6Z5BQeaR_A@mail.gmail.com> |
X3 compound attribute rules
<https://www.boost.org/doc/libs/1_73_0/libs/spirit/doc/x3/html/spirit_x3/quick_reference/compound_attribute_rules.html>
say this:
a: A, b: A --> (a | b): A
However, when I write this simple bit of code (exposition purposes only):
#include <boost/spirit/home/x3.hpp>
int main() {
using namespace boost::spirit::x3;
auto const quoted_string = lexeme['"' >> *(char_ - '"') >> '"'];
auto value = std::string{};
auto assign_string = [&](auto& ctx){ value = _attr(ctx); };
auto const any_string = (quoted_string | quoted_string) [assign_string];
auto val = std::string_view{"\"Test\""};
phrase_parse(val.begin(), val.end(), any_string, space);
}
I get this error:
error: no match for ‘operator=’ (operand types are ‘std::__cxx11::b
asic_string<char>’ and ‘
boost::variant<boost::detail::variant::over_sequence<boo
st::mpl::l_item<mpl_::long_<2>, std::__cxx11::basic_string<char>,
boost::mpl::l_
item<mpl_::long_<1>, std::__cxx11::basic_string<char>, boost::mpl::l_end> >
> >’
)
7 | auto assign_string = [&](auto& ctx){ value = _attr(ctx); };
|
Why is the attribute a variant instead of a string?
_______________________________________________
Spirit-general mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/spirit-general