4#include <boost/fusion/include/std_pair.hpp>
5#include <boost/fusion/include/vector.hpp>
6#include <boost/spirit/home/x3.hpp>
10using boost::spirit::x3::parse;
11namespace format::newick::parser
13namespace x3 = boost::spirit::x3;
15static x3::rule<class branch, ast::node>
const node{
"node"};
17static auto const name = x3::lexeme[x3::alpha >> *x3::alnum];
18static auto const length =
':' >> x3::double_ | x3::attr(0.0);
19static auto const leaf = name | x3::attr(std::string{});
20static auto const children =
'(' >> (node %
',') >>
')' | x3::attr(ast::nodes{});
21static auto const node_def = children >> leaf >> -length;
22static auto const tree = x3::skip(x3::blank)[node >>
';' >> x3::eoi];
24BOOST_SPIRIT_DEFINE(node);
26template <
typename ExpectedAttributeType>
void compatible(
auto p)
29 std::is_same_v<ExpectedAttributeType,
30 typename x3::traits::attribute_of<
decltype(x3::rule<struct _, ExpectedAttributeType>{} = p),
31 x3::unused_type>::type>);
36 compatible<double>(length);
37 compatible<std::string>(leaf);
38 compatible<std::string>(name);
39 compatible<ast::nodes>(children);
40 compatible<ast::node>(tree);
Simulation of coalescence-based models of molecular evolution.
Definition coalescence.hpp:21