Boost logo

Boost Users :

Subject: [Boost-users] [spirit-karma] skipping tokens while generation
From: Ovanes Markarian (om_boost_at_[hidden])
Date: 2011-11-30 14:37:32


Hello *,

I am somehow stuck when trying to skip tokens to be generated. My
configuration is boost 1.47 and visual c++ 2010. I also do not understand
how some mechanics are intended to work.

Example 1:
Lets say I have a string: ///

And I want my generator to generate: / from it or if the string is not
'///' leave it as it is. So I wrote:

  using namespace std;
  string result;
  typedef std::back_insert_iterator<string> oiter_t;
  oiter_t out(result);

  string input = "///";

  namespace k=karma;

  k::generate(out, &k::string("///") << "/" | k::string, input);

And that works fine.

Example 2:
Now I would like to the slash to be a dynamic part, so I go ahead and
define a rule:

  string root("/");
  k::rule<oiter_t, std::string()> repeating_slash = +k::lit(root);
  k::generate(out, &repeating_slash << "/" | k::string, input);

Here the generate never returns (infinite loop???)....

Next test:

Example 3:
use in the rule instead of k::lit a k::string. This does not compile.

Why? I was going through the docs over and over again but somehow I miss
smth.

Many thanks,
Ovanes



Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net