Looking at this example to implement the Spirit parser, something caught me when I tried to write something like that.
The grammar attribute template parameter ( std::map<std::string, std::string>() ) and the rule signature template parameter (for example, qi::rule<Iterator, std::string()> key, value ) contain round brackets.
namespace qi = boost::spirit::qi; template <typename Iterator> struct keys_and_values : qi::grammar<Iterator, std::map<std::string, std::string>()>
I had never seen this before, and I inadvertently missed it when I was writing my own version. This leads to the fact that my parser does not generate the correct output execution time (the output map is empty).
What is the purpose of these parentheses? I assume that this makes the attribute of this rule an object of this type.
source share