diff options
author | Nico Weber <thakis@chromium.org> | 2020-07-26 18:13:13 -0400 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2020-07-27 01:04:17 +0200 |
commit | c38b8d63f85ebd8168cb3c94e5e2ffefac68667d (patch) | |
tree | f4a50b75ca02525f96a9b11a1257b643f29fd657 /Libraries/LibGUI/CppLexer.cpp | |
parent | 598b5e459559d32ab136dbde6fb615b7bdf62510 (diff) | |
download | serenity-c38b8d63f85ebd8168cb3c94e5e2ffefac68667d.zip |
CppLexer: Add token types for "++", "--"
Diffstat (limited to 'Libraries/LibGUI/CppLexer.cpp')
-rw-r--r-- | Libraries/LibGUI/CppLexer.cpp | 28 |
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 == '*') { |