Questions tagged [boost-phoenix]

Boost.Phoenix is a C++ library to enable function programming in C++.

159 questions
3
votes
1 answer

boost::spirit semantic action: emit result

I am trying to learn boost::spirit to parse a grammar, but am having trouble understanding exactly how to use the library. Basically, if the parser hits "Test" in the input stream, I'd like to emit 5 as the return value. (Later, I'd actually like to…
namezero
  • 2,203
  • 3
  • 24
  • 37
3
votes
1 answer

Boost spirit permutation of rules

I have 2 type of expressions that I want parse and calculate the results. Artimetic expressions: +,-,*,/ and sqrt() function; Ex: "2 + 3 * sqrt(100*25)" -> should be calculated as 152 Functions: GetSubString() and ConcatenateStrings() Ex:…
kyy
  • 321
  • 3
  • 11
3
votes
1 answer

Subscript operator[] error with Boost C++ Phoenix user-defined argument

With an existing Boost Phoenix (placeholder) argument, such as _1, I can use the array/subscript operator. For example, the following excerpt will display a 1. int arr[4] = {1,2,3,4}; std::cout << _1[0](arr) << std::endl; However, if I define my…
user2023370
  • 10,488
  • 6
  • 50
  • 83
3
votes
1 answer

Cannot phoenix::bind qi::_val with boost 1.53 (regression ?)

The code below, using boost::spirit, used to work with boost 1.44 and boost 1.49: qi::string("a_token") [ boost::phoenix::bind(&node_t::some_func, *qi::_val, true) ] I updated boost to version 1.53, but now this code does not compile anymore.…
neodelphi
  • 2,706
  • 1
  • 15
  • 22
3
votes
1 answer

Evaluating result of boost::phoenix::insert

I'm having difficulties trying to evaluate the result of boost::phoenix::insert which inserts elements into a map. Similar to the regular std::map::insert the actor object returned by boost::phoenix::insert also returns a std::pair
Stacker
  • 1,080
  • 14
  • 20
3
votes
1 answer

Using boost::phoenix to adapt a BOOST_CHECK macro

During testing when using c++ 11 I have used the following construct: std::for_each( coll.begin(), coll.end(), [ &obj, expRes ]( const value_type& val ) { BOOST_CHECK_EQUAL( expRes, obj.someFunc( val ) ); } ); I am currently…
mark
  • 7,381
  • 5
  • 36
  • 61
3
votes
1 answer

Troubles with boost::phoenix::function

Using boost::phoenix::function I encountered some problems. As far as I know this lazy function requiries functor as its template parameter. I have to define a functor class/structure and then pass it as a template parameter for instantiation. But…
Oleksandr Karaberov
  • 12,573
  • 10
  • 43
  • 70
2
votes
2 answers

What's the execution sequence of phoenix::lambda function?

I'm a newbie for boost phoenix, I wrote a small piece of code but it totally confuses me about the execution sequence, you can check the code std::vector v; v.push_back(1); ph::for_each(v, ph::lambda[ph::ref(cout)<<"a", …
2
votes
2 answers

boost spirit: parameter type when using semantic actions and phoenix

I use boost spirit to parse mathematical expressions and have run into a problem that I extracted into the following code. There is a simple lexer with one token, having an attribute holding the matched string. The parser defines a single rule which…
user816098
  • 262
  • 3
  • 14
2
votes
2 answers

phoenix lambda and argument dereferencing

Can somebody show me how to implement an equivalent of the following using boost::phoenix lambda? I know I could implement it in many other ways but I'm trying to learn the Phoenix lambda expressions and so far all my attempts in this example…
GxL Dev
  • 23
  • 3
2
votes
2 answers

Using Boost.Phoenix's operator ->*

I'm playing around with Phoenix v3 trying to figure out whether we should standardize on it instead of the current mix of Bind and Lambda. From the documentation I got the impression that it should be possible to simplify some expressions. Currently…
Ben Swerts
  • 78
  • 3
2
votes
2 answers

boost.spirit "invalid static_cast" error when trying to count characters with phoenix bind

This code is not my actual code, but just illustrates the issue. I have a rule that matches 0 or more digits, and an action that is supposed to count them and return that count as the synthesized attribute. The attribute of *qi::ascii::digit should…
Brian Bi
  • 111,498
  • 10
  • 176
  • 312
2
votes
2 answers

How to use a sequence of statements in Boost.Phoenix together with std::transform?

I'd like to use Boost.Phoenix to create a lambda function that consists of a few lines of code and then "returns" a value so I can use it together with std::transform. Like this: std::transform(a.begin(), a.end(), b.begin(), ( …
AbuBakr
  • 968
  • 2
  • 11
  • 22
2
votes
1 answer

boost::spirit attribute assignment: struct is_nullary: base type fails to be a struct or class type

I have a boost::spirit parser that is supposed to simply assign a pointer to its attribute: rule var_ref = var()(_r1) [ _val = new_>>(_1) ]; where…
Victor Mataré
  • 2,446
  • 2
  • 16
  • 20
2
votes
1 answer

Boost phoenix member function operator fails to compile if function has overload

I want to use Boost phoenix member function operator for the class function that has overloads, like here. The following example fails: #include #include using namespace std; using namespace…