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 | |
parent | 598b5e459559d32ab136dbde6fb615b7bdf62510 (diff) | |
download | serenity-c38b8d63f85ebd8168cb3c94e5e2ffefac68667d.zip |
CppLexer: Add token types for "++", "--"
-rw-r--r-- | Libraries/LibGUI/CppLexer.cpp | 28 | ||||
-rw-r--r-- | Libraries/LibGUI/CppLexer.h | 2 |
2 files changed, 28 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 == '*') { diff --git a/Libraries/LibGUI/CppLexer.h b/Libraries/LibGUI/CppLexer.h index 88d0ebcf4e..8bd80c355d 100644 --- a/Libraries/LibGUI/CppLexer.h +++ b/Libraries/LibGUI/CppLexer.h @@ -54,8 +54,10 @@ namespace GUI { __TOKEN(LessGreater) \ __TOKEN(Comma) \ __TOKEN(Plus) \ + __TOKEN(PlusPlus) \ __TOKEN(PlusEquals) \ __TOKEN(Minus) \ + __TOKEN(MinusMinus) \ __TOKEN(MinusEquals) \ __TOKEN(Asterisk) \ __TOKEN(AsteriskEquals) \ |