CppLexer: Add token types for "+", "+=", "-", "-=", "=", "==", "/", "/="

Mostly so that TextEdit doesn't emit logspam when I write `int a = 4`
in a test program.
This commit is contained in:
Nico Weber 2020-07-26 13:39:43 -04:00 committed by Andreas Kling
parent 5a36d8acb8
commit 96d13f75cf
Notes: sideshowbarker 2024-07-19 04:35:51 +09:00
2 changed files with 24 additions and 0 deletions

View file

@ -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();

View file

@ -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) \