Boost logo

Boost Users :

Subject: [Boost-users] [Q] boost::spirit BOOST_FUSION_ADAPT_STRUCT error
From: V S P (toreason_at_[hidden])
Date: 2009-06-16 14:04:42


Hello, I am attempting to parse

FuncName(arg1,arg2,... argN)

with Spirit, such that args are saved in a vector
and func name is saved into a funct_nm

I am just in the beginning of this (I have not learned yet how
to construct a grammar that allows comma delimited args within braces )

But running into a compilation error

on line

    (std::string, funct_nm)

within
BOOST_FUSION_ADAPT_STRUCT

I am using mini_xml1.cpp as an example

Would like to ask for help/pointers to resolve it.
I want to mention that my project on boost 1.38 and also includes
json_spirit which uses
( I am guessing the 'classic version' of spirit).

thank you in advance,
Vlad

---------------------------------------

#include <json_spirit.h>
/* boost spirit parser specifics
   START
   */

#include <boost/config/warning_disable.hpp>
#include <boost/spirit/include/qi.hpp>
#include <boost/spirit/include/phoenix_core.hpp>
#include <boost/spirit/include/phoenix_container.hpp>
#include <boost/spirit/include/phoenix_statement.hpp>
#include <boost/spirit/include/phoenix_object.hpp>
#include <boost/spirit/include/phoenix_operator.hpp>

#include <iostream>
#include <string>
#include <complex>

/* boost spirit parser specifics end */

using namespace std;

using namespace boost::spirit;
using namespace boost::spirit::qi;
using namespace boost::spirit::ascii;
using namespace boost::spirit::arg_names;

namespace fusion = boost::fusion;
namespace phoenix = boost::phoenix;

//VP do not use this namespace,it is clashes with
//regular boost
//using namespace boost::spirit::arg_names;

/*
using phoenix::at_c;
using boost::phoenix::ref;
using boost::phoenix::push_back;
using boost::phoenix::val;
using boost::phoenix::construct;
*/

using namespace json_spirit;

struct cmdfunct_2arg;
//an argument of a function
typedef
    boost::variant<
        boost::recursive_wrapper<cmdfunct_2arg>
      , std::string
>
t_cmd_arg;
//function with name and a list of arguments
struct cmdfunct_arg
{
  std::string funct_nm;
  std::vector<t_cmd_arg> args;
};

// We need to tell fusion about cmdfunct struct
// to make it a first-class fusion citizen
//[tutorial_xml1_adapt_structures
BOOST_FUSION_ADAPT_STRUCT(
    cmdfunct_arg,
    (std::string, funct_nm)
    (std::vector<t_cmd_arg>, args)
)

-- 
  V S P
  toreason_at_[hidden]
-- 
http://www.fastmail.fm - Does exactly what it says on the tin

Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net