From 7a1c328417972efc33af8bc7cbc745340369a8f0 Mon Sep 17 00:00:00 2001 From: Nico Weber Date: Sun, 26 Jul 2020 18:35:17 -0400 Subject: [PATCH] CppLexer: Add token types for "::", "::*", ".*", "->*" --- Libraries/LibGUI/CppLexer.cpp | 28 ++++++++++++++++++++++++++-- Libraries/LibGUI/CppLexer.h | 4 ++++ 2 files changed, 30 insertions(+), 2 deletions(-) diff --git a/Libraries/LibGUI/CppLexer.cpp b/Libraries/LibGUI/CppLexer.cpp index 5f6507b1e0..26a95296b6 100644 --- a/Libraries/LibGUI/CppLexer.cpp +++ b/Libraries/LibGUI/CppLexer.cpp @@ -424,6 +424,11 @@ Vector CppLexer::lex() } if (peek() == '>') { consume(); + if (peek() == '*') { + consume(); + commit_token(CppToken::Type::ArrowAsterisk); + continue; + } commit_token(CppToken::Type::Arrow); continue; } @@ -491,7 +496,19 @@ Vector CppLexer::lex() continue; } if (ch == ':') { - emit_token(CppToken::Type::Colon); + begin_token(); + consume(); + if (peek() == ':') { + consume(); + if (peek() == '*') { + consume(); + commit_token(CppToken::Type::ColonColonAsterisk); + continue; + } + commit_token(CppToken::Type::ColonColon); + continue; + } + commit_token(CppToken::Type::Colon); continue; } if (ch == ';') { @@ -499,7 +516,14 @@ Vector CppLexer::lex() continue; } if (ch == '.') { - emit_token(CppToken::Type::Dot); + begin_token(); + consume(); + if (peek() == '*') { + consume(); + commit_token(CppToken::Type::DotAsterisk); + continue; + } + commit_token(CppToken::Type::Dot); continue; } if (ch == '#') { diff --git a/Libraries/LibGUI/CppLexer.h b/Libraries/LibGUI/CppLexer.h index 8e2a6b99c4..5e14dc2d88 100644 --- a/Libraries/LibGUI/CppLexer.h +++ b/Libraries/LibGUI/CppLexer.h @@ -80,9 +80,13 @@ namespace GUI { __TOKEN(Tilde) \ __TOKEN(QuestionMark) \ __TOKEN(Colon) \ + __TOKEN(ColonColon) \ + __TOKEN(ColonColonAsterisk) \ __TOKEN(Semicolon) \ __TOKEN(Dot) \ + __TOKEN(DotAsterisk) \ __TOKEN(Arrow) \ + __TOKEN(ArrowAsterisk) \ __TOKEN(DoubleQuotedString) \ __TOKEN(SingleQuotedString) \ __TOKEN(EscapeSequence) \