boost-spirit

Boost spirit parser fails with incomplete type error

落花浮王杯 提交于 2019-12-11 13:46:26
问题 I've been trying all sorts of things but still not quite understanding why the following fails with 'incomplete type' error #define BOOST_PHOENIX_LIMIT 30 #define SPIRIT_ARGUMENTS_LIMIT 30 #include <boost/spirit/include/qi.hpp> #include <boost/spirit/include/phoenix.hpp> #include <ctime> #include <chrono> #include <string> #include <iomanip> namespace qi = boost::spirit::qi; namespace phi = boost::phoenix; using namespace std::chrono_literals; using namespace qi::labels; using It = std:

boost spirit X3 parser which produces offsets into the original string

蹲街弑〆低调 提交于 2019-12-11 13:12:24
问题 I am trying to write a boost::spirit::x3 parser which, rather than producing the sub-strings (for instance), instead produces offsets and lengths of the matches strings in the source. I have tried various combinations of on_success handlers, semantic actions, and nothing has really worked. given: ABC\n DEFG\n HI\n I'd like a parser which produced a std::vector<boost::tuple<size_t, size_t>> containing: 0,3 4,4 9,2 where clearly it gets more complicated as we match specific substrings on each

parsing into classes (not structs)

陌路散爱 提交于 2019-12-11 13:07:56
问题 below I show an edited spirits employee example which does not compile. The problem I want to solve is to parse into classes not structs. I know, it's quite the same besides public/private. But I need to have a constructor to work before storing the class/struct into vector. How do I change BOOST_FUSION_ADAPT_STRUCT? How can I get this to run? // STD HEADER #include <iostream> #include <string> #include <complex> // BOOST HEADER #include <boost/config/warning_disable.hpp> #include <boost

How do you output the original unparsed code (as a comment) from a spirit parser

懵懂的女人 提交于 2019-12-11 10:37:22
问题 Given the input string: A = 23; B = 5 , I currently get the (expected) output: Output: 0xa0000023 Output: 0xa0010005 ------------------------- I would like to see this instead: Output: 0xa0000023 // A = 23 Output: 0xa0010005 // B = 5 ------------------------- The core line of code is: statement = eps[_val = 0x50000000] >> identifier[_val += _1<<16] >> "=" >> hex[_val += (_1 & 0x0000FFFF)]; Where identifier is a qi::symbols table lookup. The rest of my code looks like this: #include <boost

Error when using boost::spirit::qi::phrase_parse() with a qi::grammar

最后都变了- 提交于 2019-12-11 09:36:09
问题 I'm doing an IRC message parser with Boost.Spirit but I'm getting a (very long) error when I try to parse an input. I've followed the "Roman Numerals" example. Also, I'm using g++4.7 with -std=c++11 . The error occurs only when I call phrase_parse() on test.cpp , not when I make an instance of message_grammar . The grammar class is: class message_grammar : qi::grammar<std::string::const_iterator, std::string()> { public: message_grammar() : base_type(m_message) { using qi::_val; using qi::_1;

Spirit Grammar parse issue

无人久伴 提交于 2019-12-11 09:15:11
问题 I have the following, class BATSTradeMsg : public BATSMessageBase { BATSTradeMsg(int timestamp, char msgtype, uint64_t orderId, char side, uint32_t shares, std::string const &symbol, uint64_t price, uint64_t execId) : BATSMessageBase(timestamp, msgtype), m_orderId(orderId), m_side(side), m_shares(shares), m_symbol(symbol), m_price(price), m_execId(execId) { } uint64_t m_orderId; // Base 36 Numeric values come over the wire in ascii char m_side; uint32_t m_shares; std::string m_symbol; uint64

Boost Spirit X3: “Attribute does not have the expected size” redux

断了今生、忘了曾经 提交于 2019-12-11 08:01:31
问题 Something seems to have changed in spirit::x3 that breaks my fancy little asdl parser. It worked just fine when I ported it over from Qi (after the initial x3 bugfixes made their way into fedora) but now fails with: /usr/include/boost/spirit/home/x3/operator/detail/sequence.hpp:143:9: error: static assertion failed: Attribute does not have the expected size. #include <boost/spirit/home/x3.hpp> #include <boost/fusion/include/adapt_struct.hpp> #include "asdl.h" typedef boost::variant<asdl::ast:

trigger warning from boost spirit parser

给你一囗甜甜゛ 提交于 2019-12-11 07:52:22
问题 How I can add warnings in boost spirit parser. Edit: ... that could report the issue with position For example if I have an integer parser: ('0' >> oct) | int_ I would like to be able to do something like this: ('0' >> oct) | "-0" --> trigger warning("negative octal values are not supported, it will be interpreted as negative decimal value and the leading 0 will be ignored") | int_ 回答1: Q. Can I create my own callback? How? A. Sure. Any way you'd normally do it in C++ (or look at Boost

Boost Spirit parsing XML like grammar

柔情痞子 提交于 2019-12-11 07:45:21
问题 I've got the following piece of code I want to modify fix, but I am totally new to boost-spirit. I know RE's but not how to exactly do them in spirit. This is the parser. Parser() : Parser::base_type(root) { braces = lit('{') >> *(iso8859_1::space) >> lit('}'); str = lexeme[lit('"') >> raw[*(~iso8859_1::char_('"'))] >> lit('"')]; tolleaf = raw[+(~iso8859_1::char_("\"{}= \t\r\n"))]; leaf = raw[+(iso8859_1::alnum | iso8859_1::char_("-._:"))]; taglist = lit('{') >> omit[*(iso8859_1::space)] >>

Use a trait for parsing a date in boost::spirit

这一生的挚爱 提交于 2019-12-11 07:31:49
问题 I have been parsing log files containing dates and storing them as strings, but that is memory consumption intensive and kind of costly due to string allocation. I was advised to use a Timestamp for storing the date and a boost spirit stream to parse it, so I tried both "boost::posix_time::ptime" and old "std::time_t + std::get_time", but they both hurts performance badly. I would like to give a try to this new method: parsing the date as plain ints and then use a trait to transform them into