boost-spirit-qi

boost spirit reporting semantic error

心已入冬 提交于 2019-12-30 11:31:33
问题 I am playing with boost.spirit library and I cannot manage to report a simple error message from my semantic action. // supported parameter types (int or quoted strings) parameter = bsqi::int_ | bsqi::lexeme[L'"' > *(bsqi_coding::char_ - L'"') > L'"']; parameter.name("parameter"); // comma separator list of parameters (or no parameters) parameters = -(parameter % L','); parameters.name("parameters"); // action with parameters action = (Actions > L'(' > parameters > L')')[bsqi::_pass = boost:

boost spirit reporting semantic error

China☆狼群 提交于 2019-12-30 11:31:30
问题 I am playing with boost.spirit library and I cannot manage to report a simple error message from my semantic action. // supported parameter types (int or quoted strings) parameter = bsqi::int_ | bsqi::lexeme[L'"' > *(bsqi_coding::char_ - L'"') > L'"']; parameter.name("parameter"); // comma separator list of parameters (or no parameters) parameters = -(parameter % L','); parameters.name("parameters"); // action with parameters action = (Actions > L'(' > parameters > L')')[bsqi::_pass = boost:

cannot get boost::spirit parser&lexer working for token types other than std::string or int or double

倾然丶 夕夏残阳落幕 提交于 2019-12-30 11:03:10
问题 This does not compile (code below). There was another question here with the same error. But I don't understand the answer. I already tried inserting qi::eps in places -- but without success. I also tried already adding meta functions (boost::spirit::raits::is_container) for the types used -- but this also does not help. I also tried using the same variant containing all types I need to use everywhere. Same problem. Has anybody gotten this working for a lexer returning something else than

cannot get boost::spirit parser&lexer working for token types other than std::string or int or double

↘锁芯ラ 提交于 2019-12-30 11:02:36
问题 This does not compile (code below). There was another question here with the same error. But I don't understand the answer. I already tried inserting qi::eps in places -- but without success. I also tried already adding meta functions (boost::spirit::raits::is_container) for the types used -- but this also does not help. I also tried using the same variant containing all types I need to use everywhere. Same problem. Has anybody gotten this working for a lexer returning something else than

How to verify algebraic statements using boost::spirit?

…衆ロ難τιáo~ 提交于 2019-12-30 10:12:14
问题 I'm trying to extend the calculator example so that instead of parsing and evaluating an algebraic expression, the parser will determine if an algebraic statement is true or not. By this I mean statements like 1 + 5 * 5 - 10 = 19 - 3 (desired parser result is true ) and 3 - 1 = 9 (desired parser result is false ). I've got to admit I'm new to boost::spirit and it's all kind of overwhelming at the moment. However, I do feel I understand the calculator example good enough to at least make some

boost::spirit parsing into a fusion adapted structure optional but exclusive

烂漫一生 提交于 2019-12-30 10:06:23
问题 If there's a structure: struct record { std::string type; std::string delimiter; uint32_t length; std::string name; record() { type = ""; delimiter = ""; length = 0; name = ""; } }; Which is adapted using boost::fusion, and the below grammar: struct record_parser : qi::grammar<Iterator, record(), ascii::space_type> { record_parser() : record_parser::base_type(start) { using qi::lit; using qi::uint_; using qi::lexeme; using ascii::char_; using ascii::blank; using ascii::string; using qi::attr;

Filter the synthesized attribute through a std::map in a boost spirit semantic action

醉酒当歌 提交于 2019-12-29 09:22:06
问题 I have a case where I'd like to filter the value that comes up as a synthesized attribute inside of a rule through a std::map. The map is pre-generated and will not change during the parsing. The nature of the map and the real parser means that the lookup should never fail (although the actual number of elements may be quite large) The usual approach perfectly suited to this problem (use a symbol table) isn't appropriate for the real case. In the real problem, the lookup is conditional based

Filter the synthesized attribute through a std::map in a boost spirit semantic action

我们两清 提交于 2019-12-29 09:22:01
问题 I have a case where I'd like to filter the value that comes up as a synthesized attribute inside of a rule through a std::map. The map is pre-generated and will not change during the parsing. The nature of the map and the real parser means that the lookup should never fail (although the actual number of elements may be quite large) The usual approach perfectly suited to this problem (use a symbol table) isn't appropriate for the real case. In the real problem, the lookup is conditional based

Boost.Spirit SQL grammar/lexer failure

ぐ巨炮叔叔 提交于 2019-12-29 08:03:36
问题 I have two problems with the following SQL grammar: #define BOOST_SPIRIT_QI_DEBUG #include <boost/spirit/include/qi.hpp> #include <boost/spirit/include/lex_lexertl.hpp> #include <boost/spirit/include/phoenix.hpp> #include <boost/spirit/include/karma.hpp> #include <boost/fusion/include/adapt_struct.hpp> #include <boost/fusion/include/std_pair.hpp> #include <boost/algorithm/string.hpp> #include <boost/shared_ptr.hpp> #include <boost/make_shared.hpp> #include <boost/lexical_cast.hpp> #include

Boost.Spirit SQL grammar/lexer failure

元气小坏坏 提交于 2019-12-29 08:03:11
问题 I have two problems with the following SQL grammar: #define BOOST_SPIRIT_QI_DEBUG #include <boost/spirit/include/qi.hpp> #include <boost/spirit/include/lex_lexertl.hpp> #include <boost/spirit/include/phoenix.hpp> #include <boost/spirit/include/karma.hpp> #include <boost/fusion/include/adapt_struct.hpp> #include <boost/fusion/include/std_pair.hpp> #include <boost/algorithm/string.hpp> #include <boost/shared_ptr.hpp> #include <boost/make_shared.hpp> #include <boost/lexical_cast.hpp> #include