Closed roccomoretti closed 2 years ago
Hi Rocco,
I'm very late in looking at this. This looks like valuable support for raw strings in C++11 and a welcome addition to the beautifier. I'm not sure it covers all cases, though.
It looks like your code will perfectly handle this case:
std::string foo = R"x(bar)x";
but neither
std::string foo = R"(bar)";
nor
std::string foo = R"xyz(bar)xyz";
which I believe the standard supports.
It certainly supports R"xyz(bar)xyz"
, as that's what I tested it against (R"raw_string(...)raw_string";
: https://github.com/RosettaCommons/main/pull/5360/files#diff-4b43811eda2e5b721391426fb66f5e9fc516cb9de4abb97b403bf737619faf47R138-R149)
I think you're right that it wouldn't handle R"(bar)"
-- I wasn't aware that was a possibility for raw strings.
Ah, yes, I see my error. I was thinking:
self.raw_string_literal_delim = self.this_line_tokens[i+2].spelling
was taking only a single character instead of the full token.
See PR #104 for potential fixes for the R"(bar)"
case.
C++11 added support for raw string literals https://en.cppreference.com/w/cpp/language/string_literal
The beautifier was confused about them. This change should add support for them in the beautifier.
I'm not sure I got all the edge cases, but the basic support looks like it's working.