diff --git a/doc/tutorial.qbk b/doc/tutorial.qbk index fb5b6b7d..e9500f20 100644 --- a/doc/tutorial.qbk +++ b/doc/tutorial.qbk @@ -2095,7 +2095,19 @@ whether they are inside or outside the _sep_ directive; you force each subparser to have a separate attribute. The rules for _merge_ and _sep_ overrule the steps of the algorithm described -above for combining the attributes of a sequence parser. +above for combining the attributes of a sequence parser. Consider an example. + + namespace bp = boost::parser; + constexpr auto parser = + bp::char_ >> bp::merge[(bp::string("abc") >> bp::char_ >> bp::char_) >> bp::string("ghi")]; + +You might think that `_ATTR_np_(parser)` would be `bp::tuple`. It is not. The parser above does not even compile. Since we +created a merge group above, we disabled the default behavior in which the +`char_` parsers would have collapsed into the `string` parser that preceded +them. Since they are all treated as separate entities, and since they have +different attribute types, the use of _merge_ is an error. + [heading Other directives that affect attribute generation] diff --git a/test/merge_separate.cpp b/test/merge_separate.cpp index 2381aa12..ee228e55 100644 --- a/test/merge_separate.cpp +++ b/test/merge_separate.cpp @@ -208,8 +208,7 @@ TEST(merge_separate, merge_) *result, detail::hl::make_tuple('z', std::string("abcdefghi"))); } } -#if 0 // TODO: Document that this does not work, and why (flattening), and how - // making a rule for the parethesized part is a fix. +#if 0 // Intentionally ill-formed. { constexpr auto parser = char_ >> merge[(string("abc") >> char_ >> char_) >> string("ghi")];