Questions tagged [boost-phoenix]

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

159 questions
4
votes
1 answer

Obtaining the types of local variables in Boost Phoenix

How can I obtain the types of the local variables used within a scoped Boost Phoenix statement? Using Phoenix and Proto I can extract numerous aspects of a Phoenix expression. For example, the following code exposes the arity (3); tag type…
user2023370
  • 10,488
  • 6
  • 50
  • 83
4
votes
2 answers

Calling a function from within a boost::phoenix::lambda

I am trying to use boost::phoenix to emulate C++ lambda expressions on an older compiler that lacks C++11 support, and I am unable to call a simple function from within a lambda expression. C++11 Version: [](unsigned a) { foo( a ); }( 12678u ); //…
mark
  • 7,381
  • 5
  • 36
  • 61
4
votes
1 answer

boost::spirit: multiple statements in semantic action block

boost::phoenix defines statement blocks using the operator "," (see boost phoenix block statements). I'm trying to use this construct in the semantic action part of a boost::spirit rule. However, it looks like only the last statement in the…
mvc
  • 653
  • 1
  • 5
  • 9
3
votes
1 answer

Boost Phoenix (or Boost Lambda) - taking a pointer lazily

Is there a way of taking a pointer of a lazy phoenix value / ref ? If so how ?
Hassan Syed
  • 20,075
  • 11
  • 87
  • 171
3
votes
1 answer

Using lambdas or external functions as spirit.qi semantic actions

Iʼm playing with creating Boost.Spirit.Qi-based parsing. Having an example like calc_utree, I'm trying to extend what to use as semantic action. It's trivial to reuse the same approach with an alone assignment as semantic action, for example …
Netch
  • 4,171
  • 1
  • 19
  • 31
3
votes
1 answer

Boost Spirit tokenise expression into vector

I am trying to parse an expression which can also contain identifiers and push each element into an std::vector , and I have come up with the following grammar: #include #include…
3
votes
1 answer

Parsing simple csv table with boost-spirit

I was trying to use boost-spirit to parse a fairly simple cvs file format. My csv file looks like this: Test.txt 2 5. 3. 2. 6. 3. 6. The first integer represents the number of lines to read and each line consists of exactly three double…
Aleph0
  • 5,816
  • 4
  • 29
  • 80
3
votes
0 answers

Too many constructions with phoenix::new_ in boost spirit grammar

I'm quite new to the spirit framework, and I'd like to ask you a question concerning my program. My idea is to implement the C- programming language grammar into spirit (link is here http://marvin.cs.uidaho.edu/Teaching/CS445/c-Grammar.pdf). I'm…
bob
  • 31
  • 3
3
votes
1 answer

how to access elements of a tuple in a semantic action

My grammar has various entries which start with a generic name. After I determined the type I would like to use the expectation operator in order to create parsing errors. rule1=name >> (type1 > something); rule2=name >> (type2 > something); I…
user6520006
3
votes
1 answer

Boost Spirit rule with custom attribute parsing

I am writing a Boost Spirit grammar to parse text into a vector of these structs: struct Pair { double a; double b; }; BOOST_FUSION_ADAPT_STRUCT( Pair, (double, a) (double, a) ) This grammar has a rule like…
AJM
  • 655
  • 1
  • 9
  • 19
3
votes
2 answers

C++ boost::lambda::ret equivalent in phoenix

Boost lambda allows to overwrite deduced return type using ret template. I have tried searching for equivalent in phoenix but could not find one. Is there an equivalent in phoenix? I know how to make my own Replacement but I would rather not. …
Anycorn
  • 50,217
  • 42
  • 167
  • 261
3
votes
1 answer

boost spirit karma generation from a collection of struct using a member function

I am trying to use karma to generate a comma separated list of strings, from a vector of structs that contain a member function that provides the string. While I can generate single string output using phoenix::bind, and I can generate a csv output…
nostep
  • 35
  • 6
3
votes
1 answer

How to implement a lambda function for a sort algorithm involving object members, indirection, and casting?

I'm working on some code and I have a section where I do a one off sort function. To implement it I decided it was easiest to overload the operator< function. What I would prefer to do is move the implementation of the sort closer to the actual call…
ApockofFork
  • 487
  • 1
  • 4
  • 10
3
votes
1 answer

BOOST_PHOENIX_ADAPT_FUNCTION(...) with templated function on templated container

I need a lazy evaluating version of std::pair.first. My approach is to use boost::phoenix, define a templated function and use the BOOST_PHOENIX_ADAPT_FUNCTION makro as folows: template T1 first_impl(std::pair p){ …
Dirk
  • 155
  • 1
  • 1
  • 8
3
votes
1 answer

Updating synthesized attribute value from semantic action

I want to understand what exactly happens under the hood of boost::spirit::qi. Suppose we have simple parser that parses and calculates expressions consisting of numbers and add/subtract operations: int main() { std::string INPUT_DATA = "12e-1 +…
n0rd
  • 11,850
  • 5
  • 35
  • 56
1 2
3
10 11