Some problems with rexpr and rexpr_full example code

Maarten Verhage <[email protected]> Fri, 14 Jun 2019 15:35:29 +0000
Newsgroups gmane.comp.parsers.spirit.general
Message-ID <DB8PR04MB66330D6B64788064C617E4AABAEE0@DB8PR04MB6633.eurprd04.prod.outlook.com>
Dear people,

Not so much activity lately on this mailing list. Are there other places on 
the internet where discussions about Spirit are taking place?

I realize I could use some help. I continued my x3 parser project where I 
left off last year. Now I realize my application involve the need for a 
recursive AST. So my objective is similar to the rexpr and rexpr_full 
example code. So I went on to see if I could compile that first and check if 
it does what I expect. I am using gcc 8.1.0 from mingw-w64 and, using this 
compiler, I build boost 1.69.0 (with spirit x3 v3.0.3).on my computer. I 
compile rexpr and rexpr_full with C++14 and C++17, but as far as I can see 
now it doesn’t make a difference.

Ok, rexpr did compile fine. And with the following input:

{
"color" = "pink"
"size" = "230 mm"
"shape" = "rect"
"position" = { "x" = "-16" "y" = "2" }
"position2" = { "x" = "-4" "y" = "5" }
}

It prints:
-------------------------
Parsing succeeded
-------------------------
{
    "color" = "pink"
    "position" = {
        "x" = "-16"
        "y" = "2"
    }
    "position2" = {
        "x" = "-4"
        "y" = "5"
    }
    "shape" = "rect"
    "size" = "230 mm"
}

Now I do believe the idea about recursion is that it shouldn’t set a limit 
on how deep you nest in the input file. So I try:

{
"color" = "pink"
"size" = "230 mm"
"position" = { "x" = "-16" "y" = "2" "nextrecursion" = { "width" = "6" 
height = "28"
}
}
}

Now I get:
-------------------------
Parsing failed
stopped at: ": {
"color" = "pink"
"size" = "2..."
-------------------------

Something goes wrong is it? Or is my input somehow bad?

In order to better understand what is going on I tried to compile the 
rexpr_full code. I think what matters most is to have the datastructure in 
the AST correct. Now the AST is defined in the ast.hpp file of the example 
code. Now I get errors such as ( I guess these are the relevant bits):

error: use of deleted function 'rexpr::ast::rexpr_value::rexpr_value(const 
rexpr::ast::rexpr_value&)'
note: 'rexpr::ast::rexpr_value::rexpr_value(const rexpr::ast::rexpr_value&)' 
is implicitly declared as deleted because 'rexpr::ast::rexpr_value' declares 
a move constructor or move assignment operator

error: use of deleted function 'constexpr std::pair<_T1, _T2>::pair(const 
std::pair<_T1, _T2>&) [with _T1 = std::__cxx11::basic_string<char>; _T2 = 
rexpr::ast::rexpr_value]'

It seems so odd because the AST part of baseline rexpr code (not 
rexpr_full), is the same. What could it be? I’ve no idea.

Further I tried to uncomment the lines of code that does the Inheriting 
Constructors from variant. Now I provide the necessary constructors myself 
just to get rid of the compile errors.

struct rexpr_value : x3::variant<
      std::string
    , x3::forward_ast<rexpr>
  >
{
  //using base_type::base_type;
  //using base_type::operator=;
  rexpr_value( const rexpr_value& other ) : base_type( other ) {}
  rexpr_value( rexpr_value&& other ) :
    base_type( std::move( other ) ) {}
  rexpr_value& operator=( rexpr_value&& rhs )
  {
    return base_type::operator=( std::move( rhs ) );
  }
  rexpr_value& operator=( std::string&& rhs )
  {
    return base_type::operator=( std::move( rhs ) );
  }
  rexpr_value& operator=( rexpr&& rhs )
  {
    return base_type::operator=( std::move( rhs ) );
  }
};

Now the compiler complaints about rexpr_value are gone but I get a whole 
bunch of errors about std::pair, like this:

error: no matching function for call to 
'std::pair<std::__cxx11::basic_string<char>, 
rexpr::ast::rexpr_value>::pair()'

/boost/utility/value_init.hpp:77:12: note:   candidate expects 4 arguments, 
0 provided

It would be nice if someone could help me with this. If you will, please 
provide some explanation. As I find it often hard get what someone means by 
very short comments.

Best regards,
Maarten Verhage