summaryrefslogtreecommitdiff
path: root/Libraries
diff options
context:
space:
mode:
authorNico Weber <thakis@chromium.org>2020-07-26 13:39:43 -0400
committerAndreas Kling <kling@serenityos.org>2020-07-26 19:52:26 +0200
commit96d13f75cf2659cba8392db5469fdef1c831ceec (patch)
tree885d8a4c0c6ea4b53984b9f6c52fc761061e62ee /Libraries
parent5a36d8acb85ae346f670467e761deb724a5f4813 (diff)
downloadserenity-96d13f75cf2659cba8392db5469fdef1c831ceec.zip
CppLexer: Add token types for "+", "+=", "-", "-=", "=", "==", "/", "/="
Mostly so that TextEdit doesn't emit logspam when I write `int a = 4` in a test program.
Diffstat (limited to 'Libraries')
-rw-r--r--Libraries/LibGUI/CppLexer.cpp16
-rw-r--r--Libraries/LibGUI/CppLexer.h8
2 files changed, 24 insertions, 0 deletions
diff --git a/Libraries/LibGUI/CppLexer.cpp b/Libraries/LibGUI/CppLexer.cpp
index 8db91f3f23..4631a9185e 100644
--- a/Libraries/LibGUI/CppLexer.cpp
+++ b/Libraries/LibGUI/CppLexer.cpp
@@ -346,10 +346,22 @@ Vector<CppToken> CppLexer::lex()
emit_token(CppToken::Type::Comma);
continue;
}
+ if (ch == '+') {
+ emit_token_equals(CppToken::Type::Plus, CppToken::Type::PlusEquals);
+ continue;
+ }
+ if (ch == '-') {
+ emit_token_equals(CppToken::Type::Minus, CppToken::Type::MinusEquals);
+ continue;
+ }
if (ch == '*') {
emit_token_equals(CppToken::Type::Asterisk, CppToken::Type::AsteriskEquals);
continue;
}
+ if (ch == '=') {
+ emit_token_equals(CppToken::Type::Equals, CppToken::Type::EqualsEquals);
+ continue;
+ }
if (ch == ';') {
emit_token(CppToken::Type::Semicolon);
continue;
@@ -422,6 +434,10 @@ Vector<CppToken> CppLexer::lex()
commit_token(CppToken::Type::Comment);
continue;
}
+ if (ch == '/') {
+ emit_token_equals(CppToken::Type::Slash, CppToken::Type::SlashEquals);
+ continue;
+ }
if (ch == '"') {
begin_token();
consume();
diff --git a/Libraries/LibGUI/CppLexer.h b/Libraries/LibGUI/CppLexer.h
index 7e217c8b10..cc0c76ecb6 100644
--- a/Libraries/LibGUI/CppLexer.h
+++ b/Libraries/LibGUI/CppLexer.h
@@ -44,8 +44,16 @@ namespace GUI {
__TOKEN(LeftBracket) \
__TOKEN(RightBracket) \
__TOKEN(Comma) \
+ __TOKEN(Plus) \
+ __TOKEN(PlusEquals) \
+ __TOKEN(Minus) \
+ __TOKEN(MinusEquals) \
__TOKEN(Asterisk) \
__TOKEN(AsteriskEquals) \
+ __TOKEN(Slash) \
+ __TOKEN(SlashEquals) \
+ __TOKEN(Equals) \
+ __TOKEN(EqualsEquals) \
__TOKEN(Semicolon) \
__TOKEN(DoubleQuotedString) \
__TOKEN(SingleQuotedString) \