$include_dir="/home/hyper-archives/boost-users/include"; include("$include_dir/msg-header.inc") ?>
Subject: Re: [Boost-users] [Q] boost::spirit BOOST_FUSION_ADAPT_STRUCT error
From: V S P (toreason_at_[hidden])
Date: 2009-06-16 14:51:21
I found a couple of typos with my code, but still not working
First problem was
that I need to specify a fully qualified name in the 'struct' name as
the first argument
Second, I added the two include files
#include <boost/fusion/adapted/struct/adapt_struct.hpp>
#include <boost/fusion/include/adapt_struct.hpp>
Third, I just removed the 'second' data member of the struct just to see
if changes
anything... But I still get an error on last
(std::string, funct_nm)
struct cmdfunct_arg;
//an argument of a function
typedef
    boost::variant<
        boost::recursive_wrapper<cmdfunct_arg>
      , 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;
};
BOOST_FUSION_ADAPT_STRUCT(
setrak::pplg::cmdfunct_arg,
(std::string, funct_nm)
)
I also noticed an inconsistency in docs, and may be I am just not using
the right way but
in 
http://www.boost.org/doc/libs/1_39_0/libs/fusion/doc/html/fusion/adapted/adapt_struct.html
there is no comma after the first argument, yet when I remove it -- I
get an error
(on the other hand in the example there is a comma)
Should I move to 1.39 (I am on 1.38 now)
On Tue, 16 Jun 2009 14:04 -0400, "V S P" <toreason_at_[hidden]> wrote:
> 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
> 
-- 
  V S P
  toreason_at_[hidden]
-- 
http://www.fastmail.fm - Access all of your messages and folders
                          wherever you are