mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
Implement SE-0200 (extended escaping in string literals)
Supports string literals like #"foo"\n"bar"#.
This commit is contained in:
committed by
Brent Royal-Gordon
parent
5e2b705f6d
commit
4da8cbe655
@@ -45,7 +45,10 @@ class Token {
|
||||
/// Modifiers for string literals
|
||||
unsigned MultilineString : 1;
|
||||
|
||||
// Padding bits == 32 - sizeof(Kind) * 8 - 3;
|
||||
/// Length of custom delimiter of "raw" string literals
|
||||
unsigned CustomDelimiterLen : 8;
|
||||
|
||||
// Padding bits == 32 - 11;
|
||||
|
||||
/// \brief The length of the comment that precedes the token.
|
||||
unsigned CommentLength;
|
||||
@@ -62,8 +65,8 @@ class Token {
|
||||
public:
|
||||
Token(tok Kind, StringRef Text, unsigned CommentLength = 0)
|
||||
: Kind(Kind), AtStartOfLine(false), EscapedIdentifier(false),
|
||||
MultilineString(false), CommentLength(CommentLength),
|
||||
Text(Text) {}
|
||||
MultilineString(false), CustomDelimiterLen(0),
|
||||
CommentLength(CommentLength), Text(Text) {}
|
||||
|
||||
Token() : Token(tok::NUM_TOKENS, {}, 0) {}
|
||||
|
||||
@@ -266,17 +269,24 @@ public:
|
||||
|
||||
/// \brief Set the token to the specified kind and source range.
|
||||
void setToken(tok K, StringRef T, unsigned CommentLength = 0,
|
||||
bool MultilineString = false) {
|
||||
bool IsMultilineString = false, unsigned CustomDelimiterLen = 0) {
|
||||
Kind = K;
|
||||
Text = T;
|
||||
this->CommentLength = CommentLength;
|
||||
EscapedIdentifier = false;
|
||||
this->MultilineString = MultilineString;
|
||||
this->MultilineString = IsMultilineString;
|
||||
this->CustomDelimiterLen = CustomDelimiterLen;
|
||||
assert(this->CustomDelimiterLen == CustomDelimiterLen &&
|
||||
"custom string delimiter length > 255");
|
||||
}
|
||||
|
||||
bool IsMultilineString() const {
|
||||
bool isMultilineString() const {
|
||||
return MultilineString;
|
||||
}
|
||||
|
||||
unsigned getCustomDelimiterLen() const {
|
||||
return CustomDelimiterLen;
|
||||
}
|
||||
};
|
||||
|
||||
} // end namespace swift
|
||||
|
||||
Reference in New Issue
Block a user