boost-spirit

Boost.Spirit mini_xml2.cpp example could not be compiled by C++11, Boost 1.55

给你一囗甜甜゛ 提交于 2019-12-29 01:42:06
问题 c++0x compiler fails to compile boost.spirit example mini_xml2.cpp (and no errors from not c++0x compiler) $> c++ -std=c++0x mini_xml2.cpp (errors) $> c++ mini_xml2.cpp (no errors) The error log is placed here. I suspect that problem is related to nonterminal attributes (lines 159-163), but I could be wrong. c++ version (Ubuntu / Linaro 4.8.1-10ubuntu9) 4.8.1 Boost version 1.55 I've created issue at the boost tracker, but have no answer. Does anybody have the same errors? Solved : I found a

AST and operator precedence in rule definition

≡放荡痞女 提交于 2019-12-28 19:29:12
问题 Hello [¹] I have a simple parser (see below). It intends to parse conditional expressions (relational arithmetic operations and logic combinations thereof). In the example given there, it parses successfully A>5 but then stops and ignores the rest of the input, and this is consistent with my impl. How do I change the expr_ rule to make it parse the entire input? #include <cstdint> #include <boost/spirit/include/qi.hpp> #include <boost/spirit/include/phoenix.hpp> #include <boost/spirit/include

Building a Custom Expression Tree in Spirit:Qi (Without Utree or Boost::Variant)

≯℡__Kan透↙ 提交于 2019-12-28 16:02:48
问题 First of all, if it is much easier using either Boost Variant or Utree, then I will settle with them, and i will try to solve my issues with them in another topic. However, i would very much like to be able to build a tree like i have below. Background, ignore if you would like to go straight to the issue: I would like to be able to build an expression tree which parses something like "({a} == 0) && ({b} > 5)" or a standard mathmatic expression "(2 * a) + b" I will then define what a and b

Copy or reference semantics of boost::spirit's rule<>?

流过昼夜 提交于 2019-12-28 13:49:24
问题 I am trying to write a shell language parser in Boost.Spirit. However, I am unclear about some basic issues regarding semantics of rule s. Looking at the documentation, there are members r.alias() and r.copy() of rule . IIUC, these members should return a reference to the rule and a copy of the rule's contents, respectively. However, it is not clearly specified what happens when I just use the rule in a definition of another rule. From my experiments, I found mutually recursive rules can be

How can I use polymorphic attributes with boost::spirit::qi parsers?

五迷三道 提交于 2019-12-27 17:45:12
问题 I would like my boost::spirit-based parser to be able to parse a file, convert the parsed rules into different types, and emit a vector containing all of the matches it found. All of the types that are emitted as attributes should be inherited from a base type, for example: #include <boost/spirit/include/qi.hpp> #include <boost/fusion/adapt_struct.hpp> #include <boost/shared_ptr.hpp> #include <boost/foreach.hpp> struct CommandBase { virtual void commandAction() { std::cout << "This is a base

Parse tab delimited file with Boost.Spirit where entries may contain whitespace in

我与影子孤独终老i 提交于 2019-12-25 04:31:06
问题 I want to parse a tab delimited file using Boost.Spirit (Qi). My file looks something like this: John Doe\tAge 23\tMember Jane Doe\tAge 25\tMember ... Is it possible to parse this with a skip parser ? The problem I have right now is, that boost::spirit::ascii:space also skips the whitespace within the name of the person. How would the phrase_parse(...) call look like? I am also using the Boost.Fusion tuples for convient storing of the results in a struct: struct Person { string name; int age;

No viable conversion error from boost::spirit::unused_type

两盒软妹~` 提交于 2019-12-25 00:37:56
问题 I'm getting this error: include/boost/spirit/home/phoenix/bind/detail/member_function_ptr.hpp:109:35: No viable conversion from 'boost::spirit::unused_type' to 'const std::__1::basic_string' #define BOOST_SPIRIT_USE_PHOENIX_V3 #define spirit boost::spirit #define phoenix boost::phoenix component_ = lit( '-' ) >> string_[ phoenix::bind( &SemanticActionsType::new_component_name, &actions_, spirit::qi::_1 )] Here is the SemanticActions class: template< typename IterType > class SemanticActions {

Parsing a tokenized free form grammar with Boost.Spirit

柔情痞子 提交于 2019-12-24 16:46:30
问题 I've got stuck trying to create a Boost.Spirit parser for the callgrind tool's output which is part of valgrind. Callgrind outputs a domain specific embedded programming language (DSEL) which lets you do all sorts of cool stuff like custom expressions for synthetic counters, but it's not easy to parse. I've placed some sample callgrind output at https://gist.github.com/ned14/5452719#file-sample-callgrind-output. I've placed my current best attempt at a Boost.Spirit lexer and parser at https:/

Output of a boost::variant type using boost::spirit::karma

左心房为你撑大大i 提交于 2019-12-24 13:19:46
问题 I'm trying to output parameters, they can either be a single parameter or a vector of parameters. The following code does not what I'd like it to do: #include <iostream> #include <string> #include <boost/variant.hpp> #include <boost/spirit/include/karma.hpp> namespace karma = boost::spirit::karma; typedef std::vector<int> ParameterList; typedef boost::variant<int, ParameterList> Parameter; main() { using karma::int_; using karma::eol; using karma::lit; std::string generated; std::back_insert

Read 2D array in C++ using boost::spirit

醉酒当歌 提交于 2019-12-24 13:00:53
问题 I would like to read a simple 2D int array (whitespace separated) as here: qi::phrase_parse(b, e, +qi::int_ % qi::eol, qi::space - qi::eol, vectors) There are two differences, though: I want to put it into a 1D std::vector, line by line, without separating If two lines have a different amount of ints, this shall be recognized as a parsing error. Is it possible to do this as a one liner, e.g. without writing my own parser? Just as simple as in the link mentioned above? 回答1: Assuming you meant