summaryrefslogtreecommitdiff
path: root/Libraries/LibGUI/CppLexer.cpp
diff options
context:
space:
mode:
authorNico Weber <thakis@chromium.org>2020-07-26 18:13:13 -0400
committerAndreas Kling <kling@serenityos.org>2020-07-27 01:04:17 +0200
commitc38b8d63f85ebd8168cb3c94e5e2ffefac68667d (patch)
treef4a50b75ca02525f96a9b11a1257b643f29fd657 /Libraries/LibGUI/CppLexer.cpp
parent598b5e459559d32ab136dbde6fb615b7bdf62510 (diff)
downloadserenity-c38b8d63f85ebd8168cb3c94e5e2ffefac68667d.zip
CppLexer: Add token types for "++", "--"
Diffstat (limited to 'Libraries/LibGUI/CppLexer.cpp')
-rw-r--r--Libraries/LibGUI/CppLexer.cpp28
1 files changed, 26 insertions, 2 deletions
diff --git a/Libraries/LibGUI/CppLexer.cpp b/Libraries/LibGUI/CppLexer.cpp
index c1f8853519..66d8647977 100644
--- a/Libraries/LibGUI/CppLexer.cpp
+++ b/Libraries/LibGUI/CppLexer.cpp
@@ -394,11 +394,35 @@ Vector<CppToken> CppLexer::lex()
continue;
}
if (ch == '+') {
- emit_token_equals(CppToken::Type::Plus, CppToken::Type::PlusEquals);
+ begin_token();
+ consume();
+ if (peek() == '+') {
+ consume();
+ commit_token(CppToken::Type::PlusPlus);
+ continue;
+ }
+ if (peek() == '=') {
+ consume();
+ commit_token(CppToken::Type::PlusEquals);
+ continue;
+ }
+ commit_token(CppToken::Type::Plus);
continue;
}
if (ch == '-') {
- emit_token_equals(CppToken::Type::Minus, CppToken::Type::MinusEquals);
+ begin_token();
+ consume();
+ if (peek() == '-') {
+ consume();
+ commit_token(CppToken::Type::MinusMinus);
+ continue;
+ }
+ if (peek() == '=') {
+ consume();
+ commit_token(CppToken::Type::MinusEquals);
+ continue;
+ }
+ commit_token(CppToken::Type::Minus);
continue;
}
if (ch == '*') {