Get rid of leaf_data_binary_data

I added a new parser "adapter" that creates ad-hoc x3::rule parser which
can coerce attributes to whatever I want. Before this, I had to
explicitly create x3::rule myself. This will shave off some lines and
will hopefully be useful in more places (my next target is
leaf_data_identityRef_data).

Change-Id: I6af83433df47e3158bd328db111fd1059cce3d45
diff --git a/src/common_parsers.hpp b/src/common_parsers.hpp
index eac8e61..8da90a6 100644
--- a/src/common_parsers.hpp
+++ b/src/common_parsers.hpp
@@ -34,6 +34,22 @@
 auto const space_separator_def =
     x3::omit[x3::no_skip[x3::space]];
 
+template <typename CoerceTo>
+struct as_type {
+    template <typename...> struct Tag{};
+
+    template <typename ParserType>
+    auto operator[](ParserType p) const {
+        return x3::rule<Tag<CoerceTo, ParserType>, CoerceTo> {"as"} = x3::as_parser(p);
+    }
+};
+
+// The `as` parser creates an ad-hoc x3::rule with the attribute specified with `CoerceTo`.
+// Example usage: as<std::string>[someParser]
+// someParser will have its attribute coerced to std::string
+// https://github.com/boostorg/spirit/issues/530#issuecomment-584836532
+template <typename CoerceTo> const as_type<CoerceTo> as{};
+
 BOOST_SPIRIT_DEFINE(node_identifier)
 BOOST_SPIRIT_DEFINE(module)
 BOOST_SPIRIT_DEFINE(module_identifier)