C++ Boost Spirit X3:错误:没有名为';尺寸';在'';

C++ Boost Spirit X3:错误:没有名为';尺寸';在'';,c++,boost,struct,C++,Boost,Struct,我试图解析成一个包含std::string和std::vector的结构,但在使用Boost Spirit的%-运算符时,我总是会出错 我已经尝试将列表解析分离为一个单独的规则()和来自的as-指令 如果没有谓词参数规则,它就可以完美地工作 错误相当大,有些片段: [...] error: static assertion failed: The parser expects tuple-like attribute type [...] error: no type named 'size'

我试图解析成一个包含std::string和std::vector的结构,但在使用Boost Spirit的%-运算符时,我总是会出错

我已经尝试将列表解析分离为一个单独的规则()和来自的
as
-指令

如果没有
谓词参数
规则,它就可以完美地工作

错误相当大,有些片段:

[...] error: static assertion failed: The parser expects tuple-like attribute type
[...] error: no type named 'size' in 'struct dec::predicate_query'
[...] error: no type named 'type' in 'struct boost::fusion::extension::size_impl<boost::fusion::non_fusion_tag>::apply<dec::predicate_query>'
[...] error: non-constant condition for static assertion
[…]错误:静态断言失败:解析器需要类似元组的属性类型
[…]错误:“struct dec::predicate\u query”中没有名为“size”的类型
[…]错误:“struct boost::fusion::extension::size\u impl::apply”中没有名为“type”的类型
[…]错误:静态断言的非常量条件
decfile_parser.cpp

namespace x3 = boost::spirit::x3;

x3::rule<class predicate_name, std::string> predicate_name = "predicate_name";
x3::rule<class predicate_query, dec::predicate_query> predicate_query = "predicate_query";
x3::rule<class predicate_arguments, std::vector<dec::predicate_argument_type>> predicate_arguments = "predicate_arguments";
x3::rule<class predicate_argument, dec::predicate_argument_type> predicate_argument = "predicate_argument";

auto const predicate_query_def = predicate_name >> '(' >> predicate_arguments  >> ')';
auto const predicate_arguments_def = predicate_argument % ',';
auto const predicate_name_def = *x3::char_("a-zA-Z");
// TODO: sortname
auto const predicate_argument_def = *x3::char_("a-zA-Z") | predicate_query;

decfile_parser::decfile_parser() {

}

void decfile_parser::parse_file(std::string filename) {
    int value = 0;
    std::string str("HoldsAt(Pos(), test)");
    std::string::iterator strbegin = str.begin();

    x3::phrase_parse(strbegin,
                     str.end(),
                     predicate_query,
                     x3::ascii::blank);

}

BOOST_SPIRIT_DEFINE(predicate_query, predicate_name, predicate_argument, predicate_arguments);

int main() {
    decfile_parser par;
    par.parse_file("test.e2");
}
namespace x3=boost::spirit::x3;
x3::rule predicate\u name=“predicate\u name”;
x3::rule predicate\u query=“predicate\u query”;
x3::规则谓词参数=“谓词参数”;
x3::规则谓词参数=“谓词参数”;
auto const predicate_query_def=predicate_name>>'('>>predicate_arguments>>>);
自动常量谓词_参数_def=谓词_参数%',';
自动常量谓词_name_def=*x3::char_Z(“a-zA-Z”);
//TODO:sortname
auto const predicate_argument_def=*x3::char_uz(“a-zA-Z”)| predicate_query;
decfile_解析器::decfile_解析器(){
}
void decfile_解析器::parse_文件(std::字符串文件名){
int值=0;
字符串str(“HoldsAt(Pos(),test)”;
std::string::迭代器strbegin=str.begin();
短语解析(strbegin,
str.end(),
谓词查询,
x3::ascii::空白);
}
BOOST\u-SPIRIT\u-DEFINE(谓词查询、谓词名称、谓词参数、谓词参数);
int main(){
解密分析器PAR;
PAR.PARSEYFILE(“测试E2”);
}
decfile_parser.h

#include <boost/spirit/home/x3.hpp>
#include <boost/fusion/adapted/std_tuple.hpp>
#include <boost/fusion/include/adapt_struct.hpp>
#include <boost/spirit/include/phoenix.hpp>

#include <string>

#include "ast.h"

class decfile_parser {
public:
    decfile_parser();
    ~decfile_parser() = default;

    void parse_file(std::string filename);
};
#包括
#包括
#包括
#包括
#包括
#包括“ast.h”
类decfile\u解析器{
公众:
decfile_解析器();
~decfile_parser()=默认值;
void parse_文件(std::string文件名);
};
ast.h

名称空间dec{
名称空间x3=boost::spirit::x3;
结构谓词查询;
typedefx3::变量谓词\参数\类型;
结构谓词查询{
std::字符串名;
向量参数;
};
}
ast_.h

#include <boost/fusion/include/adapt_struct.hpp>
#include "ast.h"

BOOST_FUSION_ADAPT_STRUCT(
        dec::predicate_query,
        (std::string, name),
        (std::vector<dec::predicate_argument_type>, arguments)
        )
#包括
#包括“ast.h”
增强融合适应结构(
dec::谓词查询,
(std::string,name),
(标准::向量,参数)
)

编辑1:可能是因为他想将
name
arguments
解析到一个容器中。

我忘了将
ast\u adapted.h
导入我的
decfile\u parser.h
。错误是因为结构当然不适合融合序列

#include <boost/fusion/include/adapt_struct.hpp>
#include "ast.h"

BOOST_FUSION_ADAPT_STRUCT(
        dec::predicate_query,
        (std::string, name),
        (std::vector<dec::predicate_argument_type>, arguments)
        )