How to make a recursive rule in boost spirit x3 in VS2017(如何在VS2017的boost Spirit x3中制定递归规则)
问题描述
我在 boost::spirit::x3 中编写了以下递归规则,但它似乎只能在 g++/clang 中编译,而不是 VS2017 (15.5.3):
I've written the following recursive rule in boost::spirit::x3 but it only seems to compile in g++/clang, not VS2017 (15.5.3):
#include <iostream>
#include <boost/spirit/home/x3.hpp>
namespace lex3
{
namespace x3 = boost::spirit::x3;
x3::rule<struct foo_class> const foo = "foo";
x3::rule<struct bar_class> const bar = "bar";
auto bar_def = *((x3::char_ - "/*") - "*/") >> *(foo > *((x3::char_ - "/*") - "*/"));
auto foo_def = "/*" > bar > "*/";
BOOST_SPIRIT_DEFINE(foo)
BOOST_SPIRIT_DEFINE(bar)
}
int main(int argc, char** argv)
{
std::string input = "/* a /* nested */ comment */";
auto f = input.begin();
auto l = input.end();
if (parse(f, l, lex3::foo) && (f == l))
std::cout << "Parse success.
";
else
std::cout << "Parse failure (remainder: " << std::string(f, l) << ").
";
return 0;
}
Coliru 链接,g++
Coliru 链接,clang++
如何在 VS2017 中完成这项工作(如果可能)?
How do I make this work in VS2017 (if possible)?
P.S:Platform Toolset 设置为 v141,ISO 标准设置为 C++17,boost 版本为 1.66.0
P.S: Platform Toolset is set to v141, ISO standard is set to C++17, boost version is 1.66.0
P.P.S:编译错误如下
P.P.S: The compilation errors are as follows
error C2039: 'insert': is not a member of 'boost::spirit::x3::unused_type'
note: see declaration of 'boost::spirit::x3::unused_type'
error C2039: 'end': is not a member of 'boost::spirit::x3::unused_type'
note: see declaration of 'boost::spirit::x3::unused_type'
error C2039: 'begin': is not a member of 'boost::spirit::x3::unused_type'
note: see declaration of 'boost::spirit::x3::unused_type'
推荐答案
我查看了 GitHub 上的 Boost.Spirit 存储库,因为我的本地版本太旧了,并注意到你的示例可以使用最新的 develop 分支,但不是 1.66.0 版本(也在 Clang 和 GCC 上).将提交历史一分为二表明此错误已修复
I checked out the Boost.Spirit repository on GitHub because my local version was too old and noticed that your example compiles fine with the latest develop branch but not with the 1.66.0 release (also on Clang and GCC). Bisecting the commit history revealed that this bug was fixed in
ee4943d5891bdae0706fb616b908e3bf528e0dfa
您可以将此提交中的补丁应用到您的安装中,也可以等待下一个版本.
You could either apply the patch from this commit to your installation or wait for the next release.
这篇关于如何在VS2017的boost Spirit x3中制定递归规则的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:如何在VS2017的boost Spirit x3中制定递归规则
基础教程推荐
- 我有静态或动态 boost 库吗? 2021-01-01
- 如何检查GTK+3.0中的小部件类型? 2022-11-30
- 常量变量在标题中不起作用 2021-01-01
- 如何将 std::pair 的排序 std::list 转换为 std::map 2022-01-01
- 如何在 C++ 中初始化静态常量成员? 2022-01-01
- 如何通过C程序打开命令提示符Cmd 2022-12-09
- 在 C++ 中计算滚动/移动平均值 2021-01-01
- 静态库、静态链接动态库和动态链接动态库的 .lib 文件里面是什么? 2021-01-01
- 这个宏可以转换成函数吗? 2022-01-01
- C++结构和函数声明。为什么它不能编译? 2022-11-07
