File tree Expand file tree Collapse file tree 1 file changed +24
-8
lines changed Expand file tree Collapse file tree 1 file changed +24
-8
lines changed Original file line number Diff line number Diff line change @@ -308,6 +308,22 @@ Vector<CppToken> CppLexer::lex()
308
308
}
309
309
};
310
310
311
+ auto match_string_prefix = [&](char quote) -> size_t {
312
+ if (peek () == quote)
313
+ return 1 ;
314
+ if (peek () == ' L' && peek (1 ) == quote)
315
+ return 2 ;
316
+ if (peek () == ' u' ) {
317
+ if (peek (1 ) == quote)
318
+ return 2 ;
319
+ if (peek (1 ) == ' 8' && peek (2 ) == quote)
320
+ return 3 ;
321
+ }
322
+ if (peek () == ' U' && peek (1 ) == quote)
323
+ return 2 ;
324
+ return 0 ;
325
+ };
326
+
311
327
while (m_index < m_input.length ()) {
312
328
auto ch = peek ();
313
329
if (isspace (ch)) {
@@ -597,13 +613,13 @@ Vector<CppToken> CppLexer::lex()
597
613
emit_token_equals (CppToken::Type::Slash, CppToken::Type::SlashEquals);
598
614
continue ;
599
615
}
600
- if (ch == ' "' ) {
616
+ if (size_t prefix = match_string_prefix ( ' "' ); prefix > 0 ) {
601
617
begin_token ();
602
- consume ();
618
+ for (size_t i = 0 ; i < prefix; ++i)
619
+ consume ();
603
620
while (peek ()) {
604
621
if (peek () == ' \\ ' ) {
605
- size_t escape = match_escape_sequence ();
606
- if (escape > 0 ) {
622
+ if (size_t escape = match_escape_sequence (); escape > 0 ) {
607
623
commit_token (CppToken::Type::DoubleQuotedString);
608
624
begin_token ();
609
625
for (size_t i = 0 ; i < escape; ++i)
@@ -620,13 +636,13 @@ Vector<CppToken> CppLexer::lex()
620
636
commit_token (CppToken::Type::DoubleQuotedString);
621
637
continue ;
622
638
}
623
- if (ch == ' \' ' ) {
639
+ if (size_t prefix = match_string_prefix ( ' \' ' ); prefix > 0 ) {
624
640
begin_token ();
625
- consume ();
641
+ for (size_t i = 0 ; i < prefix; ++i)
642
+ consume ();
626
643
while (peek ()) {
627
644
if (peek () == ' \\ ' ) {
628
- size_t escape = match_escape_sequence ();
629
- if (escape > 0 ) {
645
+ if (size_t escape = match_escape_sequence (); escape > 0 ) {
630
646
commit_token (CppToken::Type::SingleQuotedString);
631
647
begin_token ();
632
648
for (size_t i = 0 ; i < escape; ++i)
You can’t perform that action at this time.
0 commit comments