Skip to content

Commit 7687063

Browse files
authored
Merge pull request #19168 from apple/revert-17668-master
Revert "[Parse] Implementation for SE-200 (raw strings)"
2 parents 192587c + df22ea1 commit 7687063

File tree

9 files changed

+79
-357
lines changed

9 files changed

+79
-357
lines changed

include/swift/AST/DiagnosticsParse.def

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -138,10 +138,6 @@ ERROR(lex_invalid_u_escape,none,
138138
"\\u{...} escape sequence expects between 1 and 8 hex digits", ())
139139
ERROR(lex_invalid_u_escape_rbrace,none,
140140
"expected '}' in \\u{...} escape sequence", ())
141-
ERROR(lex_invalid_escape_delimiter,none,
142-
"too many '#' characters in delimited escape", ())
143-
ERROR(lex_invalid_closing_delimiter,none,
144-
"too many '#' characters in closing delimiter", ())
145141

146142
ERROR(lex_invalid_unicode_scalar,none,
147143
"invalid unicode scalar", ())

include/swift/Parse/Lexer.h

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -364,21 +364,19 @@ class Lexer {
364364
enum : char { Literal, Expr } Kind;
365365
// Loc+Length for the segment inside the string literal, without quotes.
366366
SourceLoc Loc;
367-
unsigned Length, IndentToStrip, CustomDelimiterLen;
367+
unsigned Length, IndentToStrip;
368368
bool IsFirstSegment, IsLastSegment;
369369

370370
static StringSegment getLiteral(SourceLoc Loc, unsigned Length,
371371
bool IsFirstSegment, bool IsLastSegment,
372-
unsigned IndentToStrip,
373-
unsigned CustomDelimiterLen) {
372+
unsigned IndentToStrip) {
374373
StringSegment Result;
375374
Result.Kind = Literal;
376375
Result.Loc = Loc;
377376
Result.Length = Length;
378377
Result.IsFirstSegment = IsFirstSegment;
379378
Result.IsLastSegment = IsLastSegment;
380379
Result.IndentToStrip = IndentToStrip;
381-
Result.CustomDelimiterLen = CustomDelimiterLen;
382380
return Result;
383381
}
384382

@@ -390,7 +388,6 @@ class Lexer {
390388
Result.IsFirstSegment = false;
391389
Result.IsLastSegment = false;
392390
Result.IndentToStrip = 0;
393-
Result.CustomDelimiterLen = 0;
394391
return Result;
395392
}
396393

@@ -407,14 +404,13 @@ class Lexer {
407404
SmallVectorImpl<char> &Buffer,
408405
bool IsFirstSegment = false,
409406
bool IsLastSegment = false,
410-
unsigned IndentToStrip = 0,
411-
unsigned CustomDelimiterLen = 0);
407+
unsigned IndentToStrip = 0);
412408
StringRef getEncodedStringSegment(StringSegment Segment,
413409
SmallVectorImpl<char> &Buffer) const {
414410
return getEncodedStringSegment(
415411
StringRef(getBufferPtrForSourceLoc(Segment.Loc), Segment.Length),
416412
Buffer, Segment.IsFirstSegment, Segment.IsLastSegment,
417-
Segment.IndentToStrip, Segment.CustomDelimiterLen);
413+
Segment.IndentToStrip);
418414
}
419415

420416
/// \brief Given a string literal token, separate it into string/expr segments
@@ -478,8 +474,7 @@ class Lexer {
478474
return diagnose(Loc, Diagnostic(DiagID, std::forward<ArgTypes>(Args)...));
479475
}
480476

481-
void formToken(tok Kind, const char *TokStart, bool IsMultilineString = false,
482-
unsigned CustomDelimiterLen = 0);
477+
void formToken(tok Kind, const char *TokStart, bool MultilineString = false);
483478
void formEscapedIdentifierToken(const char *TokStart);
484479

485480
/// Advance to the end of the line.
@@ -503,10 +498,10 @@ class Lexer {
503498
void lexTrivia(syntax::Trivia &T, bool IsForTrailingTrivia);
504499
static unsigned lexUnicodeEscape(const char *&CurPtr, Lexer *Diags);
505500

506-
unsigned lexCharacter(const char *&CurPtr, char StopQuote,
507-
bool EmitDiagnostics, bool IsMultilineString = false,
508-
unsigned CustomDelimiterLen = 0);
509-
void lexStringLiteral(unsigned CustomDelimiterLen = 0);
501+
unsigned lexCharacter(const char *&CurPtr,
502+
char StopQuote, bool EmitDiagnostics,
503+
bool MultilineString = false);
504+
void lexStringLiteral();
510505
void lexEscapedIdentifier();
511506

512507
void tryLexEditorPlaceholder();

include/swift/Parse/Token.h

Lines changed: 6 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,7 @@ class Token {
4545
/// Modifiers for string literals
4646
unsigned MultilineString : 1;
4747

48-
/// Length of custom delimiter of "raw" string literals
49-
unsigned CustomDelimiterLen : 8;
50-
51-
// Padding bits == 32 - 11;
48+
// Padding bits == 32 - sizeof(Kind) * 8 - 3;
5249

5350
/// \brief The length of the comment that precedes the token.
5451
unsigned CommentLength;
@@ -65,8 +62,8 @@ class Token {
6562
public:
6663
Token(tok Kind, StringRef Text, unsigned CommentLength = 0)
6764
: Kind(Kind), AtStartOfLine(false), EscapedIdentifier(false),
68-
MultilineString(false), CustomDelimiterLen(0),
69-
CommentLength(CommentLength), Text(Text) {}
65+
MultilineString(false), CommentLength(CommentLength),
66+
Text(Text) {}
7067

7168
Token() : Token(tok::NUM_TOKENS, {}, 0) {}
7269

@@ -269,24 +266,17 @@ class Token {
269266

270267
/// \brief Set the token to the specified kind and source range.
271268
void setToken(tok K, StringRef T, unsigned CommentLength = 0,
272-
bool IsMultilineString = false, unsigned CustomDelimiterLen = 0) {
269+
bool MultilineString = false) {
273270
Kind = K;
274271
Text = T;
275272
this->CommentLength = CommentLength;
276273
EscapedIdentifier = false;
277-
this->MultilineString = IsMultilineString;
278-
this->CustomDelimiterLen = CustomDelimiterLen;
279-
assert(this->CustomDelimiterLen == CustomDelimiterLen &&
280-
"custom string delimiter length > 255");
274+
this->MultilineString = MultilineString;
281275
}
282276

283-
bool isMultilineString() const {
277+
bool IsMultilineString() const {
284278
return MultilineString;
285279
}
286-
287-
unsigned getCustomDelimiterLen() const {
288-
return CustomDelimiterLen;
289-
}
290280
};
291281

292282
} // end namespace swift

0 commit comments

Comments
 (0)