boost-spirit

    2热度

    1回答

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

    -1热度

    1回答

    当文件在剩余期望值的规则中间结束时,它不会触发期望错误(当然,它确实无法解析)。 触发该行为的一个简单的例子是这样的: data_var_decls_r %= (lit("data") > lit('{')) > lit('}'); 如果输入的是唯一 data { 然后最终的期望误差预期}不会被触发。 有没有办法处理超过文件末尾的期望错误?

    1热度

    1回答

    我正在使用Spirit解析器来解析像id 1234这样的字符串。它适用于内联start = qi::lit("id") >> qi::int_;,但如果我想将它放入单独的基于qi :: grammar的结构体中,则不是。见情况1,2和3在下面的例子: #include <boost/spirit/include/qi.hpp> #include <boost/spirit/include/pho

    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; }; }}

    2热度

    2回答

    我可以从存储在的std :: string,性病::向量或std ::字符数组解析数字。 但是,当字符在std :: unique_ptr中的缓冲区中时,我无法这样做。 我可以在缓冲区拷贝到一个字符串,则提振精神,但我想避免这种拷贝 这里是我的尝试: #include<memory> #include<array> #include<iostream> #include "boost/spi

    1热度

    1回答

    我想用Boost.Spirit来解析嵌套列表的数字。这是我到目前为止有: //define a test string std::string string = "[[\t1 , 2 ], [3, 4, 65.4]]"; auto it = string.begin(); //parse the string std::vector<std::vector<double>> vector

    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