What is the canonical way to declare parsers using X3?
The [documentation for X3][1] creates parsers similar to this:
namespace parser
{
namespace x3 = boost::spirit::x3;
using parser_type = x3::rule<class parser_class, attribute>;
parser_type const parser = "parser";
auto const parser_def = x3::lit("my parser");
BOOST_SPIRIT_DEFINE(parser);
}
I've also seen `parser_def` changed to look like this:
auto const parser_def = parser_type{"parser"}
= x3::lit("my parser");
But this seems like it would have ODR violations if it was in a header. I definitely want my parsers in headers to make for easier parsing. I could simply add `inline` to the variables (C++17):
namespace parser
{
namespace x3 = boost::spirit::x3;
using parser_type = x3::rule<class parser_class, attribute>;
inline parser_type const parser = "parser";
inline auto const parser_def = x3::lit("my parser");
BOOST_SPIRIT_DEFINE(parser);
}
But X3 is designed to work prior to C++17, so I feel like I'm doing something wrong.