- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在用 Boost.Spirit
做一个 IRC 消息解析器,但是当我尝试解析一个输入时我遇到了一个(很长的)错误。我遵循了“Roman Numerals”示例。此外,我将 g++4.7
与 -std=c++11
一起使用。只有当我在 test.cpp
上调用 phrase_parse()
时才会发生错误,而不是在我创建 message_grammar
的实例时发生。
语法类是:
class message_grammar : qi::grammar<std::string::const_iterator, std::string()>
{
public:
message_grammar() : base_type(m_message)
{
using qi::_val;
using qi::_1;
using boost::spirit::ascii::char_;
using qi::lit;
qi::rule<std::string::const_iterator, std::string()> alpha, graph, number, special, user,
nick, chn, channel;
alpha = qi::as_string[qi::alpha];
graph = qi::as_string[qi::graph];
number = qi::as_string[char_('0', '9')];
chn = qi::as_string[(char_('#') | char_('$'))];
special = qi::as_string[
char_('-') | char_('[') | char_(']') | char_('\\')
| char_('`') | char_('^') | char_('{') | char_('}')
];
user = (
graph [_val = std::string("USER%% ") + _1]
>> *graph[_val += _1]
);
nick = (
alpha[_val = std::string("NICK%% ") + _1]
>>
*(
alpha
| number
| special
)[_val += _1]
);
channel = (
chn [_val = std::string("CHAN%% ") + _1]
>> +(alpha | number | special) [_val += _1]
);
m_message = (
nick [_val = _1]
>> alpha [_val += std::string(" ") + _1]
>> channel [_val += std::string(" ") + _1]
>> user [_val += std::string(" ") + _1]
);
}
qi::rule<std::string::const_iterator, std::string()> m_message;
};
测试函数是:
int main()
{
string str, parsed_str;
getline(cin, str);
irc::message_grammar grammar;
auto it = str.begin();
auto end = str.end();
bool ok = qi::phrase_parse(it, end,
grammar
, qi::space, parsed_str);
if (ok && it == end) {
cout << "OK" << endl;
cout << parsed_str << endl;
}
else {
cout << "NO " << ok << endl;
}
}
错误信息:
murilo@mac:cleverbot$ g++-mp-4.7 -std=c++11 test.cpp -Wall
In file included from /opt/local/include/boost/proto/core.hpp:23:0,
from /opt/local/include/boost/proto/proto.hpp:12,
from /opt/local/include/boost/spirit/home/support/meta_compiler.hpp:19,
from /opt/local/include/boost/spirit/home/qi/meta_compiler.hpp:14,
from /opt/local/include/boost/spirit/home/qi/action/action.hpp:14,
from /opt/local/include/boost/spirit/home/qi/action.hpp:14,
from /opt/local/include/boost/spirit/home/qi.hpp:14,
from /opt/local/include/boost/spirit/include/qi.hpp:16,
from ircparser.h:6,
from test.cpp:1:
/opt/local/include/boost/proto/domain.hpp: In instantiation of 'struct boost::proto::domainns_::domain<>::as_expr<irc::message_grammar>':
/opt/local/include/boost/proto/traits.hpp:266:71: required from 'struct boost::proto::result_of::as_expr<irc::message_grammar, boost::proto::domainns_::default_domain>'
/opt/local/include/boost/spirit/home/support/meta_compiler.hpp:221:16: required from 'struct boost::spirit::traits::matches<boost::spirit::qi::domain, irc::message_grammar>'
/opt/local/include/boost/spirit/home/qi/parse.hpp:155:9: required from 'bool boost::spirit::qi::phrase_parse(Iterator&, Iterator, const Expr&, const Skipper&, boost::spirit::qi::skip_flag, Attr&) [with Iterator = __gnu_cxx::__normal_iterator<char*, std::basic_string<char> >; Expr = irc::message_grammar; Skipper = boost::proto::exprns_::expr<boost::proto::tagns_::tag::terminal, boost::proto::argsns_::term<boost::spirit::tag::char_code<boost::spirit::tag::space, boost::spirit::char_encoding::standard> >, 0l>; Attr = std::basic_string<char>]'
/opt/local/include/boost/spirit/home/qi/parse.hpp:197:86: required from 'bool boost::spirit::qi::phrase_parse(Iterator&, Iterator, const Expr&, const Skipper&, Attr&) [with Iterator = __gnu_cxx::__normal_iterator<char*, std::basic_string<char> >; Expr = irc::message_grammar; Skipper = boost::proto::exprns_::expr<boost::proto::tagns_::tag::terminal, boost::proto::argsns_::term<boost::spirit::tag::char_code<boost::spirit::tag::space, boost::spirit::char_encoding::standard> >, 0l>; Attr = std::basic_string<char>]'
test.cpp:20:25: required from here
/opt/local/include/boost/proto/extends.hpp:551:13: error: 'typedef void boost::proto::exprns_::extends<boost::proto::exprns_::expr<boost::proto::tagns_::tag::terminal, boost::proto::argsns_::term<boost::spirit::qi::reference<const boost::spirit::qi::rule<__gnu_cxx::__normal_iterator<const char*, std::basic_string<char> >, std::basic_string<char>(), boost::spirit::unused_type, boost::spirit::unused_type, boost::spirit::unused_type> > >, 0l>, boost::spirit::qi::grammar<__gnu_cxx::__normal_iterator<const char*, std::basic_string<char> >, std::basic_string<char>()>, boost::proto::domainns_::default_domain, 0l>::proto_is_expr_' is inaccessible
In file included from /opt/local/include/boost/proto/traits.hpp:32:0,
from /opt/local/include/boost/proto/expr.hpp:27,
from /opt/local/include/boost/proto/core.hpp:17,
from /opt/local/include/boost/proto/proto.hpp:12,
from /opt/local/include/boost/spirit/home/support/meta_compiler.hpp:19,
from /opt/local/include/boost/spirit/home/qi/meta_compiler.hpp:14,
from /opt/local/include/boost/spirit/home/qi/action/action.hpp:14,
from /opt/local/include/boost/spirit/home/qi/action.hpp:14,
from /opt/local/include/boost/spirit/home/qi.hpp:14,
from /opt/local/include/boost/spirit/include/qi.hpp:16,
from ircparser.h:6,
from test.cpp:1:
/opt/local/include/boost/proto/domain.hpp:141:13: error: within this context
In file included from /opt/local/include/boost/proto/core.hpp:23:0,
from /opt/local/include/boost/proto/proto.hpp:12,
from /opt/local/include/boost/spirit/home/support/meta_compiler.hpp:19,
from /opt/local/include/boost/spirit/home/qi/meta_compiler.hpp:14,
from /opt/local/include/boost/spirit/home/qi/action/action.hpp:14,
from /opt/local/include/boost/spirit/home/qi/action.hpp:14,
from /opt/local/include/boost/spirit/home/qi.hpp:14,
from /opt/local/include/boost/spirit/include/qi.hpp:16,
from ircparser.h:6,
from test.cpp:1:
/opt/local/include/boost/proto/extends.hpp:551:13: error: 'typedef void boost::proto::exprns_::extends<boost::proto::exprns_::expr<boost::proto::tagns_::tag::terminal, boost::proto::argsns_::term<boost::spirit::qi::reference<const boost::spirit::qi::rule<__gnu_cxx::__normal_iterator<const char*, std::basic_string<char> >, std::basic_string<char>(), boost::spirit::unused_type, boost::spirit::unused_type, boost::spirit::unused_type> > >, 0l>, boost::spirit::qi::grammar<__gnu_cxx::__normal_iterator<const char*, std::basic_string<char> >, std::basic_string<char>()>, boost::proto::domainns_::default_domain, 0l>::proto_is_expr_' is inaccessible
In file included from /opt/local/include/boost/proto/traits.hpp:32:0,
from /opt/local/include/boost/proto/expr.hpp:27,
from /opt/local/include/boost/proto/core.hpp:17,
from /opt/local/include/boost/proto/proto.hpp:12,
from /opt/local/include/boost/spirit/home/support/meta_compiler.hpp:19,
from /opt/local/include/boost/spirit/home/qi/meta_compiler.hpp:14,
from /opt/local/include/boost/spirit/home/qi/action/action.hpp:14,
from /opt/local/include/boost/spirit/home/qi/action.hpp:14,
from /opt/local/include/boost/spirit/home/qi.hpp:14,
from /opt/local/include/boost/spirit/include/qi.hpp:16,
from ircparser.h:6,
from test.cpp:1:
/opt/local/include/boost/proto/domain.hpp:141:13: error: within this context
In file included from /opt/local/include/boost/proto/core.hpp:23:0,
from /opt/local/include/boost/proto/proto.hpp:12,
from /opt/local/include/boost/spirit/home/support/meta_compiler.hpp:19,
from /opt/local/include/boost/spirit/home/qi/meta_compiler.hpp:14,
from /opt/local/include/boost/spirit/home/qi/action/action.hpp:14,
from /opt/local/include/boost/spirit/home/qi/action.hpp:14,
from /opt/local/include/boost/spirit/home/qi.hpp:14,
from /opt/local/include/boost/spirit/include/qi.hpp:16,
from ircparser.h:6,
from test.cpp:1:
/opt/local/include/boost/proto/extends.hpp:551:13: error: 'typedef void boost::proto::exprns_::extends<boost::proto::exprns_::expr<boost::proto::tagns_::tag::terminal, boost::proto::argsns_::term<boost::spirit::qi::reference<const boost::spirit::qi::rule<__gnu_cxx::__normal_iterator<const char*, std::basic_string<char> >, std::basic_string<char>(), boost::spirit::unused_type, boost::spirit::unused_type, boost::spirit::unused_type> > >, 0l>, boost::spirit::qi::grammar<__gnu_cxx::__normal_iterator<const char*, std::basic_string<char> >, std::basic_string<char>()>, boost::proto::domainns_::default_domain, 0l>::proto_is_expr_' is inaccessible
In file included from /opt/local/include/boost/proto/traits.hpp:32:0,
from /opt/local/include/boost/proto/expr.hpp:27,
from /opt/local/include/boost/proto/core.hpp:17,
from /opt/local/include/boost/proto/proto.hpp:12,
from /opt/local/include/boost/spirit/home/support/meta_compiler.hpp:19,
from /opt/local/include/boost/spirit/home/qi/meta_compiler.hpp:14,
from /opt/local/include/boost/spirit/home/qi/action/action.hpp:14,
from /opt/local/include/boost/spirit/home/qi/action.hpp:14,
from /opt/local/include/boost/spirit/home/qi.hpp:14,
from /opt/local/include/boost/spirit/include/qi.hpp:16,
from ircparser.h:6,
from test.cpp:1:
/opt/local/include/boost/proto/domain.hpp:142:17: error: within this context
In file included from /opt/local/include/boost/proto/core.hpp:23:0,
from /opt/local/include/boost/proto/proto.hpp:12,
from /opt/local/include/boost/spirit/home/support/meta_compiler.hpp:19,
from /opt/local/include/boost/spirit/home/qi/meta_compiler.hpp:14,
from /opt/local/include/boost/spirit/home/qi/action/action.hpp:14,
from /opt/local/include/boost/spirit/home/qi/action.hpp:14,
from /opt/local/include/boost/spirit/home/qi.hpp:14,
from /opt/local/include/boost/spirit/include/qi.hpp:16,
from ircparser.h:6,
from test.cpp:1:
/opt/local/include/boost/proto/extends.hpp:551:13: error: 'typedef void boost::proto::exprns_::extends<boost::proto::exprns_::expr<boost::proto::tagns_::tag::terminal, boost::proto::argsns_::term<boost::spirit::qi::reference<const boost::spirit::qi::rule<__gnu_cxx::__normal_iterator<const char*, std::basic_string<char> >, std::basic_string<char>(), boost::spirit::unused_type, boost::spirit::unused_type, boost::spirit::unused_type> > >, 0l>, boost::spirit::qi::grammar<__gnu_cxx::__normal_iterator<const char*, std::basic_string<char> >, std::basic_string<char>()>, boost::proto::domainns_::default_domain, 0l>::proto_is_expr_' is inaccessible
In file included from /opt/local/include/boost/proto/traits.hpp:32:0,
from /opt/local/include/boost/proto/expr.hpp:27,
from /opt/local/include/boost/proto/core.hpp:17,
from /opt/local/include/boost/proto/proto.hpp:12,
from /opt/local/include/boost/spirit/home/support/meta_compiler.hpp:19,
from /opt/local/include/boost/spirit/home/qi/meta_compiler.hpp:14,
from /opt/local/include/boost/spirit/home/qi/action/action.hpp:14,
from /opt/local/include/boost/spirit/home/qi/action.hpp:14,
from /opt/local/include/boost/spirit/home/qi.hpp:14,
from /opt/local/include/boost/spirit/include/qi.hpp:16,
from ircparser.h:6,
from test.cpp:1:
/opt/local/include/boost/proto/domain.hpp:143:56: error: within this context
In file included from /opt/local/include/boost/proto/core.hpp:23:0,
from /opt/local/include/boost/proto/proto.hpp:12,
from /opt/local/include/boost/spirit/home/support/meta_compiler.hpp:19,
from /opt/local/include/boost/spirit/home/qi/meta_compiler.hpp:14,
from /opt/local/include/boost/spirit/home/qi/action/action.hpp:14,
from /opt/local/include/boost/spirit/home/qi/action.hpp:14,
from /opt/local/include/boost/spirit/home/qi.hpp:14,
from /opt/local/include/boost/spirit/include/qi.hpp:16,
from ircparser.h:6,
from test.cpp:1:
/opt/local/include/boost/proto/extends.hpp:551:13: error: 'typedef void boost::proto::exprns_::extends<boost::proto::exprns_::expr<boost::proto::tagns_::tag::terminal, boost::proto::argsns_::term<boost::spirit::qi::reference<const boost::spirit::qi::rule<__gnu_cxx::__normal_iterator<const char*, std::basic_string<char> >, std::basic_string<char>(), boost::spirit::unused_type, boost::spirit::unused_type, boost::spirit::unused_type> > >, 0l>, boost::spirit::qi::grammar<__gnu_cxx::__normal_iterator<const char*, std::basic_string<char> >, std::basic_string<char>()>, boost::proto::domainns_::default_domain, 0l>::proto_is_expr_' is inaccessible
In file included from /opt/local/include/boost/proto/traits.hpp:32:0,
from /opt/local/include/boost/proto/expr.hpp:27,
from /opt/local/include/boost/proto/core.hpp:17,
from /opt/local/include/boost/proto/proto.hpp:12,
from /opt/local/include/boost/spirit/home/support/meta_compiler.hpp:19,
from /opt/local/include/boost/spirit/home/qi/meta_compiler.hpp:14,
from /opt/local/include/boost/spirit/home/qi/action/action.hpp:14,
from /opt/local/include/boost/spirit/home/qi/action.hpp:14,
from /opt/local/include/boost/spirit/home/qi.hpp:14,
from /opt/local/include/boost/spirit/include/qi.hpp:16,
from ircparser.h:6,
from test.cpp:1:
/opt/local/include/boost/proto/domain.hpp:146:29: error: within this context
In file included from /opt/local/include/boost/proto/core.hpp:23:0,
from /opt/local/include/boost/proto/proto.hpp:12,
from /opt/local/include/boost/spirit/home/support/meta_compiler.hpp:19,
from /opt/local/include/boost/spirit/home/qi/meta_compiler.hpp:14,
from /opt/local/include/boost/spirit/home/qi/action/action.hpp:14,
from /opt/local/include/boost/spirit/home/qi/action.hpp:14,
from /opt/local/include/boost/spirit/home/qi.hpp:14,
from /opt/local/include/boost/spirit/include/qi.hpp:16,
from ircparser.h:6,
from test.cpp:1:
/opt/local/include/boost/proto/extends.hpp:551:13: error: 'typedef void boost::proto::exprns_::extends<boost::proto::exprns_::expr<boost::proto::tagns_::tag::terminal, boost::proto::argsns_::term<boost::spirit::qi::reference<const boost::spirit::qi::rule<__gnu_cxx::__normal_iterator<const char*, std::basic_string<char> >, std::basic_string<char>(), boost::spirit::unused_type, boost::spirit::unused_type, boost::spirit::unused_type> > >, 0l>, boost::spirit::qi::grammar<__gnu_cxx::__normal_iterator<const char*, std::basic_string<char> >, std::basic_string<char>()>, boost::proto::domainns_::default_domain, 0l>::proto_is_expr_' is inaccessible
In file included from /opt/local/include/boost/proto/traits.hpp:32:0,
from /opt/local/include/boost/proto/expr.hpp:27,
from /opt/local/include/boost/proto/core.hpp:17,
from /opt/local/include/boost/proto/proto.hpp:12,
from /opt/local/include/boost/spirit/home/support/meta_compiler.hpp:19,
from /opt/local/include/boost/spirit/home/qi/meta_compiler.hpp:14,
from /opt/local/include/boost/spirit/home/qi/action/action.hpp:14,
from /opt/local/include/boost/spirit/home/qi/action.hpp:14,
from /opt/local/include/boost/spirit/home/qi.hpp:14,
from /opt/local/include/boost/spirit/include/qi.hpp:16,
from ircparser.h:6,
from test.cpp:1:
/opt/local/include/boost/proto/domain.hpp:146:29: error: within this context
In file included from /opt/local/include/boost/proto/core.hpp:23:0,
from /opt/local/include/boost/proto/proto.hpp:12,
from /opt/local/include/boost/spirit/home/support/meta_compiler.hpp:19,
from /opt/local/include/boost/spirit/home/qi/meta_compiler.hpp:14,
from /opt/local/include/boost/spirit/home/qi/action/action.hpp:14,
from /opt/local/include/boost/spirit/home/qi/action.hpp:14,
from /opt/local/include/boost/spirit/home/qi.hpp:14,
from /opt/local/include/boost/spirit/include/qi.hpp:16,
from ircparser.h:6,
from test.cpp:1:
/opt/local/include/boost/proto/extends.hpp:551:13: error: 'typedef void boost::proto::exprns_::extends<boost::proto::exprns_::expr<boost::proto::tagns_::tag::terminal, boost::proto::argsns_::term<boost::spirit::qi::reference<const boost::spirit::qi::rule<__gnu_cxx::__normal_iterator<const char*, std::basic_string<char> >, std::basic_string<char>(), boost::spirit::unused_type, boost::spirit::unused_type, boost::spirit::unused_type> > >, 0l>, boost::spirit::qi::grammar<__gnu_cxx::__normal_iterator<const char*, std::basic_string<char> >, std::basic_string<char>()>, boost::proto::domainns_::default_domain, 0l>::proto_is_expr_' is inaccessible
In file included from /opt/local/include/boost/proto/traits.hpp:32:0,
from /opt/local/include/boost/proto/expr.hpp:27,
from /opt/local/include/boost/proto/core.hpp:17,
from /opt/local/include/boost/proto/proto.hpp:12,
from /opt/local/include/boost/spirit/home/support/meta_compiler.hpp:19,
from /opt/local/include/boost/spirit/home/qi/meta_compiler.hpp:14,
from /opt/local/include/boost/spirit/home/qi/action/action.hpp:14,
from /opt/local/include/boost/spirit/home/qi/action.hpp:14,
from /opt/local/include/boost/spirit/home/qi.hpp:14,
from /opt/local/include/boost/spirit/include/qi.hpp:16,
from ircparser.h:6,
from test.cpp:1:
/opt/local/include/boost/proto/domain.hpp:146:46: error: within this context
In file included from /opt/local/include/boost/proto/core.hpp:23:0,
from /opt/local/include/boost/proto/proto.hpp:12,
from /opt/local/include/boost/spirit/home/support/meta_compiler.hpp:19,
from /opt/local/include/boost/spirit/home/qi/meta_compiler.hpp:14,
from /opt/local/include/boost/spirit/home/qi/action/action.hpp:14,
from /opt/local/include/boost/spirit/home/qi/action.hpp:14,
from /opt/local/include/boost/spirit/home/qi.hpp:14,
from /opt/local/include/boost/spirit/include/qi.hpp:16,
from ircparser.h:6,
from test.cpp:1:
/opt/local/include/boost/proto/matches.hpp: In instantiation of 'struct boost::proto::matches<irc::message_grammar, boost::spirit::meta_compiler<boost::spirit::qi::domain>::meta_grammar>':
/opt/local/include/boost/spirit/home/support/meta_compiler.hpp:221:16: required from 'struct boost::spirit::traits::matches<boost::spirit::qi::domain, irc::message_grammar>'
/opt/local/include/boost/spirit/home/qi/parse.hpp:155:9: required from 'bool boost::spirit::qi::phrase_parse(Iterator&, Iterator, const Expr&, const Skipper&, boost::spirit::qi::skip_flag, Attr&) [with Iterator = __gnu_cxx::__normal_iterator<char*, std::basic_string<char> >; Expr = irc::message_grammar; Skipper = boost::proto::exprns_::expr<boost::proto::tagns_::tag::terminal, boost::proto::argsns_::term<boost::spirit::tag::char_code<boost::spirit::tag::space, boost::spirit::char_encoding::standard> >, 0l>; Attr = std::basic_string<char>]'
/opt/local/include/boost/spirit/home/qi/parse.hpp:197:86: required from 'bool boost::spirit::qi::phrase_parse(Iterator&, Iterator, const Expr&, const Skipper&, Attr&) [with Iterator = __gnu_cxx::__normal_iterator<char*, std::basic_string<char> >; Expr = irc::message_grammar; Skipper = boost::proto::exprns_::expr<boost::proto::tagns_::tag::terminal, boost::proto::argsns_::term<boost::spirit::tag::char_code<boost::spirit::tag::space, boost::spirit::char_encoding::standard> >, 0l>; Attr = std::basic_string<char>]'
test.cpp:20:25: required from here
/opt/local/include/boost/proto/extends.hpp:551:13: error: 'typedef struct boost::spirit::qi::grammar<__gnu_cxx::__normal_iterator<const char*, std::basic_string<char> >, std::basic_string<char>()> boost::proto::exprns_::extends<boost::proto::exprns_::expr<boost::proto::tagns_::tag::terminal, boost::proto::argsns_::term<boost::spirit::qi::reference<const boost::spirit::qi::rule<__gnu_cxx::__normal_iterator<const char*, std::basic_string<char> >, std::basic_string<char>(), boost::spirit::unused_type, boost::spirit::unused_type, boost::spirit::unused_type> > >, 0l>, boost::spirit::qi::grammar<__gnu_cxx::__normal_iterator<const char*, std::basic_string<char> >, std::basic_string<char>()>, boost::proto::domainns_::default_domain, 0l>::proto_derived_expr' is inaccessible
最佳答案
您应该将 message_grammar
声明为结构而不是类。此外,您可以从 qi::grammar
公开派生您的类:
class message_grammar : public qi::grammar<std::string::const_iterator, std::string()>
{
}
您还可以找到这个 article有用。
关于c++ - 使用带有 qi::grammar 的 boost::spirit::qi::phrase_parse() 时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11126930/
我正在将一个手写解析器迁移到 Boost.Spirit (2.5.4)。第一印象是积极的,但由于我使用的是 C++17,X3 似乎是一个非常有吸引力的选择。 幸运的是,有很多关于 X3 的可用资源:
是否可以使用 boost::spirit::qi 来解析以下内容? A_B --> (A, B) A_B_C --> (A_B, C) A_B_C_D --> (A_B_
我正在尝试解析一种类似 lisp 的语言,它具有一些通用功能的语法糖。例如,plus 函数可以写成 (+ 1 2) 或 1 + 2。我认为在尝试解释语言之前消除句法糖会显着促进解释过程,因为那样的话,
我正在尝试解析一种类似 lisp 的语言,它具有一些通用功能的语法糖。例如,plus 函数可以写成 (+ 1 2) 或 1 + 2。我认为在尝试解释语言之前消除句法糖会显着促进解释过程,因为那样的话,
我想使用解析后的值作为循环解析器的输入。 语法定义了一个 header ,它指定了以下字符串的(可变)大小。例如,假设以下字符串是某个解析器的输入。 12\r\nTest Payload 解析器应提取
我正在编写 DSL 并使用 Boost Spirit 词法分析器来标记我的输入。在我的语法中,我想要一个类似于此的规则(其中 tok 是词法分析器): header_block = tok.n
我有以下精神语法。我正在尝试在 struct myresult 中创建 AST 节点的向量使用标准 push_back(at_c(qi::_val), qi::_1)但出现编译错误(见下文)。 typ
需要为 std::pair 对象提供类型为 boost::variant 的对象的值。您将如何使用其他资源来实现这个想法?下面还有其他方法吗? struct aggr_pair_visitor
我有一个词法分析器,基于该词法分析器,我现在想创建一个使用该词法分析器生成的标记的语法。我尝试改编我发现的一些示例,现在我有一些可以编译和工作的东西至少有一点,但我的一个应该失败的测试却没有。现在我想
当我使用此 qi 语法从 Lex 接受标记时: pair %= token(ID_MARKER) >> ':' >> atom >> ',' >> atom
如何解析可能包含 double 或 int 的字符串,具体取决于是否设置了点。例如。 6.0是double类型,6是int类型。规则是 rule,skipper> r = qi::double_|qi
请帮助我诊断以下错误。我有一个简单的语法: struct json_start_elem_grammar_object : qi::grammar { json_start_elem_gramma
作为使用 Boost.Spirit 的更大语法的第一阶段,我尝试解析“true”和“false”以生成相应的 bool 值,true 和 false. 我正在使用 Spirit.Lex 对输入进行标记
我正在尝试解析一个也可以包含标识符的表达式并将每个元素推送到 std::vector 中,我想出了以下语法: #include #include #include #include name
我正在为 if 函数实现生产规则: qi::rule f_if; f_if = qi::ascii::string("if") >> qi::char_('(')
我编写了这段代码示例并期望它打印OPERATION( OPERATOR(aaa) ID(bbb) ) 但我只得到OPERATION ( OPERATOR(aaa) )反而。 result2 和 it1
我的数据定义为: std::string data("START34*23*43**"); 我的语法: "START" >> boost::spirit::hex % '*' 题: 如何解析有两颗星的
我编写了这段代码示例并期望它打印OPERATION( OPERATOR(aaa) ID(bbb) ) 但我只得到OPERATION ( OPERATOR(aaa) )反而。 result2 和 it1
我需要解析一个键值对,其中键本身是示例中的固定字符串lke'cmd'。不幸的是qi::lit没有综合属性,并且qi::char_没有解析固定的字符串。 以下代码无法编译。执行后,我需要那个result
我正在尝试编写精神规则,但我无法弄清楚这个新规则的属性是什么。 以下代码按我预期的方式工作。 #include #include #include #include #include nam
我是一名优秀的程序员,十分优秀!