diff options
author | Nico Weber <thakis@chromium.org> | 2020-07-26 18:35:17 -0400 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2020-07-27 01:04:17 +0200 |
commit | 7a1c328417972efc33af8bc7cbc745340369a8f0 (patch) | |
tree | 285aef59eadc1c6c290be4443363961d0966e6b2 | |
parent | 1992dbd637fa18f829aaf3f1c9e77849815c33a4 (diff) | |
download | serenity-7a1c328417972efc33af8bc7cbc745340369a8f0.zip |
CppLexer: Add token types for "::", "::*", ".*", "->*"
-rw-r--r-- | Libraries/LibGUI/CppLexer.cpp | 28 | ||||
-rw-r--r-- | 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<CppToken> 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<CppToken> 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<CppToken> 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) \ |