Question

I am porting/updating some really old code and my C++ is not very sharp (I'm mostly a C programmer). I received this error - how do I fix it and can someone explain this mess? Note line 512 is the struct definition - the first line?

In file included from src/aaa_dict_mngr.cxx:38:0:
./include/aaa_parser_avpvalue.h:512:41: error: expected template-name before '<' token
./include/aaa_parser_avpvalue.h:512:41: error: expected '{' before '<' token
./include/aaa_parser_avpvalue.h:512:41: error: expected unqualified-id before '<' token

Offending code:

struct DiamidentGrammar : public grammar<DiamidentGrammar>
{
  template <typename ScannerT>
  struct definition
  {
    definition(DiamidentGrammar const& self)  
    { 
      diameterIdentity = realm;
      realm = label >> *('.' >> label);  // No recursive rule allowed.
      label = diameterName | diameterDname;
      diameterName = alpha_p >> *(alnum_p | '-');
      diameterDname = digit_p >> +(alnum_p | '-');
    }
    rule<ScannerT> diameterIdentity, realm, label, diameterName, diameterDname;
    rule<ScannerT> const& start() const { return diameterIdentity; }
  };
};
Was it helpful?

Solution

This is just ancient Spirit code. You need to use the classic headers/namespace:

See it Live On Coliru

Oh and by all means, upgrade! Spirit V2 is years old and SpiritX3 is around the corner

#include <boost/spirit/include/classic.hpp>

using namespace boost::spirit::classic;

struct DiamidentGrammar : public grammar<DiamidentGrammar>
{
    template <typename ScannerT>
        struct definition
        {
            definition(DiamidentGrammar const& self)  
            { 
                diameterIdentity = realm;
                realm = label >> *('.' >> label);  // No recursive rule allowed.
                label = diameterName | diameterDname;
                diameterName = alpha_p >> *(alnum_p | '-');
                diameterDname = digit_p >> +(alnum_p | '-');
            }
            rule<ScannerT> diameterIdentity, realm, label, diameterName, diameterDname;
            rule<ScannerT> const& start() const { return diameterIdentity; }
        };
};

int main()
{
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top