boost-spirit-x3

    1热度

    1回答

    我想解析一个文件,并将数据复制到一个类对象内的向量。我采取了员工示例,并将其修改为我正在尝试执行的操作。正在解析的文件看起来像这样(但多行)... 1 0.2 0.3 0.4 我添加了一个向量为结构的员工和我在phrase_parse线越来越断言失败。 static assertion failed: Attribute does not have the expected size. st

    2热度

    1回答

    我正在考虑自永远以来(自从Uni上的编译器类以来,我主要已经忘记了)编写基本上我的第一个解析器。 由于我使用C++,我正在考虑使用Boost Spirit。然后我注意到有“常规”2.5.2,并且有一些名为Spirit X3的代码有一些神奇的子集。 我也注意到Boost Spirit X3在两年前已经发布/讨论/预发布,但Boost Spirit的正式版本是2.5.2。最后,我读: Where is

    1热度

    1回答

    我试图使用Boost 1.65.1中的Spirit X3来创建解析器。我减少了我的问题,下面的小例子用更简单的结构: #include <boost/config/warning_disable.hpp> #include <boost/spirit/home/x3.hpp> #include <boost/fusion/include/adapt_struct.hpp> #include

    2热度

    2回答

    我最终得到了这些移动错误很多,我不太清楚为什么除了解析字符串的方式之外。删除与“虚拟”相关的所有内容,并返回错误。 有人提到使用attr_gen(在文档中找不到),通过这样做,我可以通过这些“traits :: move_to”编译错误,但解析器仍然失败。我已经标记了我为了编译而添加的行,但不要认为“< ---”是必要的。 #define BOOST_SPIRIT_X3_DEBUG #incl

    2热度

    1回答

    假设我们想要解析像这样的递归块。当“skip_comments_tag”以块为前缀时,我们会以递归方式跳过此块中的所有注释(/*...*/)。 { {} { skip_comments_tag{ {} /*comments*/ { /*comments*/ } } } } 很容易想出一个递归解析器,如Colir

    1热度

    1回答

    有时我在解析器之间有紧密的耦合/循环依赖关系。我可能有这样的事情: parser.hpp #pragma once namespace parser { using a_type = x3::rule<class a_class>; a_type const a = "a"; using b_type = x3::rule<class b_class>;

    1热度

    1回答

    我正在努力提升精神x3,并且对一点不清楚。我有一个具有非常不同和重复行的文件。前几行可能是注释。接下来的1000行可能是坐标,下一千行可能是int的列表等等... 我的问题是如何识别行并知道该行使用哪个解析器。例如,这里有两个解析器函数.... template <typename Iterator> bool parse_ints(Iterator first, Iterator last,

    2热度

    1回答

    我基于我的应用程序关闭这个例子,并得到完全相同的结果。出于某种原因,输入字符串的内容全部被解析为融合结构'comments',并且没有任何东西被解析为融合结构'numbers'。所以不知道我在哪里错了。 namespace client { namespace ast { struct number { int num1; int num2;

    2热度

    1回答

    从升压精神X3教程: 首先,让我们创建一个代表雇员一个结构: namespace client { namespace ast { struct employee { int age; std::string surname; std::string forename; double salary; }; }}

    3热度

    1回答

    我尝试将float或int的简单列表解析为变体的向量。我在Windows上使用boost 1.64(mingw 64bit)。 下面是一个小例子: #include <boost/spirit/home/x3/support/ast/variant.hpp> #include <boost/fusion/adapted/struct.hpp> #include <boost/spirit/ho