1

I'm new to spirit x3 and was wondering what x3::raw is good for. I experimented with a simple parser following an example from qi:

const auto rule= (x3::alpha | '_') >> *(x3::alnum | '_');
const auto rule_raw= x3::raw[ rule ];

string in = "Jame007   "; // trailing spaces
string result;

auto r= x3::phrase_parse( in.begin(), in.end(), rule, x3::ascii::space, result );
cerr << "rule: " << r << "  result:'" << result << "'\n";

result= "";
r= x3::phrase_parse( in.begin(), in.end(), rule_raw, x3::ascii::space, result );
cerr << "rule_raw: " << r << "  result:'" << result << "'\n";

The output is

rule: 1 result:'Jame007'
rule_raw: 1 result:'Jame007 ' <--- includes spaces

The outcome of parsing with rule is as expected, but why does the result of rule_raw contain the trailing spaces?

august_71
  • 93
  • 1
  • 4

0 Answers0