Hello,
I am using boost 1.58 and I see the following.
template <class Iterator>
struct test_generator:
karma::grammar {
test_generator(): test_generator::base_type(start) {
using karma::ascii::string;
using boost::spirit::ascii::char_;
using karma::lit;
using karma::buffer;
using karma::debug;
value2 = +(~char_(' '));
value1 = value2;
value = lit('=') << value1;
start = buffer[-value];
}
karma::rule start;
karma::rule value;
karma::rule value1;
karma::rule value2;
};
template <class Iterator>
struct test_generator2:
karma::grammar {
test_generator2(): test_generator2::base_type(start) {
using karma::ascii::string;
using boost::spirit::ascii::char_;
using karma::lit;
using karma::buffer;
using karma::debug;
value2 = +(~char_(' '));
value1 = value2;
value = lit('=') << value1;
debug(value);
start = buffer[-value];
}
karma::rule start;
karma::rule value;
karma::rule value1;
karma::rule value2;
};
template<class It>
bool do_generate(It it, const std::string& x) {
test_generator<It> g;
return karma::generate(it, g, x);
}
template<class It>
bool do_generate2(It it, const std::string& x) {
test_generator2<It> g;
return karma::generate(it, g, x);
}
//...
std::string x2,x3;
do_generate(std::back_inserter(x2), std::string(""));
do_generate2(std::back_inserter(x3), std::string(""));
std::cerr << "|" << x2 << "|" << std::endl;
std::cerr << "|" << x3 << "|" << std::endl;
//...
The code prints:
<unnamed-rule>
<try>
<attributes>[[]]</attributes>
</try>
<fail/>
</unnamed-rule>
|=|
||
I.e. introduction of debug() alters result of the generator. Could you
please explain me where I am wrong? I am stuck now.