Skip to content

Commit dc96342

Browse files
committed
Response to xwu's review
1 parent 3fc43bc commit dc96342

File tree

8 files changed

+109
-105
lines changed

8 files changed

+109
-105
lines changed

include/swift/AST/DiagnosticsParse.def

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ ERROR(lex_invalid_u_escape,none,
139139
ERROR(lex_invalid_u_escape_rbrace,none,
140140
"expected '}' in \\u{...} escape sequence", ())
141141
ERROR(lex_invalid_delimiter_escape,none,
142-
"too many # characters in delimited escape", ())
142+
"too many '#' characters in delimited escape", ())
143143
ERROR(lex_zerowidth_in_string_delimiter,none,
144144
"zero-width character detected in string delimiter", ())
145145

include/swift/Parse/Lexer.h

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -355,21 +355,21 @@ class Lexer {
355355
enum : char { Literal, Expr } Kind;
356356
// Loc+Length for the segment inside the string literal, without quotes.
357357
SourceLoc Loc;
358-
unsigned Length, IndentToStrip, DelimiterLength;
358+
unsigned Length, IndentToStrip, CustomDelimiterLen;
359359
bool IsFirstSegment, IsLastSegment;
360360

361361
static StringSegment getLiteral(SourceLoc Loc, unsigned Length,
362362
bool IsFirstSegment, bool IsLastSegment,
363363
unsigned IndentToStrip,
364-
unsigned DelimiterLength) {
364+
unsigned CustomDelimiterLen) {
365365
StringSegment Result;
366366
Result.Kind = Literal;
367367
Result.Loc = Loc;
368368
Result.Length = Length;
369369
Result.IsFirstSegment = IsFirstSegment;
370370
Result.IsLastSegment = IsLastSegment;
371371
Result.IndentToStrip = IndentToStrip;
372-
Result.DelimiterLength = DelimiterLength;
372+
Result.CustomDelimiterLen = CustomDelimiterLen;
373373
return Result;
374374
}
375375

@@ -381,7 +381,7 @@ class Lexer {
381381
Result.IsFirstSegment = false;
382382
Result.IsLastSegment = false;
383383
Result.IndentToStrip = 0;
384-
Result.DelimiterLength = 0;
384+
Result.CustomDelimiterLen = 0;
385385
return Result;
386386
}
387387

@@ -399,13 +399,13 @@ class Lexer {
399399
bool IsFirstSegment = false,
400400
bool IsLastSegment = false,
401401
unsigned IndentToStrip = 0,
402-
unsigned DelimiterLength = 0);
402+
unsigned CustomDelimiterLen = 0);
403403
StringRef getEncodedStringSegment(StringSegment Segment,
404404
SmallVectorImpl<char> &Buffer) const {
405405
return getEncodedStringSegment(
406406
StringRef(getBufferPtrForSourceLoc(Segment.Loc), Segment.Length),
407407
Buffer, Segment.IsFirstSegment, Segment.IsLastSegment,
408-
Segment.IndentToStrip, Segment.DelimiterLength);
408+
Segment.IndentToStrip, Segment.CustomDelimiterLen);
409409
}
410410

411411
/// \brief Given a string literal token, separate it into string/expr segments
@@ -469,8 +469,8 @@ class Lexer {
469469
return diagnose(Loc, Diagnostic(DiagID, std::forward<ArgTypes>(Args)...));
470470
}
471471

472-
void formToken(tok Kind, const char *TokStart, bool MultilineString = false,
473-
unsigned DelimiterLength = 0);
472+
void formToken(tok Kind, const char *TokStart, bool IsMultilineString = false,
473+
unsigned CustomDelimiterLen = 0);
474474
void formEscapedIdentifierToken(const char *TokStart);
475475

476476
/// Advance to the end of the line.
@@ -495,9 +495,9 @@ class Lexer {
495495
static unsigned lexUnicodeEscape(const char *&CurPtr, Lexer *Diags);
496496

497497
unsigned lexCharacter(const char *&CurPtr, char StopQuote,
498-
bool EmitDiagnostics, bool MultilineString = false,
499-
unsigned DelimiterLength = 0);
500-
void lexStringLiteral(unsigned DelimiterLength = 0);
498+
bool EmitDiagnostics, bool IsMultilineString = false,
499+
unsigned CustomDelimiterLen = 0);
500+
void lexStringLiteral(unsigned CustomDelimiterLen = 0);
501501
void lexEscapedIdentifier();
502502

503503
void tryLexEditorPlaceholder();

include/swift/Parse/Token.h

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ class Token {
4646
unsigned MultilineString : 1;
4747

4848
/// Length of custom delimiter of "raw" string literals
49-
unsigned StringDelimiterLength : 8;
49+
unsigned CustomDelimiterLen : 8;
5050

5151
// Padding bits == 32 - 11;
5252

@@ -65,7 +65,7 @@ class Token {
6565
public:
6666
Token(tok Kind, StringRef Text, unsigned CommentLength = 0)
6767
: Kind(Kind), AtStartOfLine(false), EscapedIdentifier(false),
68-
MultilineString(false), StringDelimiterLength(0),
68+
MultilineString(false), CustomDelimiterLen(0),
6969
CommentLength(CommentLength), Text(Text) {}
7070

7171
Token() : Token(tok::NUM_TOKENS, {}, 0) {}
@@ -269,22 +269,23 @@ class Token {
269269

270270
/// \brief Set the token to the specified kind and source range.
271271
void setToken(tok K, StringRef T, unsigned CommentLength = 0,
272-
bool MultilineString = false, unsigned DelimiterLength = 0) {
272+
bool IsMultilineString = false, unsigned CustomDelimiterLen = 0) {
273273
Kind = K;
274274
Text = T;
275275
this->CommentLength = CommentLength;
276276
EscapedIdentifier = false;
277-
this->MultilineString = MultilineString;
278-
StringDelimiterLength = DelimiterLength;
279-
assert(StringDelimiterLength == DelimiterLength && "delimiter too long");
277+
this->MultilineString = IsMultilineString;
278+
this->CustomDelimiterLen = CustomDelimiterLen;
279+
assert(this->CustomDelimiterLen == CustomDelimiterLen &&
280+
"string custom delimiter too long");
280281
}
281282

282-
bool IsMultilineString() const {
283+
bool isMultilineString() const {
283284
return MultilineString;
284285
}
285286

286-
unsigned getDelimiterLength() const {
287-
return StringDelimiterLength;
287+
unsigned getCustomDelimiterLen() const {
288+
return CustomDelimiterLen;
288289
}
289290
};
290291

0 commit comments

Comments
 (0)