Boost.Phoenix is a C++ library to enable function programming in C++.
Questions tagged [boost-phoenix]
159 questions
2
votes
1 answer
Converting a Boost Spirit Lex semantic action to Phoenix - How to access _val?
I wrote a semantic action for my Boost Spirit Lexer to convert escape sequences in strings to what they stand for. It works perfectly and I want to convert it to a Boost Phoenix expression, but can't get that one to compile.
Here is what works:
//…

Felix Dombek
- 13,664
- 17
- 79
- 131
2
votes
1 answer
qi::rule with inherited attribute as inherited attribute
Let's say we have a rule1
qi::rule rule1 = qi::int_[qi::_val=qi::_1];
And we decide getting an int as attribute is not enough, we also want to get the raw data (boost::iterator_range). We may have a lot of rules with…

wanghan02
- 1,227
- 7
- 14
2
votes
1 answer
string to Boolean expression is not working c++
I have a following code to evaluate a Boolean string based on an string input.
The code supposed to work like this:
Boolean string: "((0|1)&3);"
Sting input: "101"
how's it working? each character in the input string is supposed to be…

H'H
- 1,638
- 1
- 15
- 39
2
votes
1 answer
boost spirit and phoenix parsing into a std::string
How do I parse into a std::string with boost spirit and phoenix?
For example, below I successfully parse 1234 into an int, but when I try to parse into a string the parse fails. If I replace qi::alnum with +qi::alnum then the parse succeeds but the…

JDiMatteo
- 12,022
- 5
- 54
- 65
2
votes
0 answers
Can Boost Proto adapt structures to a getter setter type API
This seems like a common problem. I've got two massive sets of code that need to be glued together: one that uses simple structs to hold data, the other has APIs that only expose getter/setter methods.
Is it possible to use Boost.Proto to define a…

Grisby_2133
- 487
- 2
- 11
2
votes
2 answers
Boost Phoenix: Binding to reference members of structures?
I would like to use Boost Phoenix to generate a lambda function for use in a std::find_if operation on a structure that contains reference-type members. A contrived example is as follows:
struct MyStruct
{
MyStruct() : x(0) {}
int& x;
…

Chris Kline
- 2,249
- 26
- 32
2
votes
1 answer
using boost::lambda or boost::phoenix with std::find_if
I have a class like this
class Foo {
public:
int GetID() const { return m_id; }
private:
int m_id;
};
I want to use find_if on a vector full of Foo objects, like this:
std::find_if(foos.begin(), foos.end(), ???.GetID() ==…

gartenriese
- 4,131
- 6
- 36
- 60
2
votes
1 answer
Parsing with Boost Spirit, getting extra items
This is long with a lot of code, so I hope Stack Overflow can cope with it. :P
I'm trying to write an SVG parser with Boost Spirit. I have a grammar that populates a vector with "Contours," which are vectors of "BezierPoints," which may represent…

AJM
- 655
- 1
- 9
- 19
2
votes
1 answer
Boost spirit: Invalidate parser from member function
this article (boost spirit semantic action parameters) explains how to invalidate a match from a plain function with the signature
void f(int attribute, const boost::fusion::unused_type& it, bool& mFlag)
I would like to invalidate a match from a…

ChristophK
- 733
- 7
- 20
2
votes
1 answer
Defining a symbol which may be part of a literal function in boost spirit
I am trying to read a mathematical function which depends on the symbol t with boost::spirit.
In the example below, I'm trying evaluate the function "tan(t)" in t=1.2.
Instead of having
Exit: 1, value = 2.5721
I get
Exit: 1, value = 1.2
I…

srossi
- 122
- 1
- 6
2
votes
1 answer
Semantic action evaluated in grammar constructor (or not?)
I have been learning boost::spirit and have come across confusion that a semantic action is evaluated during grammar construction. The following code produces the output:
string=
My assumption is that this output as part of the semantic action…

Jimmy
- 6,001
- 1
- 22
- 21
2
votes
1 answer
Boost spirit using local variables
I would like to define a rule based on a previously parsed value, i. e. the input string has the following structure: D or I . I keep in a local boolean variable whether the first read character is D or I. The…

haykart
- 957
- 5
- 14
- 34
2
votes
1 answer
Boost spirit semantic action not invoked
I've been trying to parse a string with Boost Spirit like following:
integer_count int1 int2 int3 ... intN
Where N is the integer_count. For example,
5 1 2 3 4 5
The code is following:
#define BOOST_SPIRIT_USE_PHOENIX_V3
#include…

haykart
- 957
- 5
- 14
- 34
2
votes
3 answers
What's wrong with my boost phoenix lazy function?
I have the following code (using boost 1.55 on MSVC9):
struct pair_first_impl
{
template struct result { typedef typename TPair::first_type type; };
template
typename TPair::first_type const& operator() (TPair…

void.pointer
- 24,859
- 31
- 132
- 243
2
votes
6 answers
boost lambda or phoenix problem: using std::for_each to operate on each element of a container
I ran into a problem while cleaning up some old code. This is the function:
uint32_t ADT::get_connectivity_data( std::vector< std::vector > &output )
{
output.resize(chunks.size());
for(chunk_vec_t::iterator it = chunks.begin(); it…

Raindog
- 1,468
- 3
- 14
- 28