Skip to content

Instantly share code, notes, and snippets.

@peterhuene
Last active August 22, 2016 17:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save peterhuene/2ce5e403bf313ffc3f9caaaac8461bef to your computer and use it in GitHub Desktop.
Save peterhuene/2ce5e403bf313ffc3f9caaaac8461bef to your computer and use it in GitHub Desktop.
Spirit X3 1.61.0 error repro
#include <iostream>
#include <string>
#include <boost/spirit/home/x3.hpp>
#include <boost/fusion/include/std_pair.hpp>
using namespace std;
namespace x3 = boost::spirit::x3;
struct repro_string_parser : x3::parser<repro_string_parser>
{
using attribute_type = string;
template <typename Iterator, typename Attribute>
bool parse(Iterator& first, Iterator const& last, x3::unused_type, x3::unused_type, Attribute& attr) const
{
attr = "repro";
return true;
}
};
auto const repro_string = repro_string_parser{};
struct repro_empty_parser : x3::parser<repro_empty_parser>
{
using attribute_type = x3::unused_type;
template <typename Iterator, typename Attribute>
bool parse(Iterator& first, Iterator const& last, x3::unused_type, x3::unused_type, Attribute& attr) const
{
return true;
}
};
auto const repro_empty = repro_empty_parser{};
x3::rule<class repro_tag, pair<string, string>> const repro_rule = "repro";
auto const repro_rule_def = repro_string > repro_empty > repro_string;
BOOST_SPIRIT_DEFINE(repro_rule);
int main()
{
string input = "";
pair<string, string> result;
x3::parse(input.begin(), input.end(), repro_rule, result);
// Expected output: repro repro
cout << result.first << " " << result.second << endl;
return 0;
}
@peterhuene
Copy link
Author

The above is to demonstrate a compilation error (at line 16) when compiled with Boost 1.61.0. The repro builds without error and produces the expected output with Boost 1.60.0.

@peterhuene
Copy link
Author

@djowel I'm not sure if you saw my email on the Boost Spirit mailing list, but this break appears related to boostorg/spirit@a8e391b. Do you have any advice on how to fix this in the example parser with the x3::unused_type attribute type? Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment