boost-spirit

Compile error due boost spirit placeholder limit not more than 10

孤街醉人 提交于 2019-12-11 06:59:24
问题 I'm getting a "qi::_10 is not a member of qi " error when compiling grammar for qi. Is there a way to increase the maximum allowed? 回答1: Off-hand: Avoid the code smell of large numbers of function arguments . That said, Before: Live On Coliru #define SPIRIT_ARGUMENTS_LIMIT 10 #include <boost/spirit/include/qi.hpp> int main() { auto& _10 = boost::spirit::labels::_10; } After: Live On Coliru #define SPIRIT_ARGUMENTS_LIMIT 11 #include <boost/spirit/include/qi.hpp> int main() { auto& _10 = boost:

Unhelpful compiler errors in x3 grammar

筅森魡賤 提交于 2019-12-11 05:08:14
问题 The following Spirit x3 grammar for a simple robot command language generates compiler errors in Windows Visual Studio 17. For this project, I am required to compile with the warning level to 4 (/W4) and treat warnings as errors (/WX). Warning C4127 conditional expression is constant SpiritTest e:\data\boost\boost_1_65_1\boost\spirit\home\x3\char\detail\cast_char.hpp 29 Error C2039 'insert': is not a member of 'boost::spirit::x3::unused_type' SpiritTest e:\data\boost\boost_1_65_1\boost\spirit

Using spirit to parse into classes?

馋奶兔 提交于 2019-12-11 04:03:58
问题 Below is the employee.cpp source file from the boost spirit documentation. It's 'struct employee' followed by a macro that tells fusion about 'struct employee', followed by the employee parser. I am trying to adapt this for my purposes, but rather than use 'struct employee', I have a number of classes that I'd like to use in place of 'struct employee'. I was looking at trying to replace 'struct employee' for classes, but I don't see the macros to do that in fusion? And the reason I don't want

Boost Spirit Qi Attribute Propagation

本小妞迷上赌 提交于 2019-12-11 04:03:53
问题 I have an issue with a Boost Spirit Qi grammar that is emitting an undesired type, resulting in this compilation error: error C2664: 'std::basic_string<_Elem,_Traits,_Ax> &std::basic_string<_Elem,_Traits,_Ax>::insert(unsigned int,const std::basic_string<_Elem,_Traits,_Ax> &)' : cannot convert parameter 1 from 'std::_String_iterator<_Elem,_Traits,_Alloc>' to 'unsigned int' Here is the grammar that is causing the issue: qi::rule<Iterator, qi::unused_type()> gr_newline; // asmast::label() just

What is the correct way to use boost::qi::rule with BOOST_FUSION_ADAPT_STRUCT?

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-11 03:46:00
问题 I am attempting to get a qi::rule<> to emit a struct with BOOST_FUSION_ADAPT_STRUCT based on the boost employee example. I have the following struct and its associated fusion macro: struct LineOnCommand { int lineNum; std::vector<char> humpType; }; BOOST_FUSION_ADAPT_STRUCT( LineOnCommand, (int, lineNum) (std::vector<char>, humpType) ) The associated parsing rules are: qi::rule<Iterator, std::vector<char> ascii::space_type> humpIdentifer = qi::lit("BH") | qi::lit("DH"); qi::rule<Iterator,

How to access data of nested objects in boost::spirit::karma?

回眸只為那壹抹淺笑 提交于 2019-12-11 03:45:30
问题 In an ItemList containing lists of Item objects, how do I access the Item objects in the generator? The following sample code compiles on VC9 (with boost include and link directories set apropriately). I don't know how to set up list_generator::item . #include <boost/config/warning_disable.hpp> #include <boost/foreach.hpp> #include <boost/assign/list_of.hpp> #include <boost/range/adaptors.hpp> #include <boost/range/algorithm.hpp> #include <boost/spirit/include/qi.hpp> #include <boost/spirit

boost::spirit parser returns empty vector

痴心易碎 提交于 2019-12-11 03:29:36
问题 Why the parser using the rules below returns an empty container? There're 3 rules. One is for parsing a string of characters except double quote, the second parses a pair (e.g. "col1" : 2) and the third parses the vector of such pairs. The ouput of the program below in MSVS2012 is parse success result: '' : 0 result: '' : 0 result: '' : 0 . namespace parsers { spirit::qi::rule< iterator, column_name_t() > quoted_string = spirit::qi::lexeme["\"" >> +~spirit::qi::char_("\"") >> "\""]; spirit:

Boost spirit qi integer with default value on literal

冷暖自知 提交于 2019-12-11 03:06:43
问题 I want to parse numbers with default values on specific literals. For example if the program receives "nan" or "n/a" the integer default value will be -1. // Example program #include <iostream> #include <string> #include <boost/fusion/adapted.hpp> #include <boost/fusion/include/adapted.hpp> #include <boost/spirit/include/qi.hpp> #include <boost/spirit/include/phoenix_core.hpp> #include <boost/spirit/include/phoenix_operator.hpp> #include <boost/spirit/include/phoenix_fusion.hpp> #include

X3, what is attr_gen?

我与影子孤独终老i 提交于 2019-12-11 03:01:45
问题 I end up getting these move errors a lot and am not quite sure why other than having something to do with the way I'm parsing strings. Remove everything having to do with 'dummy' and the errors come back. Someone mentioned using attr_gen (couldn't find this in the docs) and by doing so, I can get past these "traits::move_to" compile errors, but the parser still fails. I've marked the lines that I've added to get it to compile, but don't think are necessary with "<---". #define BOOST_SPIRIT_X3

Flipping the order of subrules inside a rule in a boost::spirit grammar results in segfault

冷暖自知 提交于 2019-12-11 02:58:17
问题 Warning; while I tried to shorten the code down, to a minimum. I still had to include quite a bit, to ensure that the required information was present. This code, compiles files, and runs resulting in a syntax error; name = simple_name [ qi::_val = qi::_1 ] | qualified_name [ qi::_val = qi::_1 ] ; While this; name = qualified_name [ qi::_val = qi::_1 ] | simple_name [ qi::_val = qi::_1 ] ; Results in a SIGSEGV , Segmentation fault; boost::detail::function::function_obj_invoker4<boost::spirit: