@@ -1864,7 +1864,8 @@ parseStringSegments(SmallVectorImpl<Lexer::StringSegment> &Segments,
1864
1864
SyntaxKind::ExpressionSegment);
1865
1865
1866
1866
// Backslash is part of an expression segment.
1867
- Token BackSlash (tok::backslash, " \\ " );
1867
+ Token BackSlash (tok::backslash,
1868
+ CharSourceRange (Segment.Loc .getAdvancedLoc (-1 ), 1 ).str ());
1868
1869
ExprContext.addToken (BackSlash, EmptyTrivia, EmptyTrivia);
1869
1870
// Create a temporary lexer that lexes from the body of the string.
1870
1871
LexerState BeginState =
@@ -2013,15 +2014,19 @@ ParserResult<Expr> Parser::parseExprStringLiteral() {
2013
2014
2014
2015
// We are now sure this is a string interpolation expression.
2015
2016
LocalContext.setCreateSyntax (SyntaxKind::StringInterpolationExpr);
2016
- StringRef Quote ;
2017
+ StringRef OpenQuoteStr, CloseQuoteStr ;
2017
2018
tok QuoteKind;
2018
- std::tie (Quote, QuoteKind) = Tok.isMultilineString () ?
2019
- std::make_tuple (" \"\"\" " , tok::multiline_string_quote) :
2020
- std::make_tuple (" \" " , tok::string_quote);
2019
+ std::tie (OpenQuoteStr, CloseQuoteStr, QuoteKind) = Tok.isMultilineString () ?
2020
+ std::make_tuple (Tok.getRawText ().take_front (3 ),
2021
+ Tok.getRawText ().take_back (3 ),
2022
+ tok::multiline_string_quote) :
2023
+ std::make_tuple (Tok.getRawText ().take_front (1 ),
2024
+ Tok.getRawText ().take_back (1 ),
2025
+ tok::string_quote);
2021
2026
2022
2027
// Make unknown tokens to represent the open and close quote.
2023
- Token OpenQuote (QuoteKind, Quote );
2024
- Token CloseQuote (QuoteKind, Quote );
2028
+ Token OpenQuote (QuoteKind, OpenQuoteStr );
2029
+ Token CloseQuote (QuoteKind, CloseQuoteStr );
2025
2030
Trivia EmptyTrivia;
2026
2031
Trivia EntireTrailingTrivia = TrailingTrivia;
2027
2032
0 commit comments