mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-06-30 06:01:57 +00:00
CppLexer: Add token types for "<", "<=", "<<", "<<=", "<>"
This commit is contained in:
parent
23082e528f
commit
97c4344f33
Notes:
sideshowbarker
2024-07-19 04:35:23 +09:00
Author: https://github.com/nico
Commit: 97c4344f33
Pull-request: https://github.com/SerenityOS/serenity/pull/2893
2 changed files with 41 additions and 0 deletions
|
@ -342,6 +342,32 @@ Vector<CppToken> CppLexer::lex()
|
||||||
emit_token(CppToken::Type::RightBracket);
|
emit_token(CppToken::Type::RightBracket);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
if (ch == '<') {
|
||||||
|
begin_token();
|
||||||
|
consume();
|
||||||
|
if (peek() == '<') {
|
||||||
|
consume();
|
||||||
|
if (peek() == '=') {
|
||||||
|
consume();
|
||||||
|
commit_token(CppToken::Type::LessLessEquals);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
commit_token(CppToken::Type::LessLess);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (peek() == '=') {
|
||||||
|
consume();
|
||||||
|
commit_token(CppToken::Type::LessEquals);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (peek() == '>') {
|
||||||
|
consume();
|
||||||
|
commit_token(CppToken::Type::LessGreater);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
commit_token(CppToken::Type::Less);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
if (ch == ',') {
|
if (ch == ',') {
|
||||||
emit_token(CppToken::Type::Comma);
|
emit_token(CppToken::Type::Comma);
|
||||||
continue;
|
continue;
|
||||||
|
@ -358,6 +384,10 @@ Vector<CppToken> CppLexer::lex()
|
||||||
emit_token_equals(CppToken::Type::Asterisk, CppToken::Type::AsteriskEquals);
|
emit_token_equals(CppToken::Type::Asterisk, CppToken::Type::AsteriskEquals);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
if (ch == '%') {
|
||||||
|
emit_token_equals(CppToken::Type::Percent, CppToken::Type::PercentEquals);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
if (ch == '=') {
|
if (ch == '=') {
|
||||||
emit_token_equals(CppToken::Type::Equals, CppToken::Type::EqualsEquals);
|
emit_token_equals(CppToken::Type::Equals, CppToken::Type::EqualsEquals);
|
||||||
continue;
|
continue;
|
||||||
|
|
|
@ -43,6 +43,15 @@ namespace GUI {
|
||||||
__TOKEN(RightCurly) \
|
__TOKEN(RightCurly) \
|
||||||
__TOKEN(LeftBracket) \
|
__TOKEN(LeftBracket) \
|
||||||
__TOKEN(RightBracket) \
|
__TOKEN(RightBracket) \
|
||||||
|
__TOKEN(Less) \
|
||||||
|
__TOKEN(Greater) \
|
||||||
|
__TOKEN(LessEquals) \
|
||||||
|
__TOKEN(GreaterEquals) \
|
||||||
|
__TOKEN(LessLess) \
|
||||||
|
__TOKEN(GreaterGreater) \
|
||||||
|
__TOKEN(LessLessEquals) \
|
||||||
|
__TOKEN(GreaterGreaterEquals) \
|
||||||
|
__TOKEN(LessGreater) \
|
||||||
__TOKEN(Comma) \
|
__TOKEN(Comma) \
|
||||||
__TOKEN(Plus) \
|
__TOKEN(Plus) \
|
||||||
__TOKEN(PlusEquals) \
|
__TOKEN(PlusEquals) \
|
||||||
|
@ -52,6 +61,8 @@ namespace GUI {
|
||||||
__TOKEN(AsteriskEquals) \
|
__TOKEN(AsteriskEquals) \
|
||||||
__TOKEN(Slash) \
|
__TOKEN(Slash) \
|
||||||
__TOKEN(SlashEquals) \
|
__TOKEN(SlashEquals) \
|
||||||
|
__TOKEN(Percent) \
|
||||||
|
__TOKEN(PercentEquals) \
|
||||||
__TOKEN(Equals) \
|
__TOKEN(Equals) \
|
||||||
__TOKEN(EqualsEquals) \
|
__TOKEN(EqualsEquals) \
|
||||||
__TOKEN(Semicolon) \
|
__TOKEN(Semicolon) \
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue