mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-04-27 23:09:08 +00:00
CppLexer: Add token types for "++", "--"
This commit is contained in:
parent
598b5e4595
commit
c38b8d63f8
Notes:
sideshowbarker
2024-07-19 04:35:08 +09:00
Author: https://github.com/nico
Commit: c38b8d63f8
Pull-request: https://github.com/SerenityOS/serenity/pull/2893
2 changed files with 28 additions and 2 deletions
|
@ -394,11 +394,35 @@ Vector<CppToken> CppLexer::lex()
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (ch == '+') {
|
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;
|
continue;
|
||||||
}
|
}
|
||||||
if (ch == '-') {
|
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;
|
continue;
|
||||||
}
|
}
|
||||||
if (ch == '*') {
|
if (ch == '*') {
|
||||||
|
|
|
@ -54,8 +54,10 @@ namespace GUI {
|
||||||
__TOKEN(LessGreater) \
|
__TOKEN(LessGreater) \
|
||||||
__TOKEN(Comma) \
|
__TOKEN(Comma) \
|
||||||
__TOKEN(Plus) \
|
__TOKEN(Plus) \
|
||||||
|
__TOKEN(PlusPlus) \
|
||||||
__TOKEN(PlusEquals) \
|
__TOKEN(PlusEquals) \
|
||||||
__TOKEN(Minus) \
|
__TOKEN(Minus) \
|
||||||
|
__TOKEN(MinusMinus) \
|
||||||
__TOKEN(MinusEquals) \
|
__TOKEN(MinusEquals) \
|
||||||
__TOKEN(Asterisk) \
|
__TOKEN(Asterisk) \
|
||||||
__TOKEN(AsteriskEquals) \
|
__TOKEN(AsteriskEquals) \
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue