mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-04-20 11:36:10 +00:00
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:
parent
5a36d8acb8
commit
96d13f75cf
Notes:
sideshowbarker
2024-07-19 04:35:51 +09:00
Author: https://github.com/nico Commit: https://github.com/SerenityOS/serenity/commit/96d13f75cf2 Pull-request: https://github.com/SerenityOS/serenity/pull/2889
2 changed files with 24 additions and 0 deletions
|
@ -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();
|
||||
|
|
|
@ -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) \
|
||||
|
|
Loading…
Add table
Reference in a new issue