summaryrefslogtreecommitdiff
path: root/Libraries/LibGUI
diff options
context:
space:
mode:
authorNico Weber <thakis@chromium.org>2020-07-26 13:35:47 -0400
committerAndreas Kling <kling@serenityos.org>2020-07-26 19:52:26 +0200
commit5a36d8acb85ae346f670467e761deb724a5f4813 (patch)
treeba022c1f1436937660f6aa618b737f3b58239ba7 /Libraries/LibGUI
parentb09b8d99f230593fe33464078d4354dd978f153a (diff)
downloadserenity-5a36d8acb85ae346f670467e761deb724a5f4813.zip
CppLexer: Add token type for "*="
Diffstat (limited to 'Libraries/LibGUI')
-rw-r--r--Libraries/LibGUI/CppLexer.cpp13
-rw-r--r--Libraries/LibGUI/CppLexer.h1
2 files changed, 13 insertions, 1 deletions
diff --git a/Libraries/LibGUI/CppLexer.cpp b/Libraries/LibGUI/CppLexer.cpp
index c901437d00..8db91f3f23 100644
--- a/Libraries/LibGUI/CppLexer.cpp
+++ b/Libraries/LibGUI/CppLexer.cpp
@@ -243,6 +243,17 @@ Vector<CppToken> CppLexer::lex()
tokens.append(token);
};
+ auto emit_token_equals = [&](auto type, auto equals_type) {
+ if (peek(1) == '=') {
+ begin_token();
+ consume();
+ consume();
+ commit_token(equals_type);
+ return;
+ }
+ emit_token(type);
+ };
+
auto match_escape_sequence = [&]() -> size_t {
switch (peek(1)) {
case '\'':
@@ -336,7 +347,7 @@ Vector<CppToken> CppLexer::lex()
continue;
}
if (ch == '*') {
- emit_token(CppToken::Type::Asterisk);
+ emit_token_equals(CppToken::Type::Asterisk, CppToken::Type::AsteriskEquals);
continue;
}
if (ch == ';') {
diff --git a/Libraries/LibGUI/CppLexer.h b/Libraries/LibGUI/CppLexer.h
index 9de2e319e0..7e217c8b10 100644
--- a/Libraries/LibGUI/CppLexer.h
+++ b/Libraries/LibGUI/CppLexer.h
@@ -45,6 +45,7 @@ namespace GUI {
__TOKEN(RightBracket) \
__TOKEN(Comma) \
__TOKEN(Asterisk) \
+ __TOKEN(AsteriskEquals) \
__TOKEN(Semicolon) \
__TOKEN(DoubleQuotedString) \
__TOKEN(SingleQuotedString) \