boost-spirit

build error with boost spirit grammar (boost 1.43 and g++ 4.4.1) part III

你说的曾经没有我的故事 提交于 2019-12-10 10:14:08
问题 Ok i am trying to build a grammar and currently it looks like this: #ifndef _INPUTGRAMMAR_H #define _INPUTGRAMMAR_H #include <boost/config/warning_disable.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 <boost/spirit/include/phoenix_stl.hpp> #include <boost/fusion/include/adapt_struct.hpp> #include <boost/variant/recursive_variant.hpp>

Can I use BOOST_FUSION_ADAPT_STRUCT with inherited stuff?

痴心易碎 提交于 2019-12-10 06:26:59
问题 Assume I have struct cat { int tail; int head; }; struct bird { int wing; int bursa; }; If I do this... struct wat : public cat, public bird { }; BOOST_FUSION_ADAPT_STRUCT(cat,tail,head) BOOST_FUSION_ADAPT_STRUCT(bird, wing, bursa) BOOST_FUSION_ADAPT_STRUCT(wat, wat::cat, wat::bird) ... I cannot get a build, but if I explicit refer to the inherited objects like what's below, it's perfectly valid. #include <boost/spirit/include/qi.hpp> #include <boost/fusion/include/adapt_struct.hpp> namespace

Operator precedence in boost::spirit?

↘锁芯ラ 提交于 2019-12-10 03:19:21
问题 I made some tests using the spirit mini_c sample. Unfortunately it does not keep the operator precedence as expected: int main() { return 3 > 10 || 3 > 1; } evaluates to 0. return (3 > 10) || (3 > 1); returns 1 I tried to move the definition of "||" and "&&" to the very top in the constructor of template <typename Iterator> expression<Iterator>::expression( but that does not change anything. How can that be fixed. I am using boost 1.3.38. 回答1: Confirmed, that's a bug in the mini_c example

Parsing nested key value pairs in Boost Spirit

 ̄綄美尐妖づ 提交于 2019-12-09 13:01:57
问题 I am having trouble writing what I think should be a simple parser using Boost::Spirit. (I'm using Spirit instead of just using string functions as this is partly a learning exercise for me). Data The data to parse takes the form of key value pairs, where a value can itself be a key value pair. Keys are alphanumeric (with underscores and no digit as first character); values are alphanumeric plus .-_ - the values can be dates in the format DD-MMM-YYYY e.g. 01-Jan-2015 and floating point

Boost spirit parse rule is not applied

帅比萌擦擦* 提交于 2019-12-09 03:23:37
问题 i can´t see my error here .. this rule parse some stuff ok but the last two samples not. Could somebody please give me a hint .. Goal is a parser than can identify member property access and member function calls. Also chained in some way a() a(para) x.a() x.a(para) x.a(para).g(para).j() x.y x.y.z x.y.z() <---fail y.z.z(para) <--- fail lvalue = iter_pos >> name[_val = _1] >> *(lit('(') > paralistopt > lit(')') >> iter_pos)[_val = construct<common_node>(type_cmd_fnc_call, LOCATION_NODE_ITER(

Are recursive boost-spirit grammars allowed?

浪子不回头ぞ 提交于 2019-12-09 03:13:58
问题 I am about to write a parser for a mathematica-like language and have found out, that it would be nice to sometimes invoke my spirit grammar for subparts of the expression to parse. i.e. If I am about to parse a+b*c+d it would be handy to call parse() on the 'b*c' part while querying the '+' sign. Is this possible to do while using the same instance of my grammar? (The grammar parameter would be '*this') Though I am not yet fully convinced whether this is the best way to accomplish this

Eleminating left recursion in parser rule of spirit x3

梦想与她 提交于 2019-12-09 02:38:27
问题 I am currently stuck with a rule I am trying to parse using boost spirit x3. Here is te EBNF(using the % operator from spirit for lists) for what I am trying to parse: type ::= class_type | lambda_type lambda_type ::= more_arg_lambda | one_arg_lambda more_arg_lambda ::= "(", type%",", ")", "=>", type one_arg_lambda ::= type, "=>", type <- here is the left recursion class_type ::= identifier%"::", ["<", type%",", ">"] usng boost spirit x3, I am trying to parse into the following struct/variant

Boost Karma generator for composition of classes

≡放荡痞女 提交于 2019-12-09 01:55:58
问题 I've the following class diagram: There's some unused class like BinaryOperator , but my real code needs them so I want to keep them also in the example. I want to use boost::karma in order to obtain a JSON representation of this. The JSON should be like the following one: { "name": "Plus", "type": "Function", "arguments": [ { "name": "IntegerValue", "type": "Value", "value": "4" }, { "name": "Plus", "type": "Function", "arguments": [ { "name": "IntegerValue", "type": "Value", "value": "5" },

boost::spirit::hold_any memory corruption

徘徊边缘 提交于 2019-12-09 01:18:43
问题 I have a large code base that can use boost::any or boost::spirit::hold_any (depending on a macro definition). hold_any seems to be compatible with boost::any (e.g. How to print boost::any to a stream? or Type erasure - Part IV) and faster (Why you shouldn’t use boost::any) but I'm experiencing several segmentation fault errors using hold_any (Boost v1.55 / 1.54 / 1.53). This is a minimal working example that exhibits the same problem as the original code: #include <iostream> #include <string

Adapt class containing a string member as synthesized attribute

寵の児 提交于 2019-12-08 19:21:12
问题 I’m trying to parse a character string into an attribute of a custom type symbol , which contains a std::string member. I thought I could use BOOST_FUSION_ADAPT_STRUCT here but that doesn’t work. If I declare the rule as rule<It, std::string(), space_type> it works. If I define it as rule<It, symbol(), space_type> it fails with the error “no type name value_type in symbol ”. I think Spirit is trying to append the value character-for-character to the attribute, which fails as expected. But isn