boost-spirit

Is there an alternative for boost::phoenix::at_c in combination with boost::spirit::qi::grammar

别等时光非礼了梦想. 提交于 2019-12-21 05:31:11
问题 I have created a test application to illustrate my problem. It parses a list of integers preceded by "a=" or "b=" and is separated by "\r\n". The list contains multiple occurrences of those fields in any order. #include <string> #include <vector> #include <iostream> #include <boost/spirit/include/qi.hpp> #include <boost/spirit/include/phoenix.hpp> #include <boost/fusion/include/adapt_struct.hpp> typedef std::vector<unsigned int> uint_vector_t; std::ostream& operator<<(std::ostream& out, const

Why does boost::spirit::qi::parse() not set this boost::variant's value?

↘锁芯ラ 提交于 2019-12-21 04:59:13
问题 When trying to parse text into a boost::variant, the variant's value does not get changed. The parsers by themselves appear to work fine, so my assumption is that I'm doing something wrong with the variant code. I'm using boost 1.46.1 and the following code compiles in Visual Studio 2008. 1st Update hkaiser noted that the rule and grammar template arguments must not be Variant but Variant() . This got a bit "further" as I now have a compilation error in boost_1_46_1\boost\variant\variant.hpp

boost::spirit::qi and out-of-sequence variables

一个人想着一个人 提交于 2019-12-21 04:42:12
问题 I'm writing a lexigraphical analyser. It takes an English string, and converts it into a set of latitude/longitude co-ordinates. It's a bit like Google Earth. Anyway, I've written my symbol tables and grammar, and it's happily parsing formatted data. struct LatLongDegrees { std::string dirLat_; double degLat_; std::string dirLong_; double degLong_; } For example: {"North", 23.59, "East", -30.82} Here is my grammar: basic =(latitude >> ' ' >> double_ >> ' ' >> longitude >> ' ' >> double_);

Using std::array as Attribute for boost::spirit::x3

江枫思渺然 提交于 2019-12-21 04:40:25
问题 I'm trying to parse a list of numbers into a fixed sized std::array container using boost::spirit's newest release x3 (as included in boost 1.54). Since std::array has the necessary functions, it is detected as an Container, but it is lacking the insert function which makes it incompatible. Here is a short example of what I am trying to accomplish: #include <boost/spirit/home/x3.hpp> #include <array> #include <iostream> #include <string> namespace x3 = boost::spirit::x3; namespace ascii =

Boost Spirit Qi Custom Syntesized Attribute (Set a specific member of a struct attribute via a semantic action)

白昼怎懂夜的黑 提交于 2019-12-21 01:45:26
问题 Suppose I have a structure that I want to parse into with Spirit Qi, that is defined as such: struct data_ { bool export; std::wstring name; data_() : export(false) {} }; Also, suppose the struct has been adapted to fusion like this: BOOST_FUSION_ADAPT_STRUCT( data_, (bool, export) (std::wstring, name) ) And the associated rule is: qi::rule<Iterator, data_(), skipper<Iterator> > rule_data; rule_data = -lexeme["SpecialText" >> !(alnum | '_')] [ boost::phoenix::at_c<0> = true ] // If this

How to reduce output size of template-heavy C++ code?

岁酱吖の 提交于 2019-12-20 10:47:10
问题 I have a huge problem. I have a common library, that is used all across my project. This library intensively uses boost.spirit and boost.fusion . Unfortunately, the library is approx. 700Mb in size. All the boost.spirit -heavy code is used and it works well. What steps can be done to reduce its output size? Is there is a tool that can help to determine what template instantiations waste most of the space? At first, I decided to move all spirit-aware code to cpp files. Second, I will try

Parsing a grammar with Boost Spirit

一笑奈何 提交于 2019-12-20 10:42:12
问题 I am trying to parse a C-function like tree expressions like the following (using the Spirit Parser Framework): F( A() , B( GREAT( SOME , NOT ) ) , C( YES ) ) For this I am trying to use the three rules on the following grammar: template< typename Iterator , typename ExpressionAST > struct InputGrammar : qi::grammar<Iterator, ExpressionAST(), space_type> { InputGrammar() : InputGrammar::base_type( ) { tag = ( qi::char_("a-zA-Z_") >> *qi::char_("a-zA-Z_0-9") )[ push_back( at_c<0>(qi::_val) ,

Several matches in a one pass parser?

你说的曾经没有我的故事 提交于 2019-12-20 05:01:51
问题 I am trying (yet) to populate several vectors with data parsed from a log. The key is do it as fast and efficient as possible, so I would like to collect all the data in only one pass (not "or" between rules). I have found the next problems: 1) Every time I use spirit and it does not work as expected I find myself totally loss and trying test and error for two hours. Is there any debug directive that gives some hint about what has gone wrong? 2) Is it valid the way I use phoenix construct? I

Boost.Spirit X3 parser “no type named type in(…)”

不问归期 提交于 2019-12-20 04:54:10
问题 I was toying with Boost.Spirit X3 calculator example when I encountered an error I couldn't get my head around. I minimized the program to reduce complexity still throwing the same error. Say I want to parse an input as a list of statements (strings) followed by a delimiter (';'). This is my structure: namespace client { namespace ast { struct program { std::list<std::string> stmts; }; }} BOOST_FUSION_ADAPT_STRUCT(client::ast::program, (std::list<std::string>, stmts) ) The grammar is as

Boost C++ - Searching Spirit symbol table

假装没事ソ 提交于 2019-12-20 04:14:03
问题 In Boost Spirit if I have a symbol table struct Foo : boost::spirit::qi::symbols<char, MyEnums::FruitType> { Foo(const std::string& name = std::string("FooTable") : boost::spirit::qi::symbols<char, MyEnums::FruitType>(name) { add("apple", MyEnums::Apple) ("orange", MyEnums::Orange) ("peach", MyEnums::Peach); } } Later on in my code, if I have the data type how can I get the symbol? For example: Foo fruitSymbolTable; MyEnums::FruitType fruit = MyEnums::Apple; std::string fruitTypeString = ????