提升灵气:从语义动作改变多个目标场
boost spirit qi: change multiple target fields from semantic action
我有以下输入123, test, test456
,我想运行一个 boost::qi 语法,以便输出是对的向量,其中每个匹配都与某种信息相关联,例如: [(123, Int), (test, String), (test456, String)]
这是我到目前为止一直在尝试的:
enum class MatchType
{
Int,
String
}
在格拉默
match = qi::alpha >> *(qi::alnum)[/*How to set the tuple to (matched value _1, string)*/]
| +qi::digit[ /*How to set the tuple to (matched value _1, Int)*/ ]
/* Tied but doesn't compile:
+qi::digit[
[]()
{
phoenix::at_c<0>(_val) = _1;
phoenix::at_c<1>(_val) = MatchType::Int;
}]
*/
qi::rule<Iterator, std::vector<std::pair<MatchType, std::string>>> match;
实现这一目标的最佳方法是什么?
我只是建议
#include <boost/fusion/adapted/std_pair.hpp>
及以后
my_pair = (qi::attr(MatchType::Int) >> qi::int_)
| (qi::attr(MatchType::String) >> +qi::alnum);
相关文章:
- 如何(从固定列表中)选择一个数字序列,该序列将与目标数字相加
- 变量没有改变?通过向量的函数调用
- C++A*算法并不总是在路径中具有目标节点
- 基于树莓pi的tensorflow lite量化ssd目标检测
- 为测试目标创建具有不同源文件夹的文件
- 使用源向量作为目标
- 如何改变c++应用程序的视觉效果
- C++在不同线程中改变向量
- 是否可以用C++/WinRT将windows 10.0.14393作为目标
- 如何访问和改变存储在矢量C++中的对象
- 在 CMake 中为每个目标设置编译器/链接器标志
- qmake:检测目标位宽(32 位或 64 位)
- 在C++行尾写一个分号或多个分号是否会改变任何内容
- 如何在 CMake 中对目标依赖项进行分组?
- 我的目标是编写一个程序来计算和存储字符串在字符数组中出现的位置
- 如何为包含头文件的目标编写生成文件?
- 为什么字符串的 move() 会改变内存中底层数据的位置?
- 线性优化目标函数中的绝对值
- 提升灵气:从语义动作改变多个目标场
- 改变目标函数的外观,但不能完全改变